mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
Adding Town Generator
This commit is contained in:
parent
74fb543101
commit
44be43d1cf
6 changed files with 102 additions and 47 deletions
|
|
@ -405,19 +405,64 @@ function editBurg(id) {
|
|||
|
||||
function updateMFCGFrame(burg) {
|
||||
const mfcgURL = getMFCGlink(burg);
|
||||
const burgGeneratorURL = getBurgLink(burg);
|
||||
document.getElementById("mfcgPreview").setAttribute("src", mfcgURL);
|
||||
document.getElementById("mfcgLink").setAttribute("href", mfcgURL);
|
||||
document.getElementById("burgGenerator").setAttribute("href", burgGeneratorURL);
|
||||
debug
|
||||
}
|
||||
function getBurgSeed(burg) {
|
||||
return burg.MFCG || Number(`${seed}${String(burg.i).padStart(4, 0)}`);
|
||||
}
|
||||
|
||||
function getBurgLink(burg) {
|
||||
const {cells} = pack;
|
||||
let burgCulture = pack.cultures[burg.culture].name.split('(')[1].split(')')[0];
|
||||
|
||||
|
||||
const {name, population, cell} = burg;
|
||||
const burgSeed = getBurgSeed(burg);
|
||||
const sizeRaw = 0.43 * Math.pow((population * populationRate) / urbanDensity, 0.385);
|
||||
const size = minmax(Math.ceil(sizeRaw), 2, 40);
|
||||
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;
|
||||
}
|
||||
let townSize = "tiny";
|
||||
if (people > 200) townSize = 'small';
|
||||
if (people > 900) townSize = 'medium';
|
||||
if (people > 2_000) townSize = 'average';
|
||||
if (people > 5_500) townSize = 'big';
|
||||
const baseURL = "http://localhost:9090/town/";
|
||||
const url = `${baseURL}${name}-${burgCulture}/${townSize}`;
|
||||
|
||||
return url;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getMFCGlink(burg) {
|
||||
const {cells} = pack;
|
||||
const {name, population, cell} = burg;
|
||||
const burgSeed = getBurgSeed(burg);
|
||||
const sizeRaw = 0.43 * Math.pow((population * populationRate) / urbanDensity, 0.385);
|
||||
const size = minmax(Math.ceil(sizeRaw), 2, 40);
|
||||
const size = minmax(Math.ceil(sizeRaw), 2, 40)*3;
|
||||
const people = rn(population * populationRate * urbanization);
|
||||
|
||||
const hub = +cells.road[cell] > 50;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue