mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
improve MFCG link generation
This commit is contained in:
parent
dbe84ea015
commit
207b564180
3 changed files with 34 additions and 22 deletions
|
|
@ -240,7 +240,7 @@ window.BurgsAndStates = (function () {
|
||||||
b.citadel = b.capital || (pop > 50 && P(0.75)) || P(0.5) ? 1 : 0;
|
b.citadel = b.capital || (pop > 50 && P(0.75)) || P(0.5) ? 1 : 0;
|
||||||
b.plaza = pop > 50 || (pop > 30 && P(0.75)) || (pop > 10 && P(0.5)) || P(0.25) ? 1 : 0;
|
b.plaza = pop > 50 || (pop > 30 && P(0.75)) || (pop > 10 && P(0.5)) || P(0.25) ? 1 : 0;
|
||||||
b.walls = b.capital || pop > 30 || (pop > 20 && P(0.75)) || (pop > 10 && P(0.5)) || P(0.2) ? 1 : 0;
|
b.walls = b.capital || pop > 30 || (pop > 20 && P(0.75)) || (pop > 10 && P(0.5)) || P(0.2) ? 1 : 0;
|
||||||
b.shanty = pop > 30 || (pop > 20 && P(0.75)) || (b.walls && P(0.75)) ? 1 : 0;
|
b.shanty = pop > 60 || (pop > 40 && P(0.75)) || (pop > 20 && b.walls && P(0.4)) ? 1 : 0;
|
||||||
const religion = cells.religion[b.cell];
|
const religion = cells.religion[b.cell];
|
||||||
const theocracy = pack.states[b.state].form === "Theocracy";
|
const theocracy = pack.states[b.state].form === "Theocracy";
|
||||||
b.temple = (religion && theocracy) || pop > 50 || (pop > 35 && P(0.75)) || (pop > 20 && P(0.5)) ? 1 : 0;
|
b.temple = (religion && theocracy) || pop > 50 || (pop > 35 && P(0.75)) || (pop > 20 && P(0.5)) ? 1 : 0;
|
||||||
|
|
@ -1037,7 +1037,8 @@ window.BurgsAndStates = (function () {
|
||||||
if (tier < 2 && P(0.5)) return "Diocese";
|
if (tier < 2 && P(0.5)) return "Diocese";
|
||||||
if (tier < 2 && P(0.5)) return "Bishopric";
|
if (tier < 2 && P(0.5)) return "Bishopric";
|
||||||
}
|
}
|
||||||
if (P(0.9) && [7, 5].includes(base)) { // Greek, Ruthenian
|
if (P(0.9) && [7, 5].includes(base)) {
|
||||||
|
// Greek, Ruthenian
|
||||||
if (tier < 2) return "Eparchy";
|
if (tier < 2) return "Eparchy";
|
||||||
if (tier === 2) return "Exarchate";
|
if (tier === 2) return "Exarchate";
|
||||||
if (tier > 2) return "Patriarchate";
|
if (tier > 2) return "Patriarchate";
|
||||||
|
|
@ -1097,7 +1098,7 @@ window.BurgsAndStates = (function () {
|
||||||
const max = percentage == 100 ? 1000 : gauss(20, 5, 5, 100) * percentage ** 0.5; // max growth
|
const max = percentage == 100 ? 1000 : gauss(20, 5, 5, 100) * percentage ** 0.5; // max growth
|
||||||
|
|
||||||
const forms = {
|
const forms = {
|
||||||
Monarchy: {County: 22, Earldom: 6, Shire: 2, Landgrave: 2, Margrave: 2, Barony: 2, Captaincy:1, Seneschalty:1},
|
Monarchy: {County: 22, Earldom: 6, Shire: 2, Landgrave: 2, Margrave: 2, Barony: 2, Captaincy: 1, Seneschalty: 1},
|
||||||
Republic: {Province: 6, Department: 2, Governorate: 2, District: 1, Canton: 1, Prefecture: 1},
|
Republic: {Province: 6, Department: 2, Governorate: 2, District: 1, Canton: 1, Prefecture: 1},
|
||||||
Theocracy: {Parish: 3, Deanery: 1},
|
Theocracy: {Parish: 3, Deanery: 1},
|
||||||
Union: {Province: 1, State: 1, Canton: 1, Republic: 1, County: 1, Council: 1},
|
Union: {Province: 1, State: 1, Canton: 1, Republic: 1, County: 1, Council: 1},
|
||||||
|
|
|
||||||
|
|
@ -354,17 +354,18 @@ function editBurg(id) {
|
||||||
|
|
||||||
function toggleFeature() {
|
function toggleFeature() {
|
||||||
const id = +elSelected.attr("data-id");
|
const id = +elSelected.attr("data-id");
|
||||||
const b = pack.burgs[id];
|
const burg = pack.burgs[id];
|
||||||
const feature = this.dataset.feature;
|
const feature = this.dataset.feature;
|
||||||
const turnOn = this.classList.contains("inactive");
|
const turnOn = this.classList.contains("inactive");
|
||||||
if (feature === "port") togglePort(id);
|
if (feature === "port") togglePort(id);
|
||||||
else if (feature === "capital") toggleCapital(id);
|
else if (feature === "capital") toggleCapital(id);
|
||||||
else b[feature] = +turnOn;
|
else burg[feature] = +turnOn;
|
||||||
if (b[feature]) this.classList.remove("inactive");
|
if (burg[feature]) this.classList.remove("inactive");
|
||||||
else if (!b[feature]) this.classList.add("inactive");
|
else if (!burg[feature]) this.classList.add("inactive");
|
||||||
|
|
||||||
if (b.port) document.getElementById("burgEditAnchorStyle").style.display = "inline-block";
|
if (burg.port) document.getElementById("burgEditAnchorStyle").style.display = "inline-block";
|
||||||
else document.getElementById("burgEditAnchorStyle").style.display = "none";
|
else document.getElementById("burgEditAnchorStyle").style.display = "none";
|
||||||
|
updateMFCGFrame(burg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleBurgLockButton() {
|
function toggleBurgLockButton() {
|
||||||
|
|
|
||||||
|
|
@ -268,35 +268,45 @@ function getMFCGlink(burg) {
|
||||||
if (burg.link) return burg.link;
|
if (burg.link) return burg.link;
|
||||||
|
|
||||||
const {cells} = pack;
|
const {cells} = pack;
|
||||||
const {name, population, cell} = burg;
|
const {i, name, population: burgPopulation, cell} = burg;
|
||||||
const burgSeed = getBurgSeed(burg);
|
const seed = getBurgSeed(burg);
|
||||||
const sizeRaw = 2.13 * Math.pow((population * populationRate) / urbanDensity, 0.385);
|
|
||||||
|
const sizeRaw = 2.13 * Math.pow((burgPopulation * populationRate) / urbanDensity, 0.385);
|
||||||
const size = minmax(Math.ceil(sizeRaw), 6, 100);
|
const size = minmax(Math.ceil(sizeRaw), 6, 100);
|
||||||
const people = rn(population * populationRate * urbanization);
|
const population = rn(burgPopulation * populationRate * urbanization);
|
||||||
|
|
||||||
|
const river = cells.r[cell] ? 1 : 0;
|
||||||
|
const coast = Number(burg.port > 0);
|
||||||
|
const sea = coast && cells.haven[cell] ? getSeaDirections(cell) : null;
|
||||||
|
|
||||||
|
const biome = cells.biome[cell];
|
||||||
|
const arableBiomes = river ? [1, 2, 3, 4, 5, 6, 7, 8] : [5, 6, 7, 8];
|
||||||
|
const farms = +arableBiomes.includes(biome);
|
||||||
|
|
||||||
|
const citadel = +burg.citadel;
|
||||||
|
const urban_castle = +(citadel && each(2)(i));
|
||||||
|
|
||||||
const hub = +cells.road[cell] > 50;
|
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 walls = +burg.walls;
|
||||||
const plaza = +burg.plaza;
|
const plaza = +burg.plaza;
|
||||||
const temple = +burg.temple;
|
const temple = +burg.temple;
|
||||||
const shanty = +burg.shanty;
|
const shantytown = +burg.shanty;
|
||||||
|
|
||||||
const sea = coast && cells.haven[cell] ? getSeaDirections(cell) : "";
|
|
||||||
function getSeaDirections(i) {
|
function getSeaDirections(i) {
|
||||||
const p1 = cells.p[i];
|
const p1 = cells.p[i];
|
||||||
const p2 = cells.p[cells.haven[i]];
|
const p2 = cells.p[cells.haven[i]];
|
||||||
let deg = (Math.atan2(p2[1] - p1[1], p2[0] - p1[0]) * 180) / Math.PI - 90;
|
let deg = (Math.atan2(p2[1] - p1[1], p2[0] - p1[0]) * 180) / Math.PI - 90;
|
||||||
if (deg < 0) deg += 360;
|
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 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 parameters = {name, population, size, seed, river, coast, farms, citadel, urban_castle, hub, plaza, temple, walls, shantytown, gates: -1};
|
||||||
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}`;
|
const url = new URL("https://watabou.github.io/city-generator");
|
||||||
return url;
|
url.search = new URLSearchParams(parameters);
|
||||||
|
if (sea) url.searchParams.append("sea", sea);
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw legend box
|
// draw legend box
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue