diff --git a/modules/burgs-and-states.js b/modules/burgs-and-states.js index 7ac6955d..25bce200 100644 --- a/modules/burgs-and-states.js +++ b/modules/burgs-and-states.js @@ -88,8 +88,8 @@ 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 name = Names.getState(basename, b.culture); - const nomadic = [1, 2, 3, 4].includes(cells.biome[b.cell]); - const type = nomadic ? "Nomadic" : cultures[b.culture].type === "Nomadic" ? "Generic" : cultures[b.culture].type; + const type = cultures[b.culture].type; + const coa = COA.generate(null, null, null, type); 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}); @@ -185,9 +185,9 @@ if (b.capital) kinship += .1; else if (b.port) kinship -= .1; 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; - 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); } @@ -202,10 +202,10 @@ TIME && console.timeEnd("specifyBurgs"); } - const getBurgType = function(b, i) { + const getType = function(i, port) { const cells = pack.cells; - if (b.port) return "Naval"; - if (cells.haven[i] && pack.features[cells.f[cells.haven[i]]].type === "lake") return "River"; + if (port) return "Naval"; + if (cells.haven[i] && pack.features[cells.f[cells.haven[i]]].type === "lake") return "Lake"; 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 ([1, 2, 3, 4].includes(cells.biome[i])) return "Nomadic"; @@ -952,7 +952,8 @@ const fullName = name + " " + formName; const color = getMixedColor(s.color); 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); provinces.push({i:province, state:s.i, center, burg, name, formName, fullName, color, coa}); } @@ -1049,8 +1050,8 @@ const color = getMixedColor(s.color); const dominion = colony ? P(.95) : singleIsle || isleGroup ? P(.7) : P(.3); const kinship = dominion ? 0 : .4; - const naval = singleIsle || !isleGroup || burgs[burg]?.port; - const coa = COA.generate(s.coa, kinship, dominion, naval ? "Naval" : null); + const type = getType(center, burgs[burg]?.port); + const coa = COA.generate(s.coa, kinship, dominion, type); coa.shield = COA.getShield(c, s.i); provinces.push({i:province, state:s.i, center, burg, name, formName, fullName, color, coa}); s.provinces.push(province); @@ -1080,7 +1081,7 @@ } return {generate, expandStates, normalizeStates, assignColors, - drawBurgs, specifyBurgs, defineBurgFeatures, drawStateLabels, collectStatistics, + drawBurgs, specifyBurgs, defineBurgFeatures, getType, drawStateLabels, collectStatistics, generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, updateCultures}; }))); diff --git a/modules/coa-generator.js b/modules/coa-generator.js index 8a0562ca..e2cf6493 100644 --- a/modules/coa-generator.js +++ b/modules/coa-generator.js @@ -205,7 +205,7 @@ const division = divisioned ? parent?.division && P(kinship - .1) ? parent.division.division : rw(divisions.variants) : null; if (charge) 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(); if (division) { diff --git a/modules/coa-renderer.js b/modules/coa-renderer.js index 8fcbd524..1cb305c7 100644 --- a/modules/coa-renderer.js +++ b/modules/coa-renderer.js @@ -967,8 +967,9 @@ return fetchedCharges.join(""); } + const url = PRODUCTION ? "https://azgaar.github.io/Armoria/charges/" : "http://armoria.herokuapp.com/charges/"; 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(); else throw new Error("Cannot fetch charge"); }).then(text => { diff --git a/modules/save-and-load.js b/modules/save-and-load.js index 4e785d7c..3a42be49 100644 --- a/modules/save-and-load.js +++ b/modules/save-and-load.js @@ -1073,6 +1073,14 @@ function parseLoadedData(data) { localStorage.removeItem("styleGloom"); localStorage.removeItem("styleAncient"); 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); } }() diff --git a/modules/ui/editors.js b/modules/ui/editors.js index 74168294..5e1b6c1f 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -124,13 +124,14 @@ function addBurg(point) { 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 type = BurgsAndStates.getType(cell, false); // 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); 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; const townSize = burgIcons.select("#towns").attr("size") || 0.5; diff --git a/modules/ui/emblems-editor.js b/modules/ui/emblems-editor.js index 8bab6d8a..6a8a945b 100644 --- a/modules/ui/emblems-editor.js +++ b/modules/ui/emblems-editor.js @@ -167,7 +167,7 @@ function editEmblem(type, id, el) { } 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; emblemShapeSelector.disabled = false; emblemShapeSelector.value = el.coa.shield; diff --git a/modules/ui/provinces-editor.js b/modules/ui/provinces-editor.js index e8fab8dd..adda7d3e 100644 --- a/modules/ui/provinces-editor.js +++ b/modules/ui/provinces-editor.js @@ -193,11 +193,6 @@ function editProvinces() { 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) { const capital = pack.provinces[p].burg; const l = burgLabels.select("[data-id='" + capital + "']"); @@ -780,7 +775,8 @@ function editProvinces() { // generate emblem const kinship = burg ? .8 : .4; 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); COArenderer.add("province", province, coa, point[0], point[1]); diff --git a/modules/ui/states-editor.js b/modules/ui/states-editor.js index 42e228aa..bcaea20e 100644 --- a/modules/ui/states-editor.js +++ b/modules/ui/states-editor.js @@ -844,7 +844,8 @@ function editStates() { const color = getRandomColor(); // 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); // update diplomacy and reverse relations diff --git a/modules/ui/tools.js b/modules/ui/tools.js index 10e3b5df..6c648024 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -166,7 +166,8 @@ function regenerateStates() { const type = nomadic ? "Nomadic" : pack.cultures[culture].type === "Nomadic" ? "Generic" : pack.cultures[culture].type; 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; return {i, name, type, capital:capital.i, center:capital.cell, culture, expansionism, coa}; @@ -272,7 +273,8 @@ function regenerateEmblems() { // generate new emblems pack.states.forEach(state => { 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); }); @@ -284,7 +286,7 @@ function regenerateEmblems() { if (burg.capital) kinship += .1; else if (burg.port) kinship -= .1; 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); }); @@ -305,8 +307,8 @@ function regenerateEmblems() { const nameByBurg = province.burg && province.name.slice(0, 3) === parent.name.slice(0, 3); const kinship = dominion ? 0 : nameByBurg ? .8 : .4; const culture = pack.cells.culture[province.center]; - - province.coa = COA.generate(parent.coa, kinship, dominion); + const type = BurgsAndStates.getType(province.center, parent.port); + province.coa = COA.generate(parent.coa, kinship, dominion, type); province.coa.shield = COA.getShield(culture, province.state); });