feedback5 R3: Battle.js → server/sim/battle/*.js, a pure move — the 131 methods, verbatim with their comments, go to 14 per-concern method containers (players, lifecycle, hooks, spawns, deploy, blocking, status, combat, queries, summons, tiles, displacement, economy, events; fin / clone in util.js) that Battle.js installs on Battle.prototype in a fixed order with class-method descriptors; Battle.js keeps the header, the constructor and the class, and re-exports pushTiles. docs-consistency reads the method modules (battleText) and pins layerGainRoom in battle/economy.js

This commit is contained in:
sganggs committed 2026-10-05 16:13:25 +08:00
1 parent 6b489b1776
commit 13224f9483
17 files changed
+2488 -2328

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
// server/sim/battle/util.js — small helpers shared by the Battle method modules (server/sim/battle/*.js).
/** Finite number or the default (content may pass undefined/NaN/Infinity/strings to helpers). */
export const fin = (v, d) => { const n = typeof v === 'number' ? v : (v == null || v === '' ? NaN : Number(v)); return Number.isFinite(n) ? n : d; };
export function clone(v) {
if (v == null || typeof v !== 'object') return v;
if (Array.isArray(v)) return v.map(clone);
const o = {};
for (const k of Object.keys(v)) o[k] = clone(v[k]);
return o;
}