chore: modularize main.js

This commit is contained in:
Azgaar 2022-07-03 15:45:51 +03:00
parent 51df2f90b0
commit e739698346
24 changed files with 1775 additions and 1706 deletions

29
src/scripts/statistics Normal file
View file

@ -0,0 +1,29 @@
import {INFO} from "config/logging";
import {byId} from "utils/shorthands";
import {heightmapTemplates} from "config/heightmap-templates";
import {locked} from "scripts/options/lock";
// show map stats on generation complete
export function showStatistics() {
const heightmap = byId("templateInput").value;
const isTemplate = heightmap in heightmapTemplates;
const heightmapType = isTemplate ? "template" : "precreated";
const isRandomTemplate = isTemplate && !locked("template") ? "random " : "";
const stats = ` Seed: ${seed}
Canvas size: ${graphWidth}x${graphHeight} px
Heightmap: ${heightmap} (${isRandomTemplate}${heightmapType})
Points: ${grid.points.length}
Cells: ${pack.cells.i.length}
Map size: ${mapSizeOutput.value}%
States: ${pack.states.length - 1}
Provinces: ${pack.provinces.length - 1}
Burgs: ${pack.burgs.length - 1}
Religions: ${pack.religions.length - 1}
Culture set: ${culturesSet.selectedOptions[0].innerText}
Cultures: ${pack.cultures.length - 1}`;
mapId = Date.now(); // unique map id is it's creation date number
mapHistory.push({seed, width: graphWidth, height: graphHeight, template: heightmap, created: mapId});
INFO && console.log(stats);
}