Offer Semuta before CHOAM Jubba storm protection
This commit is contained in:
1 parent
953be21d38
commit
98d556a0e0
8 files changed
+313
-19
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
createGame,
|
||||
newPlayer,
|
||||
viewGame,
|
||||
normalizeAutomaticGame,
|
||||
type Game,
|
||||
type Action,
|
||||
} from '../game/engine';
|
||||
@@ -12,6 +13,8 @@ import { baseDeck } from '../game/cards';
|
||||
import { MOBILE_LOCATION } from '../game/board';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { richeseCards } from '../game/richese-cards';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
|
||||
const player = (g: Game, id: string) => g.players.find((p) => p.id === id)!;
|
||||
const send = (g: Game, id: string, action: Action) =>
|
||||
@@ -121,6 +124,82 @@ void test('Jubba protects only CHOAM in one territory in basic and advanced game
|
||||
conserve(g);
|
||||
}
|
||||
});
|
||||
void test('accepted Jubba discard offers Semuta before protection and resumes one storm', () => {
|
||||
const initial = fixture();
|
||||
initial.players[1] = newPlayer('e', 'Richese', 'richese');
|
||||
forces(initial, 'e', { 'red_chasm:7': 3 });
|
||||
initial.richeseCache = richeseCards();
|
||||
initial.semutaPreview = true;
|
||||
const index = initial.richeseCache.findIndex(card => card.id === SEMUTA_DRUG_ID);
|
||||
assert.ok(index >= 0);
|
||||
const semuta = initial.richeseCache.splice(index, 1)[0];
|
||||
player(initial, 'e').hand.push(semuta);
|
||||
contest(initial, 'b');
|
||||
const card = player(initial, 'c').hand.find(card => card.name === 'Jubba Cloak')!.id;
|
||||
const physical = (state: Game) => [
|
||||
...state.deck, ...state.discard, ...state.richeseCache!,
|
||||
...state.players.flatMap(p => p.hand),
|
||||
].map(card => card.id).sort();
|
||||
const original = physical(initial);
|
||||
const absent = structuredClone(initial);
|
||||
player(absent, 'e').hand = [absent.richeseCache!.splice(0, 1)[0]];
|
||||
absent.richeseCache!.push(semuta);
|
||||
const pending = allow(play(begin(initial)));
|
||||
const neutral = allow(play(begin(absent)));
|
||||
const event = pending.pendingTreacheryDiscard!.batch.event;
|
||||
assert.equal(pending.pendingTreacheryDiscard?.continuation.kind, 'choamJubbaDiscard');
|
||||
assert.equal(pending.pendingTreacheryDiscard?.reaction?.stage, 'offer');
|
||||
assert.equal(neutral.pendingTreacheryDiscard?.reaction?.stage, 'offer');
|
||||
assert.equal(pending.storm, 5);
|
||||
assert.ok(pending.stormResolution);
|
||||
assert.deepEqual(pending.stormResolution.choamProtected, undefined);
|
||||
assert.equal(player(pending, 'c').forces['red_chasm:7'], 4);
|
||||
assert.equal(player(pending, 'e').forces['red_chasm:7'], 3);
|
||||
assert.equal(pending.discard.filter(used => used.id === card).length, 1);
|
||||
assert.deepEqual(viewGame(pending, 'c'), viewGame(neutral, 'c'));
|
||||
assert.deepEqual(viewGame(pending, 'b'), viewGame(neutral, 'b'));
|
||||
assert.equal(viewGame(pending, 'e').semutaReaction?.canCommit, true);
|
||||
assert.equal(botActions(viewGame(pending, 'e'))[0]?.type, 'semutaCommit');
|
||||
assert.deepEqual(normalizeAutomaticGame(JSON.parse(JSON.stringify(pending))), pending);
|
||||
for (const change of [
|
||||
(state: Game) => {
|
||||
const c = state.pendingTreacheryDiscard!.continuation;
|
||||
if (c.kind === 'choamJubbaDiscard') c.territory = 'basin';
|
||||
},
|
||||
(state: Game) => { state.stormResolution!.distance++; },
|
||||
(state: Game) => { player(state, 'c').forces = {}; },
|
||||
(state: Game) => { state.pendingTreacheryDiscard!.batch.entries[0].card.name = 'Forgery'; },
|
||||
]) {
|
||||
const corrupt: Game = JSON.parse(JSON.stringify(pending));
|
||||
change(corrupt);
|
||||
const before = JSON.stringify(corrupt);
|
||||
assert.throws(() => send(corrupt, 'e', { type: 'semutaCommit', event }));
|
||||
assert.equal(JSON.stringify(corrupt), before);
|
||||
}
|
||||
let declined: Game = JSON.parse(JSON.stringify(pending));
|
||||
for (const id of ['c', 'b', 'e'])
|
||||
declined = send(declined, id, { type: 'semutaPass', event });
|
||||
const claimed = send(JSON.parse(JSON.stringify(pending)), 'e',
|
||||
{ type: 'semutaCommit', event });
|
||||
for (const state of [declined, claimed]) {
|
||||
assert.equal(state.pendingTreacheryDiscard, null);
|
||||
assert.equal(state.stormResolution, null);
|
||||
assert.equal(state.storm, 8);
|
||||
assert.equal(player(state, 'c').forces['red_chasm:7'], 4);
|
||||
assert.equal(player(state, 'c').tanks, 0);
|
||||
assert.equal(player(state, 'e').forces['red_chasm:7'], undefined);
|
||||
assert.equal(player(state, 'e').tanks, 3);
|
||||
assert.equal(state.spice['red_chasm:7'], undefined);
|
||||
assert.equal(state.decision?.kind, 'choamMarket');
|
||||
assert.equal(state.log.filter(entry => entry.text.startsWith('Storm moved')).length, 1);
|
||||
assert.deepEqual(physical(state), original);
|
||||
assert.throws(() => send(state, 'e', { type: 'semutaCommit', event }));
|
||||
}
|
||||
assert.equal(declined.discard.filter(used => used.id === card).length, 1);
|
||||
assert.equal(player(claimed, 'e').hand.filter(used => used.id === card).length, 1);
|
||||
assert.equal(claimed.discard.filter(used => used.id === semuta.id).length, 1);
|
||||
});
|
||||
|
||||
void test('moving-storm decision and public projection do not reveal Jubba ownership', () => {
|
||||
const initial = fixture(),
|
||||
empty = structuredClone(initial);
|
||||
|
||||
Reference in new issue
Block a user