refactor: more components

This commit is contained in:
Azgaar 2022-07-03 16:30:34 +03:00
parent e739698346
commit c1b3a3bbbb
4 changed files with 23 additions and 11 deletions

30
src/scripts/statistics.ts Normal file
View file

@ -0,0 +1,30 @@
// @ts-nocheck global variables
import {INFO} from "config/logging";
import {heightmapTemplates} from "config/heightmap-templates";
import {locked} from "scripts/options/lock";
import {getInputValue} from "utils/nodeUtils";
// show map stats on generation complete
export function showStatistics() {
const heightmap = getInputValue("templateInput");
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);
}