diff --git a/modules/ui/burg-editor.js b/modules/ui/burg-editor.js index 1fcdf434..0f19be3f 100644 --- a/modules/ui/burg-editor.js +++ b/modules/ui/burg-editor.js @@ -408,42 +408,6 @@ function editBurg(id) { document.getElementById("mfcgPreview").setAttribute("src", mfcgURL); document.getElementById("mfcgLink").setAttribute("href", mfcgURL); } - function getBurgSeed(burg) { - return burg.MFCG || Number(`${seed}${String(burg.i).padStart(4, 0)}`); - } - - function getMFCGlink(burg) { - const {cells} = pack; - const {name, population, cell} = burg; - const burgSeed = getBurgSeed(burg); - const sizeRaw = 2.13 * Math.pow((population * populationRate) / urbanDensity, 0.385); - const size = minmax(Math.ceil(sizeRaw), 6, 100); - const people = rn(population * populationRate * urbanization); - - const hub = +cells.road[cell] > 50; - const river = cells.r[cell] ? 1 : 0; - - const coast = +burg.port; - const citadel = +burg.citadel; - const walls = +burg.walls; - const plaza = +burg.plaza; - const temple = +burg.temple; - const shanty = +burg.shanty; - - const sea = coast && cells.haven[cell] ? getSeaDirections(cell) : ""; - function getSeaDirections(i) { - const p1 = cells.p[i]; - const p2 = cells.p[cells.haven[i]]; - let deg = (Math.atan2(p2[1] - p1[1], p2[0] - p1[0]) * 180) / Math.PI - 90; - if (deg < 0) deg += 360; - const norm = rn(normalize(deg, 0, 360) * 2, 2); // 0 = south, 0.5 = west, 1 = north, 1.5 = east - return "&sea=" + norm; - } - - const baseURL = "https://watabou.github.io/city-generator/?random=0&continuous=0"; - const url = `${baseURL}&name=${name}&population=${people}&size=${size}&seed=${burgSeed}&hub=${hub}&river=${river}&coast=${coast}&citadel=${citadel}&plaza=${plaza}&temple=${temple}&walls=${walls}&shantytown=${shanty}${sea}`; - return url; - } function changeSeed() { const id = +elSelected.attr("data-id"); diff --git a/modules/ui/burgs-overview.js b/modules/ui/burgs-overview.js index ea8b2dec..5d02930b 100644 --- a/modules/ui/burgs-overview.js +++ b/modules/ui/burgs-overview.js @@ -456,10 +456,10 @@ function overviewBurgs() { } function downloadBurgsData() { - let data = - "Id,Burg,Province,Province Full Name,State,State Full Name,Culture,Religion,Population,Longitude,Latitude,Elevation (" + - heightUnit.value + - "),Capital,Port,Citadel,Walls,Plaza,Temple,Shanty Town\n"; // headers + let data = `Id,Burg,Province,Province Full Name,State,State Full Name,Culture,Religion,Population,Longitude,Latitude,Elevation (${heightUnit.value}),Capital,Port,Citadel,Walls,Plaza,Temple,Shanty Town`; // headers + if (options.showMFCGMap) data += `,City Generator Link`; + data += "\n"; + const valid = pack.burgs.filter(b => b.i && !b.removed); // all valid burgs valid.forEach(b => { @@ -486,7 +486,9 @@ function overviewBurgs() { data += b.walls ? "walls," : ","; data += b.plaza ? "plaza," : ","; data += b.temple ? "temple," : ","; - data += b.shanty ? "shanty town\n" : "\n"; + data += b.shanty ? "shanty town," : ","; + if (options.showMFCGMap) data += getMFCGlink(b); + data += "\n"; }); const name = getFileName("Burgs") + ".csv"; diff --git a/modules/ui/editors.js b/modules/ui/editors.js index 9d241334..5f648fa5 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -260,6 +260,43 @@ function togglePort(burg) { .attr("height", size); } +function getBurgSeed(burg) { + return burg.MFCG || Number(`${seed}${String(burg.i).padStart(4, 0)}`); +} + +function getMFCGlink(burg) { + const {cells} = pack; + const {name, population, cell} = burg; + const burgSeed = getBurgSeed(burg); + const sizeRaw = 2.13 * Math.pow((population * populationRate) / urbanDensity, 0.385); + const size = minmax(Math.ceil(sizeRaw), 6, 100); + const people = rn(population * populationRate * urbanization); + + const hub = +cells.road[cell] > 50; + const river = cells.r[cell] ? 1 : 0; + + const coast = +burg.port; + const citadel = +burg.citadel; + const walls = +burg.walls; + const plaza = +burg.plaza; + const temple = +burg.temple; + const shanty = +burg.shanty; + + const sea = coast && cells.haven[cell] ? getSeaDirections(cell) : ""; + function getSeaDirections(i) { + const p1 = cells.p[i]; + const p2 = cells.p[cells.haven[i]]; + let deg = (Math.atan2(p2[1] - p1[1], p2[0] - p1[0]) * 180) / Math.PI - 90; + if (deg < 0) deg += 360; + const norm = rn(normalize(deg, 0, 360) * 2, 2); // 0 = south, 0.5 = west, 1 = north, 1.5 = east + return "&sea=" + norm; + } + + const baseURL = "https://watabou.github.io/city-generator/?random=0&continuous=0"; + const url = `${baseURL}&name=${name}&population=${people}&size=${size}&seed=${burgSeed}&hub=${hub}&river=${river}&coast=${coast}&citadel=${citadel}&plaza=${plaza}&temple=${temple}&walls=${walls}&shantytown=${shanty}${sea}`; + return url; +} + function toggleBurgLock(burg) { const b = pack.burgs[burg]; b.lock = b.lock ? 0 : 1;