From 195a4676adb124d9b18e043cc358db160368d107 Mon Sep 17 00:00:00 2001 From: kruschen Date: Mon, 26 Aug 2024 19:23:30 +0000 Subject: [PATCH] Burg Type now filtered properly in generations.ts --- src/scripts/generation/generation.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scripts/generation/generation.ts b/src/scripts/generation/generation.ts index 25b0f581..fa9978e6 100644 --- a/src/scripts/generation/generation.ts +++ b/src/scripts/generation/generation.ts @@ -26,6 +26,7 @@ import {createGrid} from "./grid/grid"; import {createPack} from "./pack/pack"; import {getInputValue, setInputValue} from "utils/nodeUtils"; import {calculateMapCoordinates} from "modules/coordinates"; +import { isBurg } from "utils/typeUtils"; const {Zoom, ThreeD} = window; @@ -195,6 +196,7 @@ function focusOn() { if (burgParam) { const burg = isNaN(+burgParam) ? pack.burgs.find(burg => burg.name === burgParam) : pack.burgs[+burgParam]; if (!burg) return; + if (!isBurg(burg)) return; const {x, y} = burg; Zoom.to(x, y, scale, 1600); @@ -209,8 +211,8 @@ function focusOn() { // find burg for MFCG and focus on it function findBurgForMFCG(params: URLSearchParams) { - const {cells, burgs} = pack; - + const {cells, burgs: burgsT} = pack; + const burgs = burgsT.filter(isBurg); if (pack.burgs.length < 2) { ERROR && console.error("Cannot select a burg for MFCG"); return; @@ -247,13 +249,13 @@ function findBurgForMFCG(params: URLSearchParams) { if (param === "name") b.name = value; else if (param === "size") b.population = +value; else if (param === "seed") b.MFCG = +value; - else if (param === "shantytown") b.shanty = +value; + else if (param === "shantytown") b.shanty = +value > 0 ? 1 : 0; } const nameParam = params.get("name"); if (nameParam && nameParam !== "null") b.name = nameParam; - const label = burgLabels.select("[data-id='" + burgId + "']"); + const label = burgLabels.select("[data-id='" + burgId + "']"); if (label.size()) { label .text(b.name)