public/js/ui/gameLogic.js becomes a re-export barrel. The bodies move verbatim into public/js/ui/gameLogic/*.js (shared, phases, camera, watch, bonds, shop, placement, draft, enemies, format, shortcuts, settings, result, loadout, panel). The barrel re-exports the same 96 names in the same order. isObj and int gain export on shared.js so sibling modules can import them; they stay off the barrel. No importer changes.
17 lines
728 B
JavaScript
17 lines
728 B
JavaScript
// ui/gameLogic/shared.js — small helpers and seat order. Public names are re-exported from ../gameLogic.js.
|
|
|
|
// ---- small helpers -------------------------------------------------------------------------------
|
|
|
|
export const isObj = (v) => !!v && typeof v === 'object';
|
|
export const int = (v, d = 0) => (Number.isInteger(v) ? v : d);
|
|
export const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
|
|
/** Stable key of a board tile. */
|
|
export const tileKey = (row, col) => `${row},${col}`;
|
|
|
|
/** Players sorted by seat (nulls dropped). */
|
|
export function sortedPlayers(pub) {
|
|
const list = Array.isArray(pub?.players) ? pub.players.filter(isObj) : [];
|
|
return [...list].sort((a, b) => int(a.seat, 99) - int(b.seat, 99));
|
|
}
|