49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
// Master of Vega — formation strategy definitions, V2 per-ship combat
|
|
// prototype only.
|
|
//
|
|
// Chosen once per side before a battle starts — a human player through a
|
|
// pre-battle picker (VegaCombatSim.js's openFormationPicker), an AI side
|
|
// silently (VegaCombatV2.createBattle defaults an unset choice to a random
|
|
// one using the battle's own seeded RNG, so it's deterministic and needs no
|
|
// separate AI logic yet). Stamped onto every ship on that side at creation.
|
|
//
|
|
// Headless — no Phaser import — so it stays usable from both the engine
|
|
// (VegaCombatV2.js) and the view/UI layers, and is Node-checkable from the
|
|
// verifier the same way everything else in this game is.
|
|
//
|
|
// Placement, movement, and targeting will read `ship.formationStrategy` in
|
|
// upcoming work. For now this file only defines the choices and resolves
|
|
// one per side — it doesn't yet change how a battle plays out.
|
|
|
|
export const FORMATION_STRATEGIES = [
|
|
{
|
|
id: 'power_pressure',
|
|
name: 'Power Pressure',
|
|
desc: 'Heavy hulls lead from the front and grind the enemy down at close range.',
|
|
},
|
|
{
|
|
id: 'speed_swarm',
|
|
name: 'Speed Swarm',
|
|
desc: 'Fast hulls spread out and harass from every angle at once.',
|
|
},
|
|
];
|
|
|
|
const byId = new Map(FORMATION_STRATEGIES.map((f) => [f.id, f]));
|
|
|
|
export function isFormationStrategy(id) {
|
|
return byId.has(id);
|
|
}
|
|
|
|
export function formationName(id) {
|
|
return byId.get(id)?.name ?? id;
|
|
}
|
|
|
|
/** A silent pick — pass the battle's own seeded rnd so it stays deterministic. */
|
|
export function randomFormationStrategy(rnd = Math.random) {
|
|
const i = Math.min(
|
|
FORMATION_STRATEGIES.length - 1,
|
|
Math.floor(rnd() * FORMATION_STRATEGIES.length),
|
|
);
|
|
return FORMATION_STRATEGIES[i].id;
|
|
}
|