fix: improve comments for clarity and update type imports for consistency

This commit is contained in:
Azgaar 2026-03-11 01:17:36 +01:00
parent 3c7b6fffef
commit fae0bd1085
6 changed files with 37 additions and 23 deletions

View file

@ -453,7 +453,7 @@ class EmblemGeneratorModule {
// Size selection - must use sequential P() calls to match original behavior // Size selection - must use sequential P() calls to match original behavior
if (P(0.1)) size = "-small"; if (P(0.1)) size = "-small";
// biome-ignore lint/suspicious/noDuplicateElseIf: <explanation> // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition
else if (P(0.1)) size = "-smaller"; else if (P(0.1)) size = "-smaller";
else if (P(0.01)) size = "-big"; else if (P(0.01)) size = "-big";
else if (P(0.005)) size = "-smallest"; else if (P(0.005)) size = "-smallest";
@ -469,11 +469,11 @@ class EmblemGeneratorModule {
if (P(0.2)) { if (P(0.2)) {
t1 = "gules"; t1 = "gules";
t2 = "or"; t2 = "or";
// biome-ignore lint/suspicious/noDuplicateElseIf: <explanation> // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition
} else if (P(0.2)) { } else if (P(0.2)) {
t1 = "argent"; t1 = "argent";
t2 = "sable"; t2 = "sable";
// biome-ignore lint/suspicious/noDuplicateElseIf: <explanation> // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition
} else if (P(0.2)) { } else if (P(0.2)) {
t1 = "azure"; t1 = "azure";
t2 = "argent"; t2 = "argent";
@ -482,7 +482,7 @@ class EmblemGeneratorModule {
if (P(0.3)) { if (P(0.3)) {
t1 = "gules"; t1 = "gules";
t2 = "argent"; t2 = "argent";
// biome-ignore lint/suspicious/noDuplicateElseIf: <explanation> // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition
} else if (P(0.3)) { } else if (P(0.3)) {
t1 = "argent"; t1 = "argent";
t2 = "sable"; t2 = "sable";

View file

@ -430,7 +430,7 @@ class MilitaryModule {
nodes.forEach((node) => { nodes.forEach((node) => {
tree.remove(node); tree.remove(node);
const overlap = tree.find(node.x, node.y, 20); const overlap = tree.find(node.x, node.y, 20);
if (overlap && overlap.t && mergeable(node, overlap)) { if (overlap?.t && mergeable(node, overlap)) {
merge(node, overlap); merge(node, overlap);
return; return;
} }

View file

@ -318,7 +318,7 @@ class ProvinceModule {
if (singleIsle) return "Island"; if (singleIsle) return "Island";
if (isleGroup) return "Islands"; if (isleGroup) return "Islands";
if (colony) return "Colony"; if (colony) return "Colony";
return rw(this.forms["Wild"]); return rw(this.forms.Wild);
})(); })();
const fullName = `${name} ${formName}`; const fullName = `${name} ${formName}`;

View file

@ -1,6 +1,12 @@
import type { CurveFactory } from "d3"; import type { CurveFactory } from "d3";
import * as d3 from "d3"; import {
import { color, line, range } from "d3"; color,
curveBasisClosed,
curveLinear,
curveStep,
line,
range,
} from "d3";
import { round } from "../utils"; import { round } from "../utils";
declare global { declare global {
@ -28,10 +34,13 @@ const heightmapRenderer = (): void => {
if (renderOceanCells) { if (renderOceanCells) {
const skip = +ocean.attr("skip") + 1 || 1; const skip = +ocean.attr("skip") + 1 || 1;
const relax = +ocean.attr("relax") || 0; const relax = +ocean.attr("relax") || 0;
// TODO: Improve for treeshaking const curveFactories: Record<string, CurveFactory> = {
const curveType: keyof typeof d3 = (ocean.attr("curve") || curveBasisClosed,
"curveBasisClosed") as keyof typeof d3; curveLinear,
const lineGen = line().curve(d3[curveType] as CurveFactory); curveStep,
};
const curveType = ocean.attr("curve") || "curveBasisClosed";
const lineGen = line().curve(curveFactories[curveType] ?? curveBasisClosed);
let currentLayer = 0; let currentLayer = 0;
for (const i of heights) { for (const i of heights) {
@ -59,9 +68,13 @@ const heightmapRenderer = (): void => {
{ {
const skip = +land.attr("skip") + 1 || 1; const skip = +land.attr("skip") + 1 || 1;
const relax = +land.attr("relax") || 0; const relax = +land.attr("relax") || 0;
const curveType: keyof typeof d3 = (land.attr("curve") || const curveFactories: Record<string, CurveFactory> = {
"curveBasisClosed") as keyof typeof d3; curveBasisClosed,
const lineGen = line().curve(d3[curveType] as CurveFactory); curveLinear,
curveStep,
};
const curveType = land.attr("curve") || "curveBasisClosed";
const lineGen = line().curve(curveFactories[curveType] ?? curveBasisClosed);
let currentLayer = 20; let currentLayer = 20;
for (const i of heights) { for (const i of heights) {

View file

@ -53,6 +53,7 @@ const pinShapes: PinShapes = {
no: () => "", no: () => "",
}; };
// biome-ignore lint/suspicious/noRedeclare: const implementation satisfies the global var declaration above
const getPin = (shape = "bubble", fill = "#fff", stroke = "#000"): string => { const getPin = (shape = "bubble", fill = "#fff", stroke = "#000"): string => {
const shapeFunction = pinShapes[shape] || pinShapes.bubble; const shapeFunction = pinShapes[shape] || pinShapes.bubble;
return shapeFunction(fill, stroke); return shapeFunction(fill, stroke);

View file

@ -1,6 +1,6 @@
import type {Selection} from "d3"; import type { Selection } from "d3";
import type {NameBase} from "../modules/names-generator"; import type { NameBase } from "../modules/names-generator";
import type {PackedGraph} from "./PackedGraph"; import type { PackedGraph } from "./PackedGraph";
declare global { declare global {
var seed: string; var seed: string;
@ -11,7 +11,7 @@ declare global {
var TIME: boolean; var TIME: boolean;
var WARN: boolean; var WARN: boolean;
var ERROR: boolean; var ERROR: boolean;
var DEBUG: {stateLabels?: boolean; [key: string]: boolean | undefined}; var DEBUG: { stateLabels?: boolean; [key: string]: boolean | undefined };
var options: any; var options: any;
var heightmapTemplates: any; var heightmapTemplates: any;
@ -66,9 +66,9 @@ declare global {
}; };
var notes: any[]; var notes: any[];
var style: { var style: {
burgLabels: {[key: string]: {[key: string]: string}}; burgLabels: { [key: string]: { [key: string]: string } };
burgIcons: {[key: string]: {[key: string]: string}}; burgIcons: { [key: string]: { [key: string]: string } };
anchors: {[key: string]: {[key: string]: string}}; anchors: { [key: string]: { [key: string]: string } };
[key: string]: any; [key: string]: any;
}; };
@ -81,7 +81,7 @@ declare global {
message: string, message: string,
autoHide?: boolean, autoHide?: boolean,
type?: "info" | "warn" | "error" | "success", type?: "info" | "warn" | "error" | "success",
timeout?: number timeout?: number,
) => void; ) => void;
var locked: (settingId: string) => boolean; var locked: (settingId: string) => boolean;
var unlock: (settingId: string) => void; var unlock: (settingId: string) => void;