Each player summary opens enlarged original counter diagrams and public physical pools. The inventory separates reserves, Tanks, board locations and foreign Homeworld deployments. Native Homeworlds break down existing reserves; elites and advisor stances remain subsets. The reference gallery covers all twelve factions, including Suboids/Cyborgs, Sardaukar, Fedaykin and BG advisor faces. Actual force keys retain unplaced Mobile Stronghold and Discovery groups. Basic Homeworld special identity comes from public typed pools, not mode alone. Concealed No-Fields expose only a separate marker/location; no value or future materialization is inferred. Temporary battle strength creates no physical counter. Invalid projections show a refresh notice instead of invented totals. Inspection updates from current props and submits no action or saved mutation. Independent review found no material issue and clarified No-Field wording: revelation draws from reserves available then, without earmarking counters. Eleven new focused cases cover faction identity, typed pools, advisors, genuine Basic Homeworld public views, native/foreign splits, genuine Ix setup before HMS placement, a controlled Discovery position, JSON continuation, input immutability, concealed0/3/5 equivalence, named controls and malformed projection feedback. A test-only Homeworld projection initially omitted its card identity; corrected before final checks. Lint's semantic status element was corrected to output. Types, lint, all 4984 offline tests and production build passed on stable source. No HTTP/auth/schema/persistence behavior changed, so no additional HTTP suite was required. Browser QA reused an isolated existing three-human Basic Nexus without game actions. All three public inspectors showed correct pools; Escape restored trigger focus, Enter opened inspection and PageDown scrolled the labelled region. At390px the dialog359px fit, body text16px and Close44px high. All twelve gallery choices rendered named160px diagrams without gallery overflow. Internal guide, Back and refresh worked; viewport reset and preview retained. Screenshot capture timed out. Full visual/screen-reader/200% zoom, manufactured component fidelity and all-configuration browser acceptance remain open. All 1499 original rooms, 3171 seats and auxiliary rows are unchanged; SQLite integrity and foreign keys pass. The healthy server was reused without restart, migration, reset or automation. AI strategy/calibration remains deferred until non-AI features are complete; no mode/publication gate was opened. Private evidence: 20260921-force-inspection. Verified source tree: 5d7ffd471229faa13224fd5a87d33c3ac5af866446241a7881926a54c1ee49eb
95 lines
4.0 KiB
TypeScript
95 lines
4.0 KiB
TypeScript
import { splitLocation, territory } from './board';
|
|
import type { FactionId } from './catalog';
|
|
import { specialForceName } from './combat';
|
|
import { isAdvisor } from './advisors';
|
|
import { HOMEWORLD_CARDS } from './homeworld-cards';
|
|
|
|
/** Public physical custody only. No private cards, commitments or token faces. */
|
|
export type PublicForcePlayer = {
|
|
id: string;
|
|
name: string;
|
|
faction: FactionId;
|
|
reserves: number;
|
|
tanks: number;
|
|
forces: Readonly<Record<string, number>>;
|
|
elites?: { reserves: number; tanks: number; forces: Readonly<Record<string, number>> };
|
|
advisors?: Record<string, { lockedTurn?: number }>;
|
|
noField?: { deployed: { location: { territory: string; sector: number } } | null } | null;
|
|
};
|
|
export type PublicForceWorld = {
|
|
id: string;
|
|
native: string;
|
|
card: string;
|
|
forces: Readonly<Record<string, { normal: number; elite: number }>>;
|
|
};
|
|
export type ForcePool = {
|
|
id: string;
|
|
name: string;
|
|
total: number;
|
|
normal: number;
|
|
elite: number;
|
|
advisors: boolean;
|
|
};
|
|
|
|
export function forceCounterName(faction: FactionId, kind: 'force' | 'special' | 'advisor') {
|
|
if (kind === 'advisor') return 'Advisor';
|
|
if (kind === 'special') return specialForceName(faction);
|
|
return faction === 'ixians' ? 'Suboid' : faction === 'beneGesserit' ? 'Fighter' : 'Force';
|
|
}
|
|
|
|
function locationName(id: string, sector: number) {
|
|
if (!Number.isSafeInteger(sector) || sector < 0) throw new Error('Invalid force location.');
|
|
const name = territory(id).name;
|
|
return sector > 0 ? `${name} · sector ${sector}` : name;
|
|
}
|
|
|
|
function pool(id: string, name: string, total: number, elite = 0, advisors = false): ForcePool {
|
|
if (![total, elite].every(n => Number.isSafeInteger(n) && n >= 0) || elite > total)
|
|
throw new Error('Invalid public force count.');
|
|
return { id, name, total, normal: total - elite, elite, advisors };
|
|
}
|
|
|
|
/** Native Homeworlds subdivide reserves; only foreign deployments add a pool.
|
|
* Concealed No-Fields are markers, never physical counters or inferred values.
|
|
* A malformed projection produces no fabricated totals and cannot crash a table. */
|
|
export function forceInventory(player: PublicForcePlayer, worlds: readonly PublicForceWorld[] | null = null) {
|
|
try {
|
|
const reserves = pool('reserves', 'Reserves', player.reserves, player.elites?.reserves);
|
|
const tanks = pool('tanks', 'Tleilaxu Tanks', player.tanks, player.elites?.tanks);
|
|
const rows = [reserves, tanks];
|
|
for (const key of [...new Set([...Object.keys(player.forces), ...Object.keys(player.elites?.forces ?? {})])].sort()) {
|
|
const { territory: id, sector } = splitLocation(key);
|
|
const row = pool(key, locationName(id, sector), player.forces[key] ?? 0,
|
|
player.elites?.forces[key], isAdvisor(player, id));
|
|
if (row.total > 0) rows.push(row);
|
|
}
|
|
const nativeReserves: ForcePool[] = [];
|
|
for (const world of worlds ?? []) {
|
|
const force = world.forces[player.id];
|
|
if (!force) continue;
|
|
const card = HOMEWORLD_CARDS.find(c => c.id === world.card);
|
|
if (!card) throw new Error('Unknown Homeworld.');
|
|
const row = pool(world.id, card.name, force.normal + force.elite, force.elite);
|
|
if (world.native === player.id) nativeReserves.push(row);
|
|
else if (row.total > 0) rows.push(row);
|
|
}
|
|
if (nativeReserves.length && (nativeReserves.reduce((n, r) => n + r.total, 0) !== reserves.total ||
|
|
nativeReserves.reduce((n, r) => n + r.elite, 0) !== reserves.elite))
|
|
throw new Error('Native reserves disagree with their Homeworld breakdown.');
|
|
const marker = player.noField?.deployed?.location;
|
|
const total = rows.reduce((n, r) => n + r.total, 0);
|
|
if (!Number.isSafeInteger(total)) throw new Error('Invalid force inventory.');
|
|
return {
|
|
rows, nativeReserves,
|
|
total,
|
|
normal: rows.reduce((n, r) => n + r.normal, 0),
|
|
elite: rows.reduce((n, r) => n + r.elite, 0),
|
|
advisors: rows.reduce((n, r) => n + (r.advisors ? r.total : 0), 0),
|
|
split: !!player.elites,
|
|
marker: marker ? { name: locationName(marker.territory, marker.sector) } : null,
|
|
};
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|