This commit is contained in:
Azgaar 2020-03-27 17:52:23 +03:00
parent cba011282d
commit c8f758ab3c
15 changed files with 397 additions and 135 deletions

View file

@ -76,6 +76,9 @@
}
// parse word to get a final name
const l = last(w); // last letter
if (l === "'" || l === " ") w = w.slice(0,-1); // not allow apostrophe and space at the end
let name = [...w].reduce(function(r, c, i, d) {
if (c === d[i+1] && !dupl.includes(c)) return r; // duplication is not allowed
if (!r.length) return c.toUpperCase();
@ -83,8 +86,7 @@
if (r.slice(-1) === " ") return r + c.toUpperCase(); // capitalize letter after space
if (r.slice(-1) === "-") return r + c.toUpperCase(); // capitalize letter after hyphen
if (c === "a" && d[i+1] === "e") return r; // "ae" => "e"
if (c === " " && i+1 === d.length) return r;
if (i+2 < d.length && !vowel(c) && !vowel(d[i+1]) && !vowel(d[i+2])) return r; // remove consonant before 2 consonants
if (i+1 < d.length && !vowel(c) && !vowel(d[i-1]) && !vowel(d[i+1])) return r; // remove consonant between 2 consonants
if (i+2 < d.length && c === d[i+1] && c === d[i+2]) return r; // remove tree same letters in a row
return r + c;
}, "");
@ -96,6 +98,7 @@
console.error("Name is too short! Random name to be selected");
name = ra(nameBases[base].b.split(","));
}
return name;
}
@ -115,8 +118,7 @@
// generate short name for base
const getBaseShort = function(base) {
if (nameBases[base] === undefined) {
tip(`Namebase for culture ${pack.cultures[culture].name} does not exist.
Please upload custom namebases of change the base in Cultures Editor`, false, "error");
tip(`Namebase ${base} does not exist. Please upload custom namebases of change the base in Cultures Editor`, false, "error");
base = 1;
}
const min = nameBases[base].min-1;