React to a clean Distrans transfer in the Homeworld Semuta envelope
This commit is contained in:
1 parent
a9a8ae6b75
commit
f1706ab408
10 files changed
+130
-13
No files matched your search
@@ -30,6 +30,40 @@ export function createSemutaHomeworldOrdinaryFixture(): SemutaHomeworldOrdinaryF
|
||||
action: { type: 'card', card: hajr } };
|
||||
}
|
||||
|
||||
export type SemutaHomeworldDistransFixture = {
|
||||
game: Game; holder: string; owner: string; distrans: string; given: string;
|
||||
recipient: string; action: Action;
|
||||
};
|
||||
|
||||
/** Genuine original Homeworld occupation state; the Distrans transfer and its
|
||||
* given card are conserved physical cards, not minted, and the recipient is a
|
||||
* real seat. No clock, wallet or occupation value is assigned. */
|
||||
export function createSemutaHomeworldDistransFixture(): SemutaHomeworldDistransFixture {
|
||||
const income = createSemutaHomeworldGuildIncomeFixture({ advanced: false });
|
||||
const game = income.game;
|
||||
assert.equal(game.phase, 5);
|
||||
assert.equal(game.active, 'a');
|
||||
const holder = income.holder, owner = 'a', recipient = 'e';
|
||||
const distrans = moveSemutaEmperorCard(game,
|
||||
semutaEmperorCardId(game, card => card.effect === 'distrans'), owner);
|
||||
const given = moveSemutaEmperorCard(game, semutaEmperorCardId(game, card =>
|
||||
card.effect !== 'distrans' && card.kind !== 'special' && card.effect !== 'karama' &&
|
||||
card.effect !== 'nullentropyBox'), owner);
|
||||
return { game, holder, owner, distrans, given, recipient,
|
||||
action: { type: 'card', card: distrans, target: recipient, give: given } };
|
||||
}
|
||||
|
||||
export function reactSemutaHomeworldDistrans(
|
||||
state: Game, fixture: SemutaHomeworldDistransFixture, claim: boolean,
|
||||
): Game {
|
||||
const event = state.pendingTreacheryDiscard!.batch.event;
|
||||
if (claim) return applyAction(state, fixture.holder, { type: 'semutaCommit', event });
|
||||
let game = state;
|
||||
for (const player of state.players)
|
||||
game = applyAction(game, player.id, { type: 'semutaPass', event });
|
||||
return game;
|
||||
}
|
||||
|
||||
export type SemutaHomeworldBoxFixture = {
|
||||
game: Game; source: Game; holder: string; box: string; owner: string;
|
||||
action: Action; cost: number;
|
||||
|
||||
@@ -5,8 +5,9 @@ import { botActions } from '../game/bots';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { semutaEmperorPlayer } from './fixture-semuta-emperor-share';
|
||||
import {
|
||||
createSemutaHomeworldBoxFixture, createSemutaHomeworldOrdinaryFixture,
|
||||
reactSemutaHomeworldBox, reactSemutaHomeworldOrdinary,
|
||||
createSemutaHomeworldBoxFixture, createSemutaHomeworldDistransFixture,
|
||||
createSemutaHomeworldOrdinaryFixture, reactSemutaHomeworldBox,
|
||||
reactSemutaHomeworldDistrans, reactSemutaHomeworldOrdinary,
|
||||
semutaHomeworldOrdinaryState,
|
||||
} from './fixture-semuta-homeworld-ordinary';
|
||||
|
||||
@@ -103,6 +104,60 @@ for (const difficulty of ['Easy', 'Medium', 'Hard', 'Brutal'] as const) void tes
|
||||
},
|
||||
);
|
||||
|
||||
for (const claim of [false, true]) void test(
|
||||
`Homeworld Distrans transfer Semuta ${claim ? 'claims' : 'passes'} the used Distrans without repeating the gift`, () => {
|
||||
const f = createSemutaHomeworldDistransFixture();
|
||||
const played = applyAction(f.game, f.owner, f.action);
|
||||
const pending = played.pendingTreacheryDiscard;
|
||||
assert.ok(pending, 'The used Distrans must offer its printed Semuta cost');
|
||||
assert.equal(pending.batch.cause, 'distrans');
|
||||
assert.deepEqual(pending.batch.entries.map(entry => ({
|
||||
id: entry.card.id, by: entry.discardedBy, face: entry.publicFace,
|
||||
})), [{ id: f.distrans, by: f.owner, face: true }]);
|
||||
const recipient = semutaEmperorPlayer(played, f.recipient);
|
||||
assert.equal(recipient.hand.some(card => card.id === f.given), true,
|
||||
'The private transfer has already completed');
|
||||
assert.equal(recipient.hand.some(card => card.id === f.distrans), false);
|
||||
assert.equal(played.discard.some(card => card.id === f.distrans), true);
|
||||
for (const player of played.players) viewGame(played, player.id);
|
||||
const before = semutaHomeworldOrdinaryState(played);
|
||||
const event = pending.batch.event;
|
||||
assert.throws(() => applyAction(played, f.holder, { type: 'semutaSelect', event, card: f.given }),
|
||||
'The already-transferred card is not a candidate');
|
||||
const done = reactSemutaHomeworldDistrans(played, f, claim);
|
||||
assert.equal(done.pendingTreacheryDiscard, null);
|
||||
assert.equal(done.resolvedTreacheryDiscardSequence, pending.sequence);
|
||||
const holder = semutaEmperorPlayer(done, f.holder);
|
||||
assert.equal(holder.hand.some(card => card.id === f.distrans), claim);
|
||||
assert.equal(holder.hand.some(card => card.id === SEMUTA_DRUG_ID), !claim);
|
||||
assert.equal(semutaEmperorPlayer(done, f.recipient).hand.some(card => card.id === f.given), true);
|
||||
assert.deepEqual(semutaHomeworldOrdinaryState(done), before,
|
||||
'The private gift, wallets and occupation authority are unchanged');
|
||||
assert.throws(() => applyAction(done, f.owner, f.action));
|
||||
const suffix = applyAction(done, f.owner, { type: 'endMovement' });
|
||||
assert.ok(!suffix.movementRemaining?.includes(f.owner));
|
||||
assert.equal(suffix.phase, 5);
|
||||
},
|
||||
);
|
||||
|
||||
for (const difficulty of ['Easy', 'Medium', 'Hard', 'Brutal'] as const) void test(
|
||||
`the ${difficulty} bot settles the Homeworld Distrans Semuta cost`, () => {
|
||||
const f = createSemutaHomeworldDistransFixture();
|
||||
const played = applyAction(f.game, f.owner, f.action);
|
||||
const view = viewGame(played, f.holder);
|
||||
view.players.find(player => player.id === f.holder)!.bot = difficulty;
|
||||
const action = botActions(view)[0];
|
||||
assert.ok(action);
|
||||
const done = applyAction(played, f.holder, action);
|
||||
assert.equal(done.pendingTreacheryDiscard, null);
|
||||
const holder = done.players.find(player => player.id === f.holder)!;
|
||||
const claimed = holder.hand.some(card => card.id === f.distrans);
|
||||
assert.equal(claimed || done.discard.some(card => card.id === f.distrans), true);
|
||||
assert.equal(holder.hand.some(card => card.id === SEMUTA_DRUG_ID), !claimed);
|
||||
assert.equal(semutaEmperorPlayer(done, f.recipient).hand.some(card => card.id === f.given), true);
|
||||
},
|
||||
);
|
||||
|
||||
void test('a full-hand Homeworld Richese exchanges Semuta for the used ordinary card', () => {
|
||||
const f = createSemutaHomeworldOrdinaryFixture();
|
||||
const holder = semutaEmperorPlayer(f.game, f.holder);
|
||||
|
||||
Reference in new issue
Block a user