From 54fd34d3d7770ed8be36275cc9295f3a4e01ebc3 Mon Sep 17 00:00:00 2001 From: Marc Emmanuel Date: Sun, 8 Feb 2026 10:00:04 +0100 Subject: [PATCH] chore: lint --- src/modules/ice.ts | 56 ++++++++++++++++++++++++++++---------------- src/modules/index.ts | 2 +- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/modules/ice.ts b/src/modules/ice.ts index b59f9354..88bc8767 100644 --- a/src/modules/ice.ts +++ b/src/modules/ice.ts @@ -1,7 +1,18 @@ import Alea from "alea"; -import { min } from 'd3'; -import { clipPoly, getGridPolygon, getIsolines, lerp, minmax, normalize, P, ra, rand, rn } from "../utils"; -import { Point } from "./voronoi"; +import { min } from "d3"; +import { + clipPoly, + getGridPolygon, + getIsolines, + lerp, + minmax, + normalize, + P, + ra, + rand, + rn, +} from "../utils"; +import type { Point } from "./voronoi"; declare global { var Ice: IceModule; @@ -12,7 +23,7 @@ class IceModule { private getNextId() { if (pack.ice.length === 0) return 0; // find gaps in existing ids - const existingIds = pack.ice.map(e => e.i).sort((a, b) => a - b); + const existingIds = pack.ice.map((e) => e.i).sort((a, b) => a - b); for (let id = 0; id < existingIds[existingIds.length - 1]; id++) { if (!existingIds.includes(id)) return id; } @@ -48,7 +59,7 @@ class IceModule { pack.ice.push({ i: this.getNextId(), points: clipped, - type: "glacier" + type: "glacier", }); }); } @@ -70,7 +81,7 @@ class IceModule { const [cx, cy] = grid.points[cellId]; const points = getGridPolygon(cellId, grid).map(([x, y]: Point) => [ rn(lerp(cx, x, size), 2), - rn(lerp(cy, y, size), 2) + rn(lerp(cy, y, size), 2), ]); pack.ice.push({ @@ -78,7 +89,7 @@ class IceModule { points, type: "iceberg", cellId, - size + size, }); } } @@ -87,7 +98,7 @@ class IceModule { const [cx, cy] = grid.points[cellId]; const points = getGridPolygon(cellId, grid).map(([x, y]: Point) => [ rn(lerp(cx, x, size), 2), - rn(lerp(cy, y, size), 2) + rn(lerp(cy, y, size), 2), ]); const id = this.getNextId(); pack.ice.push({ @@ -95,27 +106,26 @@ class IceModule { points, type: "iceberg", cellId, - size + size, }); redrawIceberg(id); } removeIce(id: number) { - const index = pack.ice.findIndex(element => element.i === id); + const index = pack.ice.findIndex((element) => element.i === id); if (index !== -1) { - const type = pack.ice.find(element => element.i === id).type; + const type = pack.ice.find((element) => element.i === id).type; pack.ice.splice(index, 1); if (type === "glacier") { redrawGlacier(id); } else { redrawIceberg(id); } - } } randomizeIcebergShape(id: number) { - const iceberg = pack.ice.find(element => element.i === id); + const iceberg = pack.ice.find((element) => element.i === id); if (!iceberg) return; const cellId = iceberg.cellId; @@ -125,17 +135,20 @@ class IceModule { // Get a different random cell for the polygon template const i = ra(grid.cells.i); const cn = grid.points[i]; - const poly = getGridPolygon(i, grid).map((p: Point) => [p[0] - cn[0], p[1] - cn[1]]); + const poly = getGridPolygon(i, grid).map((p: Point) => [ + p[0] - cn[0], + p[1] - cn[1], + ]); const points = poly.map((p: Point) => [ rn(cx + p[0] * size, 2), - rn(cy + p[1] * size, 2) + rn(cy + p[1] * size, 2), ]); iceberg.points = points; } changeIcebergSize(id: number, newSize: number) { - const iceberg = pack.ice.find(element => element.i === id); + const iceberg = pack.ice.find((element) => element.i === id); if (!iceberg) return; const cellId = iceberg.cellId; @@ -145,10 +158,13 @@ class IceModule { const flat = iceberg.points.flat(); const pairs = []; while (flat.length) pairs.push(flat.splice(0, 2)); - const poly = pairs.map(p => [(p[0] - cx) / oldSize, (p[1] - cy) / oldSize]); - const points = poly.map(p => [ + const poly = pairs.map((p) => [ + (p[0] - cx) / oldSize, + (p[1] - cy) / oldSize, + ]); + const points = poly.map((p) => [ rn(cx + p[0] * newSize, 2), - rn(cy + p[1] * newSize, 2) + rn(cy + p[1] * newSize, 2), ]); iceberg.points = points; @@ -156,4 +172,4 @@ class IceModule { } } -window.Ice = new IceModule(); \ No newline at end of file +window.Ice = new IceModule(); diff --git a/src/modules/index.ts b/src/modules/index.ts index b617e4d9..045edb18 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -13,4 +13,4 @@ import "./states-generator"; import "./zones-generator"; import "./religions-generator"; import "./provinces-generator"; -import "./ice"; \ No newline at end of file +import "./ice";