Connect Basic Revival gift and arrival continuations
Verify and publish checkpoint container / container (push) Successful in 11m37s
Verify and publish checkpoint container / container (push) Successful in 11m37s
This commit is contained in:
1 parent
6acf2c200c
commit
2cea251afd
10 files changed
+520
-6
No files matched your search
@@ -0,0 +1,133 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyAction, createGame, joinGame, newPlayer, normalizeAutomaticGame, viewGame, type Action, type Game } from '../game/engine';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { takeKullCard } from './fixture-choam-kull';
|
||||
import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards';
|
||||
import { advanceSemutaNexusTrade as advance } from './fixture-semuta-nexus-trade';
|
||||
|
||||
const act = (g: Game, actor: string, action: Action) => applyAction(g, actor, action);
|
||||
function seat(g: Game, id: string) { const player = g.players.find(p => p.id === id); assert.ok(player); return player; }
|
||||
const clean = (g: Game) => !g.response && !g.phaseOpening && !g.decision && !g.truthtrance && !g.pendingTreacheryDiscard;
|
||||
function inventory(g: Game) {
|
||||
const cards = [...g.deck, ...g.discard, ...(g.richeseCache ?? []), ...(g.richeseRemoved ?? []),
|
||||
...(g.auction?.cards.slice(g.auction.index) ?? []), ...(g.ixAuction?.cards ?? []),
|
||||
...g.players.flatMap(p => p.hand)].map(card => card.id).sort();
|
||||
assert.equal(new Set(cards).size, cards.length); return cards;
|
||||
}
|
||||
|
||||
/** Genuine Basic public setup and a real Nexus alliance. Only unopened Spice
|
||||
* order and conserved held Treachery Card locations are staged. */
|
||||
function fixture() {
|
||||
let g = createGame('KULLRICHESEGIFT', newPlayer('r', 'Richese', 'richese'), false, ['choam', 'ix']);
|
||||
for (const faction of ['choam', 'atreides', 'emperor'] as const) joinGame(g, newPlayer(faction, faction, faction));
|
||||
for (const p of g.players) g = act(g, p.id, { type: 'ready' });
|
||||
g = act(g, 'r', { type: 'start' });
|
||||
assert.equal(g.kullPreview, true); assert.equal(g.semutaPreview, true);
|
||||
g = advance(g, state => state.status === 'playing');
|
||||
const originalCards = inventory(g);
|
||||
// Prevent an incidental stronghold victory during the actual turn-one path.
|
||||
for (const player of g.players) {
|
||||
player.reserves += Object.values(player.forces).reduce((sum, n) => sum + n, 0);
|
||||
player.forces = {};
|
||||
}
|
||||
// Keep the two selected Richese cards in their original cache until staging.
|
||||
for (const id of [SEMUTA_DRUG_ID, 'richese-distrans']) {
|
||||
const index = g.richeseCache!.findIndex(card => card.id === id); assert.ok(index >= 0);
|
||||
g.richeseCache!.push(g.richeseCache!.splice(index, 1)[0]);
|
||||
}
|
||||
g = advance(g, beforeIxSpiceDraw); orderIxSpiceCards(g, ['land', 'land']);
|
||||
g = advance(g, state => state.turn === 2 && beforeIxSpiceDraw(state));
|
||||
orderIxSpiceCards(g, ['worm', 'land', 'land']);
|
||||
g = advance(g, state => !!state.nexus && !state.spiceWindow && clean(state));
|
||||
g = act(g, 'r', { type: 'alliance', target: 'emperor' });
|
||||
g = act(g, 'emperor', { type: 'alliance', target: 'r' });
|
||||
g = advance(g, state => state.turn === 2 && state.phase === 2 && clean(state));
|
||||
for (const p of g.players) g.deck.push(...p.hand.splice(0));
|
||||
seat(g, 'choam').hand.push(takeKullCard(g, 'ix-kull-wahad'));
|
||||
const karama = takeKullCard(g, 'karama'); seat(g, 'atreides').hand.push(karama);
|
||||
const counter = takeKullCard(g, 'karama'); seat(g, 'emperor').hand.push(counter);
|
||||
const semuta = takeKullCard(g, SEMUTA_DRUG_ID); seat(g, 'r').hand.push(semuta);
|
||||
const gift = takeKullCard(g, 'richese-distrans'); seat(g, 'r').hand.push(gift);
|
||||
assert.deepEqual(inventory(g), originalCards);
|
||||
const beforeGift = structuredClone(g);
|
||||
g = act(g, 'r', { type: 'richeseGift', card: gift.id });
|
||||
assert.equal(g.response?.kind, 'richeseGift');
|
||||
g = act(g, 'atreides', { type: 'card', mode: 'cancel', card: karama.id });
|
||||
assert.ok(g.pendingKull, 'The original cancellation must open the neutral Kull opportunity');
|
||||
return { g, gift: gift.id, karama: karama.id, counter: counter.id,
|
||||
kull: 'ix-kull-wahad', semuta: semuta.id, beforeGift, originalCards };
|
||||
}
|
||||
|
||||
function resolveSemuta(g: Game, claim: boolean) {
|
||||
const pending = g.pendingTreacheryDiscard; assert.ok(pending?.reaction?.stage === 'offer');
|
||||
const event = pending.batch.event;
|
||||
if (claim && seat(g, 'r').hand.some(card => card.id === SEMUTA_DRUG_ID)) {
|
||||
g = act(g, 'r', { type: 'semutaCommit', event });
|
||||
if (g.pendingTreacheryDiscard?.reaction?.stage === 'select')
|
||||
g = act(g, 'r', { type: 'semutaSelect', event, card: pending.batch.entries[0].card.id });
|
||||
} else {
|
||||
for (const player of g.players) {
|
||||
if (g.pendingTreacheryDiscard?.batch.event !== event) break;
|
||||
g = act(g, player.id, { type: 'semutaPass', event });
|
||||
}
|
||||
}
|
||||
assert.notEqual(g.pendingTreacheryDiscard?.batch.event, event);
|
||||
return g;
|
||||
}
|
||||
function allowKull(g: Game) {
|
||||
for (let n = 0; g.pendingKull && !g.pendingTreacheryDiscard && n < 20; n++) {
|
||||
const response = g.response;
|
||||
if (!response) { g = normalizeAutomaticGame(g); continue; }
|
||||
const actor = g.players.find(p => !response.passed.includes(p.id)); assert.ok(actor);
|
||||
g = act(g, actor.id, { type: 'passResponse' });
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
for (const result of ['decline', 'success', 'counter'] as const) for (const claim of [false, true]) void test(
|
||||
`Basic Kull ${result} during a Richese gift retains Semuta ${claim ? 'claim' : 'pass'} and gift continuation`, () => {
|
||||
const f = fixture(); let g = f.g;
|
||||
const event = g.pendingKull!.event, offered = viewGame(g, 'choam').kullReaction;
|
||||
assert.ok(offered?.plays.some(play => play.source === 'printed' && play.card.id === f.kull));
|
||||
if (result === 'success' && !claim) for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(g, 'choam'); view.players.find(p => p.id === 'choam')!.bot = difficulty;
|
||||
const action = botActions(view).find(row => row.type === 'kullDecision'); assert.ok(action);
|
||||
assert.doesNotThrow(() => act(g, 'choam', action), difficulty);
|
||||
}
|
||||
g = act(g, 'choam', result === 'decline' ? { type: 'kullDecision', event, decline: true }
|
||||
: { type: 'kullDecision', event, source: 'printed', card: f.kull });
|
||||
if (result === 'counter') {
|
||||
assert.equal(g.response?.kind, 'choamWorthless');
|
||||
g = act(g, 'emperor', { type: 'card', mode: 'cancel', card: f.counter });
|
||||
} else if (result === 'success') g = allowKull(g);
|
||||
for (let n = 0; n < 6 && (g.pendingTreacheryDiscard || g.pendingKull); n++) {
|
||||
if (g.pendingTreacheryDiscard?.reaction) g = resolveSemuta(g, claim);
|
||||
else if (g.pendingKull) g = allowKull(g);
|
||||
else break;
|
||||
}
|
||||
assert.equal(g.pendingKull, null); assert.ok(!g.pendingTreacheryDiscard);
|
||||
if (result === 'success') {
|
||||
// Preventing one Karama does not consume the other players' original
|
||||
// chance to respond to the still-pending Richese alliance gift.
|
||||
assert.equal(g.response?.kind, 'richeseGift');
|
||||
assert.equal(g.pendingRicheseGift?.intent.cardId, f.gift);
|
||||
assert.ok(seat(g, 'r').hand.some(card => card.id === f.gift));
|
||||
for (let n = 0; g.response?.kind === 'richeseGift' && n < g.players.length; n++) {
|
||||
const response = g.response;
|
||||
const actor = g.players.find(p => !response.passed.includes(p.id)); assert.ok(actor);
|
||||
g = act(g, actor.id, { type: 'passResponse' });
|
||||
}
|
||||
assert.notEqual(g.response?.kind, 'richeseGift');
|
||||
}
|
||||
assert.equal(g.pendingRicheseGift, null); assert.deepEqual(inventory(g), f.originalCards);
|
||||
const succeeded = result === 'success';
|
||||
assert.equal(seat(g, 'emperor').hand.some(card => card.id === f.gift), succeeded);
|
||||
assert.equal(seat(g, 'r').hand.some(card => card.id === f.gift), !succeeded);
|
||||
assert.equal(seat(g, 'atreides').hand.some(card => card.id === f.karama), succeeded);
|
||||
assert.equal(seat(g, 'choam').hand.some(card => card.id === f.kull), !succeeded);
|
||||
assert.equal(g.turn, f.beforeGift.turn); assert.equal(g.phase, f.beforeGift.phase);
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,124 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyAction, createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
|
||||
import { placeAmbassador, validateAmbassadors } from '../game/ecaz-ambassadors';
|
||||
import { placeTerror } from '../game/moritani-terror';
|
||||
import { guildAmbassadorShipments } from '../game/guild-ambassador';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { nextSemutaNexusTradeNativeStep } from './fixture-semuta-nexus-trade';
|
||||
|
||||
type First = 'ambassador' | 'terror';
|
||||
const act = (g: Game, id: string, action: Action) => applyAction(g, id, action);
|
||||
const seat = (g: Game, id: string) => { const p = g.players.find(row => row.id === id); assert.ok(p); return p; };
|
||||
const clean = (g: Game) => !g.response && !g.phaseOpening && !g.decision && !g.truthtrance && !g.pendingTreacheryDiscard;
|
||||
|
||||
/** Genuine Basic public setup/training and entrant turn. Only one unopened
|
||||
* Spice card, original Ambassador cohort and legal token locations are staged. */
|
||||
function fixture(first: First, nexus: boolean, independent: boolean) {
|
||||
let g = createGame('KULLSKILLSOVERLAP', newPlayer('ecaz', 'Ecaz', 'ecaz'), false, ['ix', 'choam', 'ecaz']);
|
||||
for (const id of ['choam', 'tleilaxu', 'guild', 'moritani'] as const) joinGame(g, newPlayer(id, id, id));
|
||||
g = act(g, 'guild', { type: 'seatPosition', position: 6 });
|
||||
if (first === 'terror') g = act(g, 'moritani', { type: 'seatPosition', position: 4 });
|
||||
g = act(g, 'ecaz', { type: 'seatPosition', position: first === 'ambassador' ? 4 : 5 });
|
||||
g = act(g, 'choam', { type: 'seatPosition', position: 1 });
|
||||
g = act(g, 'tleilaxu', { type: 'seatPosition', position: 2 });
|
||||
for (const name of [...(nexus ? ['nexusCards'] : []), ...(independent ? ['ecazTreachery'] : []), 'leaderSkills', 'kullPreview'])
|
||||
g = act(g, 'ecaz', { type: 'moduleOption', module: name, enabled: true });
|
||||
for (const p of g.players) g = act(g, p.id, { type: 'ready' });
|
||||
g = act(g, 'ecaz', { type: 'start' });
|
||||
const reach = (until: (g: Game) => boolean) => {
|
||||
for (let n = 0; n < 1800; n++) {
|
||||
if (until(g)) return;
|
||||
assert.notEqual(g.status, 'finished');
|
||||
if (g.status === 'setup' && !g.setupStage && g.decision?.kind === 'moritaniSetup')
|
||||
g = act(g, 'moritani', { type: 'decision', territory: 'oh_gap', sector: 9 });
|
||||
else if (g.status === 'setup' && g.setupStage === 'forces' && seat(g, 'ecaz').reserves === 20)
|
||||
g = act(g, 'ecaz', { type: 'ecazSetup', placements: { 'imperial_basin:9': 6 } });
|
||||
else if (g.decision?.kind === 'ecazPlacement' && !g.response && !g.phaseOpening)
|
||||
g = act(g, 'ecaz', { type: 'decision', decline: true });
|
||||
else {
|
||||
const next = nextSemutaNexusTradeNativeStep(g);
|
||||
g = act(g, next.actor, next.action);
|
||||
}
|
||||
}
|
||||
throw Error('Native play did not reach the entrant turn');
|
||||
};
|
||||
reach(state => state.status === 'playing');
|
||||
assert.equal(g.leaderSkills?.assignments.length, g.players.length);
|
||||
assert.equal(g.kullPreview, true); assert.equal(g.nexusKullPreview === true, nexus);
|
||||
const spice = g.spiceDeck.findIndex(card => 'territory' in card && !card.discovery); assert.ok(spice >= 0);
|
||||
g.spiceDeck.unshift(g.spiceDeck.splice(spice, 1)[0]);
|
||||
reach(state => state.turn === 1 && state.phase === 5 && state.active === 'tleilaxu' && clean(state));
|
||||
assert.equal(g.order.indexOf('ecaz') < g.order.indexOf('moritani'), first === 'ambassador');
|
||||
const candidates = [{ territory: 'habbanya_ridge_sietch', sector: 17 }, { territory: 'sietch_tabr', sector: 14 }, { territory: 'arrakeen', sector: 10 }];
|
||||
const target = candidates.find(row => row.sector !== g.storm); assert.ok(target);
|
||||
const state = g.ecazAmbassadors!;
|
||||
const token = state.tokens.find(row => row.effect === 'guild'); assert.ok(token);
|
||||
if (token.zone === 'pool') {
|
||||
const replaced = state.tokens.find(row => row.zone === 'supply' && row.effect !== 'ecaz'); assert.ok(replaced);
|
||||
const index = state.cohort.indexOf(replaced.id); assert.ok(index >= 0);
|
||||
state.cohort[index] = token.id; replaced.zone = 'pool'; token.zone = 'supply';
|
||||
}
|
||||
validateAmbassadors(state);
|
||||
g.ecazAmbassadors = placeAmbassador(state, token.id, { turn: g.turn, availableSpice: seat(g, 'ecaz').spice,
|
||||
destination: { id: target.territory, stronghold: true, inStorm: false, allowed: true } }).state;
|
||||
const terror = g.moritaniTerror!.tokens.find(row => row.kind === 'robbery' && row.status === 'available'); assert.ok(terror);
|
||||
g.moritaniTerror = placeTerror(g.moritaniTerror!, terror.id, target.territory, g.turn);
|
||||
return { g, target, token: token.id, terror: terror.id };
|
||||
}
|
||||
|
||||
for (const nexus of [false, true]) for (const independent of [false, true])
|
||||
for (const first of ['ambassador', 'terror'] as const) for (const childReveal of [false, true])
|
||||
void test(`Basic ${nexus ? 'Nexus' : 'printed'} Kull/Skills ${independent ? 'independent ' : ''}${first} first: Guild child ${childReveal ? 'reveals' : 'declines'} Terror`, () => {
|
||||
const f = fixture(first, nexus, independent), before = structuredClone(f.g);
|
||||
const destination = `${f.target.territory}:${f.target.sector}`;
|
||||
const spice = seat(f.g, 'tleilaxu').spice, reserves = seat(f.g, 'ecaz').reserves;
|
||||
let g = act(f.g, 'tleilaxu', { type: 'ship', territory: f.target.territory, sector: f.target.sector, amount: 1, elite: 0, allyPayment: 0 });
|
||||
assert.deepEqual(f.g, before);
|
||||
// A held Karama can open the ordinary Guild-income response before the
|
||||
// already committed shipment's ordered entry reactions. Close that real
|
||||
// response through the existing native driver, without changing the hand.
|
||||
for (let n = 0; !g.pendingArrivalOverlap && n < 20; n++) {
|
||||
assert.equal(g.response?.kind, 'guildIncome');
|
||||
const next = nextSemutaNexusTradeNativeStep(g);
|
||||
g = act(g, next.actor, next.action);
|
||||
}
|
||||
assert.equal(g.pendingArrivalOverlap?.first, first);
|
||||
assert.equal(seat(g, 'tleilaxu').forces[destination], 1);
|
||||
const overlap = g.pendingArrivalOverlap!.event;
|
||||
if (first === 'terror') g = act(g, 'moritani', { type: 'decision', decline: true });
|
||||
const entry = g.pendingAmbassador; assert.ok(entry); assert.equal(entry.token, f.token);
|
||||
const ecazView = viewGame(g, 'ecaz'); assert.ok(ecazView.ambassadorEntry);
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(g, 'ecaz'); view.players.find(row => row.id === 'ecaz')!.bot = difficulty;
|
||||
const action = botActions(view)[0]; assert.ok(action, difficulty); assert.doesNotThrow(() => act(g, 'ecaz', action));
|
||||
}
|
||||
g = act(g, 'ecaz', { type: 'decision', event: entry.event, trigger: true, beneficiary: 'ecaz' });
|
||||
assert.equal(g.pendingAmbassador?.stage, 'ship');
|
||||
const target = guildAmbassadorShipments(g, 'ecaz').destinations.find(row => row.territory === f.target.territory && row.sector === f.target.sector);
|
||||
assert.ok(target);
|
||||
g = act(g, 'ecaz', { type: 'decision', event: entry.event, amount: 1, elite: 0, territory: target.territory, sector: target.sector });
|
||||
assert.equal(seat(g, 'ecaz').reserves, reserves - 1);
|
||||
assert.equal(g.pendingArrivalOverlap?.event, overlap);
|
||||
assert.equal(g.pendingTerrorEntry?.entrant, 'ecaz');
|
||||
assert.equal(g.pendingTerrorEntry?.token, f.terror);
|
||||
if (childReveal) {
|
||||
g = act(g, 'moritani', { type: 'decision', reveal: true });
|
||||
assert.equal(g.pendingTerrorEntry?.stage, 'robbery');
|
||||
g = act(g, 'moritani', { type: 'decision', choice: 'spice' });
|
||||
assert.equal(g.moritaniTerror!.tokens.find(row => row.id === f.terror)!.status, 'removed');
|
||||
} else g = act(g, 'moritani', { type: 'decision', decline: true });
|
||||
if (first === 'ambassador' && !childReveal) {
|
||||
assert.equal(g.pendingTerrorEntry?.entrant, 'tleilaxu');
|
||||
g = act(g, 'moritani', { type: 'decision', decline: true });
|
||||
}
|
||||
assert.equal(g.pendingArrivalOverlap, null); assert.equal(g.pendingAmbassador, null); assert.equal(g.pendingTerrorEntry, null);
|
||||
assert.equal(seat(g, 'tleilaxu').forces[destination], 1);
|
||||
assert.equal(seat(g, 'tleilaxu').spice, spice - 1);
|
||||
assert.equal(seat(g, 'ecaz').forces[destination], 1);
|
||||
assert.equal(g.ecazAmbassadors!.tokens.find(row => row.id === f.token)!.zone, 'used');
|
||||
assert.equal(g.active, 'tleilaxu');
|
||||
g = act(g, 'tleilaxu', { type: 'endMovement' });
|
||||
assert.ok(!g.movementRemaining?.includes('tleilaxu'));
|
||||
});
|
||||
@@ -0,0 +1,161 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
|
||||
import { actTruthMovementNativeEarly as act, nextTruthMovementNativeEarlyStep } from './fixture-truth-movement-native-early';
|
||||
import { truthMovementInventory as inventory } from './fixture-truth-movement';
|
||||
|
||||
const richese = 'richese', choam = 'choam', atreides = 'atreides';
|
||||
function seat(g: Game, id: string) {
|
||||
const p = g.players.find(row => row.id === id); assert.ok(p); return p;
|
||||
}
|
||||
const clean = (g: Game) => !g.response && !g.decision && !g.phaseOpening &&
|
||||
!g.truthtrance && !g.pendingRevival && !g.pendingTreacheryDiscard;
|
||||
function step(g: Game) {
|
||||
if (g.turn === 1 && g.phase === 5 && g.active === richese && clean(g)) {
|
||||
const p = seat(g, richese);
|
||||
if (!p.shipped) {
|
||||
const token = p.noField!.tokens.find(row => row.value === 3); assert.ok(token);
|
||||
return {actor:richese, action:{type:'ship', noField:token.id, event:p.noFieldEvent,
|
||||
territory:'polar_sink', sector:0, allyPayment:0} satisfies Action};
|
||||
}
|
||||
return {actor:richese, action:{type:'endMovement'} satisfies Action};
|
||||
}
|
||||
if (g.phase === 5 && g.active && clean(g))
|
||||
return {actor:g.active, action:{type:'endMovement'} satisfies Action};
|
||||
return nextTruthMovementNativeEarlyStep(g, {position:'first', method:'onceAround', direction:'clockwise'});
|
||||
}
|
||||
function reach(g: Game, until: (state: Game) => boolean): Game {
|
||||
for (let i = 0; i < 2000; i++) {
|
||||
if (until(g)) return g;
|
||||
assert.notEqual(g.status, 'finished');
|
||||
const next = step(g); assert.ok(next, `Supply a native action at ${g.turn}/${g.phase}/${g.decision?.kind}`);
|
||||
g = act(g, next.actor, next.action);
|
||||
}
|
||||
throw Error('Native game did not reach its Revival control');
|
||||
}
|
||||
|
||||
/** Genuine public Basic setup, real paid marker shipment and next-turn Revival.
|
||||
* Only the original unopened Spice order, Worthless card location and selected
|
||||
* recipient's physical casualty count are staged; each inventory is conserved. */
|
||||
function source(recipient: string, oneReserve = false) {
|
||||
let g = createGame('RICHESECHOAMREVIVAL', newPlayer(richese, 'Richese', 'richese'), false, ['choam']);
|
||||
joinGame(g, newPlayer(choam, 'CHOAM', 'choam'));
|
||||
joinGame(g, newPlayer(atreides, 'Atreides', 'atreides'));
|
||||
for (const p of g.players) g = act(g, p.id, {type:'ready'});
|
||||
g = act(g, g.host, {type:'start'});
|
||||
g = reach(g, state => state.status === 'playing');
|
||||
for (const position of [0, 1]) {
|
||||
const from = g.spiceDeck.findIndex((card, index) => index >= position && 'territory' in card && !card.discovery);
|
||||
assert.ok(from >= position);
|
||||
[g.spiceDeck[position], g.spiceDeck[from]] = [g.spiceDeck[from], g.spiceDeck[position]];
|
||||
}
|
||||
g = reach(g, state => state.turn === 2 && state.phase === 4 && clean(state));
|
||||
const owner = seat(g, richese), marker = owner.noField?.deployed, event = owner.noFieldEvent;
|
||||
assert.ok(marker); assert.ok(event);
|
||||
const p = seat(g, recipient); assert.ok(p.reserves >= 3);
|
||||
p.reserves -= 3; p.tanks += 3;
|
||||
if (oneReserve) {
|
||||
assert.equal(recipient, richese); assert.ok(p.reserves > 1);
|
||||
const staged = p.reserves - 1;
|
||||
p.reserves -= staged;
|
||||
p.forces['polar_sink:0'] = (p.forces['polar_sink:0'] ?? 0) + staged;
|
||||
}
|
||||
const physical = inventory(g);
|
||||
const c = seat(g, choam);
|
||||
if (!c.hand.some(card => card.name === 'La La La')) {
|
||||
let card = g.deck.findIndex(row => row.name === 'La La La');
|
||||
if (card >= 0) c.hand.push(g.deck.splice(card, 1)[0]);
|
||||
else {
|
||||
const holder = g.players.find(row => row.hand.some(held => held.name === 'La La La'));
|
||||
if (holder) {
|
||||
card = holder.hand.findIndex(held => held.name === 'La La La');
|
||||
c.hand.push(holder.hand.splice(card, 1)[0]);
|
||||
} else {
|
||||
card = g.discard.findIndex(held => held.name === 'La La La'); assert.ok(card >= 0);
|
||||
c.hand.push(g.discard.splice(card, 1)[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.deepEqual(inventory(g), physical);
|
||||
g = act(g, recipient, {type:'revive', amount:2, elite:0});
|
||||
assert.ok(g.decision?.kind === 'choamFreeRevival');
|
||||
assert.equal(g.decision.player, choam);
|
||||
assert.equal(g.decision.recipient, recipient);
|
||||
assert.equal(g.pendingRevival?.player, recipient);
|
||||
return {g, token:marker.tokenId, event, physical};
|
||||
}
|
||||
|
||||
for (const recipient of [richese, atreides]) for (const deny of [false, true]) void test(
|
||||
`Richese reveal preserves ${recipient}'s free Revival while CHOAM ${deny ? 'plays La La La' : 'allows'}`, () => {
|
||||
const {g, token, event, physical} = source(recipient), before = structuredClone(g);
|
||||
const reserves = seat(g, richese).reserves, field = seat(g, richese).forces['polar_sink:0'] ?? 0;
|
||||
const tanks = seat(g, recipient).tanks, revived = seat(g, recipient).revived;
|
||||
assert.equal(viewGame(g, richese).richeseNoField?.canReveal, true);
|
||||
let next = act(g, richese, {type:'revealNoField', token, event});
|
||||
assert.deepEqual(g, before);
|
||||
assert.deepEqual(next.decision, before.decision);
|
||||
assert.deepEqual(next.pendingRevival, before.pendingRevival);
|
||||
assert.equal(seat(next, richese).noField?.deployed, null);
|
||||
assert.equal(seat(next, richese).reserves, reserves - 3);
|
||||
assert.equal(seat(next, richese).forces['polar_sink:0'], field + 3);
|
||||
assert.equal(seat(next, recipient).tanks, tanks);
|
||||
if (deny) {
|
||||
const card = seat(next, choam).hand.find(row => row.name === 'La La La'); assert.ok(card);
|
||||
next = act(next, choam, {type:'card', mode:'choam', card:card.id});
|
||||
} else next = act(next, choam, {type:'decision', decline:true});
|
||||
for (let i = 0; (next.response || next.pendingTreacheryDiscard) && i < 40; i++) {
|
||||
if (next.pendingTreacheryDiscard?.reaction) {
|
||||
const reaction = next.pendingTreacheryDiscard.reaction;
|
||||
assert.ok(reaction.stage === 'offer');
|
||||
const p = next.players.find(row => !reaction.passed.includes(row.id)); assert.ok(p);
|
||||
next = act(next, p.id, {type:'semutaPass', event:next.pendingTreacheryDiscard.batch.event});
|
||||
} else if (next.response) {
|
||||
const p = next.players.find(row => !next.response!.passed.includes(row.id)); assert.ok(p);
|
||||
next = act(next, p.id, {type:'passResponse'});
|
||||
} else break;
|
||||
}
|
||||
assert.equal(next.pendingRevival, null);
|
||||
assert.equal(seat(next, recipient).tanks, tanks - (deny ? 0 : 2));
|
||||
assert.equal(seat(next, recipient).revived, revived + (deny ? 0 : 2));
|
||||
assert.equal(seat(next, richese).forces['polar_sink:0'], field + 3);
|
||||
assert.deepEqual(inventory(next), physical);
|
||||
},
|
||||
);
|
||||
|
||||
void test('a three-marker uses the one current reserve before the pending free return adds two', () => {
|
||||
const {g, token, event, physical} = source(richese, true), before = seat(g, richese);
|
||||
const field = before.forces['polar_sink:0'] ?? 0, tanks = before.tanks, revived = before.revived;
|
||||
const forceCount = (game: Game) => {
|
||||
const player = seat(game, richese);
|
||||
return player.reserves + player.tanks + Object.values(player.forces).reduce((sum, n) => sum + n, 0);
|
||||
};
|
||||
assert.equal(before.reserves, 1);
|
||||
assert.equal(forceCount(g), 20);
|
||||
const pending = structuredClone(g.pendingRevival);
|
||||
let next = act(g, richese, {type:'revealNoField', token, event});
|
||||
assert.equal(seat(next, richese).reserves, 0);
|
||||
assert.equal(seat(next, richese).forces['polar_sink:0'], field + 1);
|
||||
assert.equal(seat(next, richese).tanks, tanks);
|
||||
assert.deepEqual(next.pendingRevival, pending);
|
||||
assert.equal(forceCount(next), 20);
|
||||
next = act(next, choam, {type:'decision', decline:true});
|
||||
assert.equal(next.pendingRevival, null);
|
||||
assert.equal(seat(next, richese).reserves, 2);
|
||||
assert.equal(seat(next, richese).tanks, tanks - 2);
|
||||
assert.equal(seat(next, richese).revived, revived + 2);
|
||||
assert.equal(seat(next, richese).forces['polar_sink:0'], field + 1);
|
||||
assert.equal(forceCount(next), 20);
|
||||
assert.deepEqual(inventory(next), physical);
|
||||
});
|
||||
|
||||
void test('all bot profiles can respond to the original CHOAM decision after a voluntary reveal', () => {
|
||||
const {g, token, event} = source(atreides);
|
||||
const revealed = act(g, richese, {type:'revealNoField', token, event});
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(revealed, choam); view.players.find(p => p.id === choam)!.bot = difficulty;
|
||||
const action = botActions(view)[0]; assert.ok(action, difficulty);
|
||||
assert.doesNotThrow(() => act(revealed, choam, action), difficulty);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user