Enable native Fremen Cunning with original Nexus components
This commit is contained in:
1 parent
7571ffb2ef
commit
bcabaaf596
8 files changed
+176
-4
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { applyAction, type Game } from '../game/engine';
|
||||
import { presenceAt } from '../game/force-presence';
|
||||
import {
|
||||
initializeNexusModulePaymentsSetup, nextNexusModulePaymentsNativeStep,
|
||||
} from './fixture-nexus-module-payments';
|
||||
import { nexusReady, orderNexusSpice } from './fixture-nexus-cards';
|
||||
|
||||
/** Original setup, first-Storm Tech and first-Mentat Stronghold ownership precede
|
||||
* the turn-two appearance. Only the physical card/deck order and two reserve
|
||||
* counters are staged; no phase, wallet, owner or earned receipt is manufactured. */
|
||||
export function nexusFremenComponentsAppearance(options: {
|
||||
advanced: boolean; tech: boolean; strongholds: boolean;
|
||||
}) {
|
||||
let game = initializeNexusModulePaymentsSetup({
|
||||
...options, ownerFaction: 'fremen',
|
||||
});
|
||||
for (let n = 0; n < 1600; n++) {
|
||||
if (game.status === 'playing' && game.turn === 2 && game.phase === 1 &&
|
||||
!game.phaseOpening && !game.response && !game.decision) break;
|
||||
assert.ok(game.turn <= 2, 'Stop at the original second-turn Spice Blow.');
|
||||
const step = nextNexusModulePaymentsNativeStep(game);
|
||||
assert.ok(step, `Original continuation stopped at ${game.turn}/${game.phase}/${game.decision?.kind}`);
|
||||
game = applyAction(game, step.actor, step.action);
|
||||
}
|
||||
assert.equal(game.turn, 2); assert.equal(game.phase, 1);
|
||||
assert.ok(!game.phaseOpening && !game.decision && !game.response);
|
||||
const fremen = game.players.find(player => player.faction === 'fremen')!;
|
||||
assert.ok(fremen.reserves - (fremen.elites?.reserves ?? 0) >= 2);
|
||||
const sourceSector = game.storm === 14 ? 15 : 14;
|
||||
const source = `wind_pass:${sourceSector}`;
|
||||
fremen.reserves -= 2;
|
||||
fremen.forces[source] = (fremen.forces[source] ?? 0) + 2;
|
||||
const cards = game.nexusCards!.cards!;
|
||||
const cardIndex = cards.deck.indexOf('fremen');
|
||||
assert.ok(cardIndex >= 0);
|
||||
cards.deck.splice(cardIndex, 1);
|
||||
cards.hands[fremen.id] = 'fremen';
|
||||
orderNexusSpice(game, ['worm', 'land']);
|
||||
const empty = game.spiceDeck.find(card => 'territory' in card &&
|
||||
game.players.every(player => presenceAt(player, card.territory) === 0));
|
||||
assert.ok(empty && 'territory' in empty);
|
||||
game.spiceDeck.splice(game.spiceDeck.indexOf(empty), 1);
|
||||
game.spiceDiscard[0].push(empty);
|
||||
const before = structuredClone(game);
|
||||
game = nexusReady(game);
|
||||
return { game, before, actor: fremen.id, source, sourceSector };
|
||||
}
|
||||
|
||||
export function completeNexusFremenComponentsRide(state: Game): Game {
|
||||
let game = state;
|
||||
for (let n = 0; n < 100 && game.decision?.kind !== 'nexusFremenCunningRide'; n++) {
|
||||
const step = nextNexusModulePaymentsNativeStep(game);
|
||||
assert.ok(step, 'The original post-Nexus ride needs a legal continuation.');
|
||||
game = applyAction(game, step.actor, step.action);
|
||||
}
|
||||
assert.equal(game.decision?.kind, 'nexusFremenCunningRide');
|
||||
return game;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { captureFremenCunningOccurrence, fremenCunningDestinationBlock,
|
||||
import { applyAction, normalizeAutomaticGame, viewGame, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { nexusFixture, nexusTurnTwo, nexusReady, nexusAllow, nexusInventory, nexusReload, orderNexusSpice } from './fixture-nexus-cards';
|
||||
import { nexusFremenComponentsAppearance, completeNexusFremenComponentsRide } from './fixture-nexus-fremen-components';
|
||||
|
||||
function fixture() {
|
||||
const g = nexusFixture({ advanced: true });
|
||||
@@ -274,3 +275,40 @@ void test('an accepted Advanced additional-worm placement offers the distinct em
|
||||
assert.equal(g.nexusCards!.cards!.hands.f, null);
|
||||
nexusInventory(g);
|
||||
});
|
||||
|
||||
void test('original Tech and Strongholds preserve the private empty-worm opportunity and one remote ride', () => {
|
||||
const fixture = nexusFremenComponentsAppearance({ advanced: true, tech: true, strongholds: true });
|
||||
const { actor, source } = fixture;
|
||||
let g = fixture.game;
|
||||
assert.equal(g.decision?.kind, 'nexusFremenCunningOffer');
|
||||
const event = g.nexusFremenCunningOffer!.occurrence.event;
|
||||
const components = { tech: structuredClone(g.techTokens), strongholds: structuredClone(g.strongholdCards) };
|
||||
const fremen = g.players.find(player => player.id === actor)!;
|
||||
const sourceBefore = fremen.forces[source];
|
||||
const reserves = fremen.reserves, spice = fremen.spice;
|
||||
const observer = g.players.find(player => player.id !== actor)!.id;
|
||||
const absent = nexusReload(g);
|
||||
absent.nexusCards!.cards!.hands[actor] = null;
|
||||
absent.nexusCards!.cards!.deck.push('fremen');
|
||||
assert.deepEqual(viewGame(absent, observer).decision, viewGame(g, observer).decision);
|
||||
assert.throws(() => applyAction(absent, actor, { type: 'decision', event, accept: true }));
|
||||
const declined = applyAction(absent, actor, { type: 'decision', event, accept: false });
|
||||
assert.equal(declined.nexusFremenCunningOffer, null);
|
||||
g = applyAction(g, actor, { type: 'decision', event, accept: true });
|
||||
g = completeNexusFremenComponentsRide(g);
|
||||
g = applyAction(g, actor, { type: 'decision', event, accept: true,
|
||||
source: 'wind_pass', forces: { [source]: { normal: 2, elite: 0 } },
|
||||
territory: 'polar_sink', sector: 0 });
|
||||
const moved = g.players.find(player => player.id === actor)!;
|
||||
assert.equal(moved.forces[source] ?? 0, sourceBefore - 2);
|
||||
assert.equal(moved.forces['polar_sink:0'], 2);
|
||||
assert.equal(moved.reserves, reserves);
|
||||
assert.equal(moved.spice, spice);
|
||||
assert.equal(g.nexusFremenCunningRides?.[0].stage, 'complete');
|
||||
assert.equal(g.nexusCards!.cards!.discard.filter(card => card === 'fremen').length, 1);
|
||||
assert.deepEqual(g.techTokens, components.tech);
|
||||
assert.deepEqual(g.strongholdCards, components.strongholds);
|
||||
assert.throws(() => applyAction(g, actor, { type: 'decision', event, accept: true,
|
||||
source: 'wind_pass', forces: { [source]: { normal: 2, elite: 0 } },
|
||||
territory: 'polar_sink', sector: 0 }));
|
||||
});
|
||||
Reference in new issue
Block a user