mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 10:31:24 +01:00
reinstate economics logic
This commit is contained in:
parent
cea9b1a48a
commit
cb486fa0e8
17 changed files with 2179 additions and 42 deletions
|
|
@ -331,6 +331,7 @@ async function parseLoadedData(data, mapVersion) {
|
|||
coastline = viewbox.select("#coastline");
|
||||
prec = viewbox.select("#prec");
|
||||
population = viewbox.select("#population");
|
||||
resources = viewbox.select("#goods")
|
||||
emblems = viewbox.select("#emblems");
|
||||
labels = viewbox.select("#labels");
|
||||
icons = viewbox.select("#icons");
|
||||
|
|
@ -393,6 +394,7 @@ async function parseLoadedData(data, mapVersion) {
|
|||
pack.cells.province = data[27] ? Uint16Array.from(data[27].split(",")) : new Uint16Array(pack.cells.i.length);
|
||||
// data[28] had deprecated cells.crossroad
|
||||
pack.cells.routes = data[36] ? JSON.parse(data[36]) : {};
|
||||
pack.resources = data[40] ? JSON.parse(data[40]) : {};
|
||||
|
||||
if (data[31]) {
|
||||
const namesDL = data[31].split("/");
|
||||
|
|
@ -541,6 +543,14 @@ async function parseLoadedData(data, mapVersion) {
|
|||
ERROR && console.error("Data integrity check. Invalid river", r, "is assigned to cells", invalidCells);
|
||||
});
|
||||
|
||||
const invalidResources = [...new Set(cells.r)].filter(r => r && !pack.resources.find(resource => resource.i === r));
|
||||
invalidResources.forEach(r=> {
|
||||
const invalidCells = cells.i.filter(i => cells.r[i] === r);
|
||||
invalidCells.forEach(i => (cells.r[i] = 0));
|
||||
rivers.select("resource" + r).remove();
|
||||
ERROR && console.error("Data integrity check. Invalid resource", r, "is assigned to cells", invalidCells);
|
||||
})
|
||||
|
||||
pack.burgs.forEach(burg => {
|
||||
if (typeof burg.capital === "boolean") burg.capital = Number(burg.capital);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ function prepareMapData() {
|
|||
const religions = JSON.stringify(pack.religions);
|
||||
const provinces = JSON.stringify(pack.provinces);
|
||||
const rivers = JSON.stringify(pack.rivers);
|
||||
const resource = JSON.stringify(pack.resources);
|
||||
const markers = JSON.stringify(pack.markers);
|
||||
const cellRoutes = JSON.stringify(pack.cells.routes);
|
||||
const routes = JSON.stringify(pack.routes);
|
||||
|
|
@ -116,45 +117,47 @@ function prepareMapData() {
|
|||
|
||||
// data format as below
|
||||
const mapData = [
|
||||
params,
|
||||
settings,
|
||||
coords,
|
||||
biomes,
|
||||
notesData,
|
||||
serializedSVG,
|
||||
gridGeneral,
|
||||
grid.cells.h,
|
||||
grid.cells.prec,
|
||||
grid.cells.f,
|
||||
grid.cells.t,
|
||||
grid.cells.temp,
|
||||
packFeatures,
|
||||
cultures,
|
||||
states,
|
||||
burgs,
|
||||
pack.cells.biome,
|
||||
pack.cells.burg,
|
||||
pack.cells.conf,
|
||||
pack.cells.culture,
|
||||
pack.cells.fl,
|
||||
pop,
|
||||
pack.cells.r,
|
||||
[], // deprecated pack.cells.road
|
||||
pack.cells.s,
|
||||
pack.cells.state,
|
||||
pack.cells.religion,
|
||||
pack.cells.province,
|
||||
[], // deprecated pack.cells.crossroad
|
||||
religions,
|
||||
provinces,
|
||||
namesData,
|
||||
rivers,
|
||||
rulersString,
|
||||
fonts,
|
||||
markers,
|
||||
cellRoutes,
|
||||
routes,
|
||||
zones
|
||||
params, //1
|
||||
settings, //2
|
||||
coords, //3
|
||||
biomes, //4
|
||||
notesData, //5
|
||||
serializedSVG, //6
|
||||
gridGeneral, //7
|
||||
grid.cells.h, //8
|
||||
grid.cells.prec, //9
|
||||
grid.cells.f, //10
|
||||
grid.cells.t, //11
|
||||
grid.cells.temp, //12
|
||||
packFeatures, //13
|
||||
cultures, //14
|
||||
states, //15
|
||||
burgs, //16
|
||||
pack.cells.biome, //17
|
||||
pack.cells.burg, //18
|
||||
pack.cells.conf, //19
|
||||
pack.cells.culture, //20
|
||||
pack.cells.fl, //21
|
||||
pop, //22
|
||||
pack.cells.r, //23
|
||||
[], // deprecated pack.cells.road 24
|
||||
pack.cells.s, // 25
|
||||
pack.cells.state, //26
|
||||
pack.cells.religion, //27
|
||||
pack.cells.province, //28
|
||||
[], // deprecated pack.cells.crossroad 29
|
||||
religions, //30
|
||||
provinces, //31
|
||||
namesData, //32
|
||||
rivers, //33
|
||||
rulersString, //34
|
||||
fonts, //35
|
||||
markers, //36
|
||||
cellRoutes, //37
|
||||
routes, //38
|
||||
zones, //39
|
||||
pack.cells.resources, //40
|
||||
resources //41
|
||||
].join("\r\n");
|
||||
return mapData;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue