mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
buttons to release all provinces and regenerate culture name
This commit is contained in:
parent
567cf3676a
commit
6de70f5897
8 changed files with 301 additions and 149 deletions
|
|
@ -128,20 +128,14 @@ window.Names = (function () {
|
|||
|
||||
// generate name for culture
|
||||
const getCulture = function (culture, min, max, dupl) {
|
||||
if (culture === undefined) {
|
||||
ERROR && console.error("Please define a culture");
|
||||
return;
|
||||
}
|
||||
if (culture === undefined) return ERROR && console.error("Please define a culture");
|
||||
const base = pack.cultures[culture].base;
|
||||
return getBase(base, min, max, dupl);
|
||||
};
|
||||
|
||||
// generate short name for culture
|
||||
const getCultureShort = function (culture) {
|
||||
if (culture === undefined) {
|
||||
ERROR && console.error("Please define a culture");
|
||||
return;
|
||||
}
|
||||
if (culture === undefined) return ERROR && console.error("Please define a culture");
|
||||
return getBaseShort(pack.cultures[culture].base);
|
||||
};
|
||||
|
||||
|
|
@ -157,55 +151,75 @@ window.Names = (function () {
|
|||
};
|
||||
|
||||
// generate state name based on capital or random name and culture-specific suffix
|
||||
// prettier-ignore
|
||||
const getState = function(name, culture, base) {
|
||||
if (name === undefined) {ERROR && console.error("Please define a base name"); return;}
|
||||
if (culture === undefined && base === undefined) {ERROR && console.error("Please define a culture"); return;}
|
||||
const getState = function (name, culture, base) {
|
||||
if (name === undefined) return ERROR && console.error("Please define a base name");
|
||||
if (culture === undefined && base === undefined) return ERROR && console.error("Please define a culture");
|
||||
if (base === undefined) base = pack.cultures[culture].base;
|
||||
|
||||
// exclude endings inappropriate for states name
|
||||
if (name.includes(" ")) name = capitalize(name.replace(/ /g, "").toLowerCase()); // don't allow multiword state names
|
||||
if (name.length > 6 && name.slice(-4) === "berg") name = name.slice(0,-4); // remove -berg for any
|
||||
if (name.length > 5 && name.slice(-3) === "ton") name = name.slice(0,-3); // remove -ton for any
|
||||
if (name.length > 6 && name.slice(-4) === "berg") name = name.slice(0, -4); // remove -berg for any
|
||||
if (name.length > 5 && name.slice(-3) === "ton") name = name.slice(0, -3); // remove -ton for any
|
||||
|
||||
if (base === 5 && ["sk", "ev", "ov"].includes(name.slice(-2))) name = name.slice(0,-2); // remove -sk/-ev/-ov for Ruthenian
|
||||
else if (base === 12) return vowel(name.slice(-1)) ? name : name + "u"; // Japanese ends on any vowel or -u
|
||||
else if (base === 18 && P(.4)) name = vowel(name.slice(0,1).toLowerCase()) ? "Al" + name.toLowerCase() : "Al " + name; // Arabic starts with -Al
|
||||
if (base === 5 && ["sk", "ev", "ov"].includes(name.slice(-2))) name = name.slice(0, -2);
|
||||
// remove -sk/-ev/-ov for Ruthenian
|
||||
else if (base === 12) return vowel(name.slice(-1)) ? name : name + "u";
|
||||
// Japanese ends on any vowel or -u
|
||||
else if (base === 18 && P(0.4)) name = vowel(name.slice(0, 1).toLowerCase()) ? "Al" + name.toLowerCase() : "Al " + name; // Arabic starts with -Al
|
||||
|
||||
// no suffix for fantasy bases
|
||||
if (base > 32 && base < 42) return name;
|
||||
|
||||
// define if suffix should be used
|
||||
if (name.length > 3 && vowel(name.slice(-1))) {
|
||||
if (vowel(name.slice(-2,-1)) && P(.85)) name = name.slice(0,-2); // 85% for vv
|
||||
else if (P(.7)) name = name.slice(0,-1); // ~60% for cv
|
||||
if (vowel(name.slice(-2, -1)) && P(0.85)) name = name.slice(0, -2);
|
||||
// 85% for vv
|
||||
else if (P(0.7)) name = name.slice(0, -1);
|
||||
// ~60% for cv
|
||||
else return name;
|
||||
} else if (P(.4)) return name; // 60% for cc and vc
|
||||
} else if (P(0.4)) return name; // 60% for cc and vc
|
||||
|
||||
// define suffix
|
||||
let suffix = "ia"; // standard suffix
|
||||
|
||||
const rnd = Math.random(), l = name.length;
|
||||
if (base === 3 && rnd < .03 && l < 7) suffix = "terra"; // Italian
|
||||
else if (base === 4 && rnd < .03 && l < 7) suffix = "terra"; // Spanish
|
||||
else if (base === 13 && rnd < .03 && l < 7) suffix = "terra"; // Portuguese
|
||||
else if (base === 2 && rnd < .03 && l < 7) suffix = "terre"; // French
|
||||
else if (base === 0 && rnd < .5 && l < 7) suffix = "land"; // German
|
||||
else if (base === 1 && rnd < .4 && l < 7 ) suffix = "land"; // English
|
||||
else if (base === 6 && rnd < .3 && l < 7) suffix = "land"; // Nordic
|
||||
else if (base === 32 && rnd < .1 && l < 7) suffix = "land"; // generic Human
|
||||
else if (base === 7 && rnd < .1) suffix = "eia"; // Greek
|
||||
else if (base === 9 && rnd < .35) suffix = "maa"; // Finnic
|
||||
else if (base === 15 && rnd < .4 && l < 6) suffix = "orszag"; // Hungarian
|
||||
else if (base === 16) suffix = rnd < .6 ? "stan" : "ya"; // Turkish
|
||||
else if (base === 10) suffix = "guk"; // Korean
|
||||
else if (base === 11) suffix = " Guo"; // Chinese
|
||||
else if (base === 14) suffix = rnd < .5 && l < 6 ? "tlan" : "co"; // Nahuatl
|
||||
else if (base === 17 && rnd < .8) suffix = "a"; // Berber
|
||||
else if (base === 18 && rnd < .8) suffix = "a"; // Arabic
|
||||
const rnd = Math.random(),
|
||||
l = name.length;
|
||||
if (base === 3 && rnd < 0.03 && l < 7) suffix = "terra";
|
||||
// Italian
|
||||
else if (base === 4 && rnd < 0.03 && l < 7) suffix = "terra";
|
||||
// Spanish
|
||||
else if (base === 13 && rnd < 0.03 && l < 7) suffix = "terra";
|
||||
// Portuguese
|
||||
else if (base === 2 && rnd < 0.03 && l < 7) suffix = "terre";
|
||||
// French
|
||||
else if (base === 0 && rnd < 0.5 && l < 7) suffix = "land";
|
||||
// German
|
||||
else if (base === 1 && rnd < 0.4 && l < 7) suffix = "land";
|
||||
// English
|
||||
else if (base === 6 && rnd < 0.3 && l < 7) suffix = "land";
|
||||
// Nordic
|
||||
else if (base === 32 && rnd < 0.1 && l < 7) suffix = "land";
|
||||
// generic Human
|
||||
else if (base === 7 && rnd < 0.1) suffix = "eia";
|
||||
// Greek
|
||||
else if (base === 9 && rnd < 0.35) suffix = "maa";
|
||||
// Finnic
|
||||
else if (base === 15 && rnd < 0.4 && l < 6) suffix = "orszag";
|
||||
// Hungarian
|
||||
else if (base === 16) suffix = rnd < 0.6 ? "stan" : "ya";
|
||||
// Turkish
|
||||
else if (base === 10) suffix = "guk";
|
||||
// Korean
|
||||
else if (base === 11) suffix = " Guo";
|
||||
// Chinese
|
||||
else if (base === 14) suffix = rnd < 0.5 && l < 6 ? "tlan" : "co";
|
||||
// Nahuatl
|
||||
else if (base === 17 && rnd < 0.8) suffix = "a";
|
||||
// Berber
|
||||
else if (base === 18 && rnd < 0.8) suffix = "a"; // Arabic
|
||||
|
||||
return validateSuffix(name, suffix);
|
||||
}
|
||||
};
|
||||
|
||||
function validateSuffix(name, suffix) {
|
||||
if (name.slice(-1 * suffix.length) === suffix) return name; // no suffix if name already ends with it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue