Offer Semuta before clean CHOAM Kulon movement bonus
This commit is contained in:
1 parent
8f67b39735
commit
88bcb33342
8 files changed
+273
-18
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
applyAction,
|
||||
createGame,
|
||||
newPlayer,
|
||||
normalizeAutomaticGame,
|
||||
viewGame,
|
||||
RuleError,
|
||||
type Game,
|
||||
@@ -14,6 +15,8 @@ import { TERRITORIES, gameDistance, splitLocation } from '../game/board';
|
||||
import { forceRevivalQuote, newRevivalRules } from '../game/revival';
|
||||
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';
|
||||
function fixture(advanced = false) {
|
||||
const g = createGame('CWORTH22', newPlayer('c', 'CHOAM', 'choam'), advanced, [
|
||||
'choam',
|
||||
@@ -127,6 +130,70 @@ void test('Kulon adds one range in basic and advanced play only after its Karama
|
||||
assert.throws(() => move(g, 1), /movement is not available/);
|
||||
}
|
||||
});
|
||||
void test('clean Kulon discard offers Semuta before the one earned movement bonus', () => {
|
||||
const initial = movement();
|
||||
initial.players[1] = newPlayer('e', 'Richese', 'richese');
|
||||
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 = named(initial, 'Kulon');
|
||||
const physical = (state: Game) => [
|
||||
...state.deck, ...state.discard, ...state.richeseCache!,
|
||||
...state.players.flatMap(p => p.hand),
|
||||
].map(c => c.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 offered = (state: Game) => allow(play(state, 'Kulon'));
|
||||
const pending = offered(initial), neutral = offered(absent);
|
||||
const event = pending.pendingTreacheryDiscard!.batch.event;
|
||||
assert.equal(pending.pendingTreacheryDiscard?.continuation.kind, 'choamKulonDiscard');
|
||||
assert.equal(pending.pendingTreacheryDiscard?.reaction?.stage, 'offer');
|
||||
assert.equal(neutral.pendingTreacheryDiscard?.reaction?.stage, 'offer');
|
||||
assert.equal(pending.choamMovement, undefined);
|
||||
assert.equal(pending.discard.filter(c => c.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);
|
||||
assert.throws(() => move(pending, 2));
|
||||
for (const change of [
|
||||
(state: Game) => {
|
||||
const c = state.pendingTreacheryDiscard!.continuation;
|
||||
if (c.kind === 'choamKulonDiscard') c.before = 3;
|
||||
},
|
||||
(state: Game) => { state.choamMovement = { turn: state.turn, bonus: 1 }; },
|
||||
(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(() => applyAction(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 = applyAction(declined, id, { type: 'semutaPass', event });
|
||||
const claimed = applyAction(JSON.parse(JSON.stringify(pending)), 'e',
|
||||
{ type: 'semutaCommit', event });
|
||||
for (const state of [declined, claimed]) {
|
||||
assert.equal(state.pendingTreacheryDiscard, null);
|
||||
assert.deepEqual(state.choamMovement, { turn: state.turn, bonus: 1 });
|
||||
assert.deepEqual(physical(state), original);
|
||||
assert.equal(player(move(state, 2), 'c').moved, 1);
|
||||
assert.throws(() => applyAction(state, 'e', { type: 'semutaCommit', event }));
|
||||
}
|
||||
assert.equal(declined.discard.filter(c => c.id === card).length, 1);
|
||||
assert.equal(claimed.players[1].hand.filter(c => c.id === card).length, 1);
|
||||
assert.equal(claimed.discard.filter(c => c.id === semuta.id).length, 1);
|
||||
});
|
||||
|
||||
void test('Kulon adds to ornithopters and keeps the usual storm and alliance entry restrictions', () => {
|
||||
let g = movement(true);
|
||||
assert.throws(() => move(g, 4), /more than 3/);
|
||||
|
||||
Reference in new issue
Block a user