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
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.01)) size = "-big";
else if (P(0.005)) size = "-smallest";
@ -469,11 +469,11 @@ class EmblemGeneratorModule {
if (P(0.2)) {
t1 = "gules";
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)) {
t1 = "argent";
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)) {
t1 = "azure";
t2 = "argent";
@ -482,7 +482,7 @@ class EmblemGeneratorModule {
if (P(0.3)) {
t1 = "gules";
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)) {
t1 = "argent";
t2 = "sable";

View file

@ -430,7 +430,7 @@ class MilitaryModule {
nodes.forEach((node) => {
tree.remove(node);
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);
return;
}

View file

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

View file

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

View file

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

View file

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