mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.5.25 - smarter generation
This commit is contained in:
parent
2f3f5d05fb
commit
66bd7b7f6f
9 changed files with 38 additions and 28 deletions
|
|
@ -88,8 +88,8 @@
|
||||||
const expansionism = rn(Math.random() * powerInput.value + 1, 1);
|
const expansionism = rn(Math.random() * powerInput.value + 1, 1);
|
||||||
const basename = b.name.length < 9 && b.cell%5 === 0 ? b.name : Names.getCultureShort(b.culture);
|
const basename = b.name.length < 9 && b.cell%5 === 0 ? b.name : Names.getCultureShort(b.culture);
|
||||||
const name = Names.getState(basename, b.culture);
|
const name = Names.getState(basename, b.culture);
|
||||||
const nomadic = [1, 2, 3, 4].includes(cells.biome[b.cell]);
|
const type = cultures[b.culture].type;
|
||||||
const type = nomadic ? "Nomadic" : cultures[b.culture].type === "Nomadic" ? "Generic" : cultures[b.culture].type;
|
|
||||||
const coa = COA.generate(null, null, null, type);
|
const coa = COA.generate(null, null, null, type);
|
||||||
coa.shield = COA.getShield(b.culture, null);
|
coa.shield = COA.getShield(b.culture, null);
|
||||||
states.push({i, color: colors[i-1], name, expansionism, capital: i, type, center: b.cell, culture: b.culture, coa});
|
states.push({i, color: colors[i-1], name, expansionism, capital: i, type, center: b.cell, culture: b.culture, coa});
|
||||||
|
|
@ -185,9 +185,9 @@
|
||||||
if (b.capital) kinship += .1;
|
if (b.capital) kinship += .1;
|
||||||
else if (b.port) kinship -= .1;
|
else if (b.port) kinship -= .1;
|
||||||
if (b.culture !== state.culture) kinship -= .25;
|
if (b.culture !== state.culture) kinship -= .25;
|
||||||
b.type = getBurgType(b, i);
|
b.type = getType(i, b.port);
|
||||||
const type = b.capital && P(.2) ? "Capital" : b.type === "Generic" ? "City" : b.type;
|
const type = b.capital && P(.2) ? "Capital" : b.type === "Generic" ? "City" : b.type;
|
||||||
b.coa = COA.generate(stateCOA, kinship, null, type === "Generic" ? null : type);
|
b.coa = COA.generate(stateCOA, kinship, null, type);
|
||||||
b.coa.shield = COA.getShield(b.culture, b.state);
|
b.coa.shield = COA.getShield(b.culture, b.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,10 +202,10 @@
|
||||||
TIME && console.timeEnd("specifyBurgs");
|
TIME && console.timeEnd("specifyBurgs");
|
||||||
}
|
}
|
||||||
|
|
||||||
const getBurgType = function(b, i) {
|
const getType = function(i, port) {
|
||||||
const cells = pack.cells;
|
const cells = pack.cells;
|
||||||
if (b.port) return "Naval";
|
if (port) return "Naval";
|
||||||
if (cells.haven[i] && pack.features[cells.f[cells.haven[i]]].type === "lake") return "River";
|
if (cells.haven[i] && pack.features[cells.f[cells.haven[i]]].type === "lake") return "Lake";
|
||||||
if (cells.h[i] > 60) return "Highland";
|
if (cells.h[i] > 60) return "Highland";
|
||||||
if (cells.r[i] && cells.r[i].length > 100 && cells.r[i].length >= pack.rivers[0].length) return "River";
|
if (cells.r[i] && cells.r[i].length > 100 && cells.r[i].length >= pack.rivers[0].length) return "River";
|
||||||
if ([1, 2, 3, 4].includes(cells.biome[i])) return "Nomadic";
|
if ([1, 2, 3, 4].includes(cells.biome[i])) return "Nomadic";
|
||||||
|
|
@ -952,7 +952,8 @@
|
||||||
const fullName = name + " " + formName;
|
const fullName = name + " " + formName;
|
||||||
const color = getMixedColor(s.color);
|
const color = getMixedColor(s.color);
|
||||||
const kinship = nameByBurg ? .8 : .4;
|
const kinship = nameByBurg ? .8 : .4;
|
||||||
const coa = COA.generate(stateBurgs[i].coa, kinship, null, burg.port ? "Naval" : null);
|
const type = getType(center, burg.port);
|
||||||
|
const coa = COA.generate(stateBurgs[i].coa, kinship, null, type);
|
||||||
coa.shield = COA.getShield(c, s.i);
|
coa.shield = COA.getShield(c, s.i);
|
||||||
provinces.push({i:province, state:s.i, center, burg, name, formName, fullName, color, coa});
|
provinces.push({i:province, state:s.i, center, burg, name, formName, fullName, color, coa});
|
||||||
}
|
}
|
||||||
|
|
@ -1049,8 +1050,8 @@
|
||||||
const color = getMixedColor(s.color);
|
const color = getMixedColor(s.color);
|
||||||
const dominion = colony ? P(.95) : singleIsle || isleGroup ? P(.7) : P(.3);
|
const dominion = colony ? P(.95) : singleIsle || isleGroup ? P(.7) : P(.3);
|
||||||
const kinship = dominion ? 0 : .4;
|
const kinship = dominion ? 0 : .4;
|
||||||
const naval = singleIsle || !isleGroup || burgs[burg]?.port;
|
const type = getType(center, burgs[burg]?.port);
|
||||||
const coa = COA.generate(s.coa, kinship, dominion, naval ? "Naval" : null);
|
const coa = COA.generate(s.coa, kinship, dominion, type);
|
||||||
coa.shield = COA.getShield(c, s.i);
|
coa.shield = COA.getShield(c, s.i);
|
||||||
provinces.push({i:province, state:s.i, center, burg, name, formName, fullName, color, coa});
|
provinces.push({i:province, state:s.i, center, burg, name, formName, fullName, color, coa});
|
||||||
s.provinces.push(province);
|
s.provinces.push(province);
|
||||||
|
|
@ -1080,7 +1081,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return {generate, expandStates, normalizeStates, assignColors,
|
return {generate, expandStates, normalizeStates, assignColors,
|
||||||
drawBurgs, specifyBurgs, defineBurgFeatures, drawStateLabels, collectStatistics,
|
drawBurgs, specifyBurgs, defineBurgFeatures, getType, drawStateLabels, collectStatistics,
|
||||||
generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, updateCultures};
|
generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, updateCultures};
|
||||||
|
|
||||||
})));
|
})));
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@
|
||||||
const division = divisioned ? parent?.division && P(kinship - .1) ? parent.division.division : rw(divisions.variants) : null;
|
const division = divisioned ? parent?.division && P(kinship - .1) ? parent.division.division : rw(divisions.variants) : null;
|
||||||
if (charge) charge =
|
if (charge) charge =
|
||||||
parent?.charges && P(kinship - .1) ? parent.charges[0].charge :
|
parent?.charges && P(kinship - .1) ? parent.charges[0].charge :
|
||||||
type && type !== "Generic" && P(.3) ? rw(charges[type]) :
|
type && type !== "Generic" && P(.2) ? rw(charges[type]) :
|
||||||
selectCharge();
|
selectCharge();
|
||||||
|
|
||||||
if (division) {
|
if (division) {
|
||||||
|
|
|
||||||
|
|
@ -967,8 +967,9 @@
|
||||||
return fetchedCharges.join("");
|
return fetchedCharges.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const url = PRODUCTION ? "https://azgaar.github.io/Armoria/charges/" : "http://armoria.herokuapp.com/charges/";
|
||||||
async function fetchCharge(charge, id) {
|
async function fetchCharge(charge, id) {
|
||||||
const fetched = fetch("https://azgaar.github.io/Armoria/charges/" + charge + ".svg").then(res => {
|
const fetched = fetch(url + charge + ".svg").then(res => {
|
||||||
if (res.ok) return res.text();
|
if (res.ok) return res.text();
|
||||||
else throw new Error("Cannot fetch charge");
|
else throw new Error("Cannot fetch charge");
|
||||||
}).then(text => {
|
}).then(text => {
|
||||||
|
|
|
||||||
|
|
@ -1073,6 +1073,14 @@ function parseLoadedData(data) {
|
||||||
localStorage.removeItem("styleGloom");
|
localStorage.removeItem("styleGloom");
|
||||||
localStorage.removeItem("styleAncient");
|
localStorage.removeItem("styleAncient");
|
||||||
localStorage.removeItem("styleMonochrome");
|
localStorage.removeItem("styleMonochrome");
|
||||||
|
|
||||||
|
// v 1.5 added burg type value
|
||||||
|
pack.burgs.forEach(burg => {
|
||||||
|
if (!burg.i || burg.removed) return;
|
||||||
|
burg.type = BurgsAndStates.getType(burg.cell, burg.port);
|
||||||
|
});
|
||||||
|
|
||||||
|
BurgsAndStates.getType(cell, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,14 @@ function addBurg(point) {
|
||||||
|
|
||||||
const temple = pack.states[state].form === "Theocracy";
|
const temple = pack.states[state].form === "Theocracy";
|
||||||
const population = Math.max((cells.s[cell] + cells.road[cell]) / 3 + i / 1000 + cell % 100 / 1000, .1);
|
const population = Math.max((cells.s[cell] + cells.road[cell]) / 3 + i / 1000 + cell % 100 / 1000, .1);
|
||||||
|
const type = BurgsAndStates.getType(cell, false);
|
||||||
|
|
||||||
// generate emblem
|
// generate emblem
|
||||||
const coa = COA.generate(pack.states[state].coa, .25);
|
const coa = COA.generate(pack.states[state].coa, .25, null, type);
|
||||||
coa.shield = COA.getShield(culture, state);
|
coa.shield = COA.getShield(culture, state);
|
||||||
COArenderer.add("burg", i, coa, x, y);
|
COArenderer.add("burg", i, coa, x, y);
|
||||||
|
|
||||||
pack.burgs.push({name, cell, x, y, state, i, culture, feature, capital: 0, port: 0, temple, population, coa});
|
pack.burgs.push({name, cell, x, y, state, i, culture, feature, capital: 0, port: 0, temple, population, coa, type});
|
||||||
cells.burg[cell] = i;
|
cells.burg[cell] = i;
|
||||||
|
|
||||||
const townSize = burgIcons.select("#towns").attr("size") || 0.5;
|
const townSize = burgIcons.select("#towns").attr("size") || 0.5;
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ function editEmblem(type, id, el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const shield = el.coa.shield || COA.getShield(el.culture || parent?.culture || 0, el.state);
|
const shield = el.coa.shield || COA.getShield(el.culture || parent?.culture || 0, el.state);
|
||||||
el.coa = COA.generate(parent ? parent.coa : null);
|
el.coa = COA.generate(parent ? parent.coa : null, .3, .1, null);
|
||||||
el.coa.shield = shield;
|
el.coa.shield = shield;
|
||||||
emblemShapeSelector.disabled = false;
|
emblemShapeSelector.disabled = false;
|
||||||
emblemShapeSelector.value = el.coa.shield;
|
emblemShapeSelector.value = el.coa.shield;
|
||||||
|
|
|
||||||
|
|
@ -193,11 +193,6 @@ function editProvinces() {
|
||||||
openPicker(currentFill, callback);
|
openPicker(currentFill, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function editCOA(p) {
|
|
||||||
const coa = COA.toString(pack.provinces[p].coa);
|
|
||||||
openURL("http://azgaar.github.io/Armoria/?coa=" + coa);
|
|
||||||
}
|
|
||||||
|
|
||||||
function capitalZoomIn(p) {
|
function capitalZoomIn(p) {
|
||||||
const capital = pack.provinces[p].burg;
|
const capital = pack.provinces[p].burg;
|
||||||
const l = burgLabels.select("[data-id='" + capital + "']");
|
const l = burgLabels.select("[data-id='" + capital + "']");
|
||||||
|
|
@ -780,7 +775,8 @@ function editProvinces() {
|
||||||
// generate emblem
|
// generate emblem
|
||||||
const kinship = burg ? .8 : .4;
|
const kinship = burg ? .8 : .4;
|
||||||
const parent = burg ? pack.burgs[burg].coa : pack.states[state].coa;
|
const parent = burg ? pack.burgs[burg].coa : pack.states[state].coa;
|
||||||
const coa = COA.generate(parent, kinship);
|
const type = BurgsAndStates.getType(center, parent.port);
|
||||||
|
const coa = COA.generate(parent, kinship, P(.1), type);
|
||||||
coa.shield = COA.getShield(c, state);
|
coa.shield = COA.getShield(c, state);
|
||||||
COArenderer.add("province", province, coa, point[0], point[1]);
|
COArenderer.add("province", province, coa, point[0], point[1]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -844,7 +844,8 @@ function editStates() {
|
||||||
const color = getRandomColor();
|
const color = getRandomColor();
|
||||||
|
|
||||||
// generate emblem
|
// generate emblem
|
||||||
const coa = COA.generate(burgs[burg].coa, .4);
|
const cultureType = pack.cultures[culture].type;
|
||||||
|
const coa = COA.generate(burgs[burg].coa, .4, null, cultureType);
|
||||||
coa.shield = COA.getShield(culture, null);
|
coa.shield = COA.getShield(culture, null);
|
||||||
|
|
||||||
// update diplomacy and reverse relations
|
// update diplomacy and reverse relations
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,8 @@ function regenerateStates() {
|
||||||
const type = nomadic ? "Nomadic" : pack.cultures[culture].type === "Nomadic" ? "Generic" : pack.cultures[culture].type;
|
const type = nomadic ? "Nomadic" : pack.cultures[culture].type === "Nomadic" ? "Generic" : pack.cultures[culture].type;
|
||||||
const expansionism = rn(Math.random() * powerInput.value + 1, 1);
|
const expansionism = rn(Math.random() * powerInput.value + 1, 1);
|
||||||
|
|
||||||
const coa = COA.generate(capital.coa, .3);
|
const cultureType = pack.cultures[culture].type;
|
||||||
|
const coa = COA.generate(capital.coa, .3, null, cultureType);
|
||||||
coa.shield = capital.coa.shield;
|
coa.shield = capital.coa.shield;
|
||||||
|
|
||||||
return {i, name, type, capital:capital.i, center:capital.cell, culture, expansionism, coa};
|
return {i, name, type, capital:capital.i, center:capital.cell, culture, expansionism, coa};
|
||||||
|
|
@ -272,7 +273,8 @@ function regenerateEmblems() {
|
||||||
// generate new emblems
|
// generate new emblems
|
||||||
pack.states.forEach(state => {
|
pack.states.forEach(state => {
|
||||||
if (!state.i || state.removed) return;
|
if (!state.i || state.removed) return;
|
||||||
state.coa = COA.generate(null);
|
const cultureType = pack.cultures[state.culture].type;
|
||||||
|
state.coa = COA.generate(null, null, null, cultureType);
|
||||||
state.coa.shield = COA.getShield(state.culture, null);
|
state.coa.shield = COA.getShield(state.culture, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -284,7 +286,7 @@ function regenerateEmblems() {
|
||||||
if (burg.capital) kinship += .1;
|
if (burg.capital) kinship += .1;
|
||||||
else if (burg.port) kinship -= .1;
|
else if (burg.port) kinship -= .1;
|
||||||
if (burg.culture !== state.culture) kinship -= .25;
|
if (burg.culture !== state.culture) kinship -= .25;
|
||||||
burg.coa = COA.generate(state.coa, kinship);
|
burg.coa = COA.generate(state.coa, kinship, null, burg.type);
|
||||||
burg.coa.shield = COA.getShield(burg.culture, burg.state);
|
burg.coa.shield = COA.getShield(burg.culture, burg.state);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -305,8 +307,8 @@ function regenerateEmblems() {
|
||||||
const nameByBurg = province.burg && province.name.slice(0, 3) === parent.name.slice(0, 3);
|
const nameByBurg = province.burg && province.name.slice(0, 3) === parent.name.slice(0, 3);
|
||||||
const kinship = dominion ? 0 : nameByBurg ? .8 : .4;
|
const kinship = dominion ? 0 : nameByBurg ? .8 : .4;
|
||||||
const culture = pack.cells.culture[province.center];
|
const culture = pack.cells.culture[province.center];
|
||||||
|
const type = BurgsAndStates.getType(province.center, parent.port);
|
||||||
province.coa = COA.generate(parent.coa, kinship, dominion);
|
province.coa = COA.generate(parent.coa, kinship, dominion, type);
|
||||||
province.coa.shield = COA.getShield(culture, province.state);
|
province.coa.shield = COA.getShield(culture, province.state);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue