67 lines
3.4 KiB
TypeScript
67 lines
3.4 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { viewGame, type Game } from '../game/engine';
|
|
import { truthFactAnswer } from '../game/truthtrance';
|
|
import {
|
|
actTruthMixedBattle as act,
|
|
bindTruthMixedBattle as bind,
|
|
createTruthMixedBattleFixture as fixture,
|
|
truthMixedBattleAction as action,
|
|
truthMixedBattleFact as fact,
|
|
truthMixedBattleGroup as group,
|
|
truthMixedBattleInventory as inventory,
|
|
truthMixedBattlePlayer as player,
|
|
} from './fixture-truth-mixed-battle';
|
|
|
|
/** The native setup, movement, physical battle and Prescience opportunity are
|
|
* real. Place one existing Karama from the unopened deck in Emperor's hand in
|
|
* both branches so the actual Prescience response stays open. The residual
|
|
* branch swaps Emperor's original projectile for an existing shield; both
|
|
* branches have the same public hand count and conserved physical inventory. */
|
|
function sources() {
|
|
const f = fixture({window:'preparation'});
|
|
const constant = structuredClone(f.game);
|
|
const hand = player(constant,f.target).hand;
|
|
const karama = constant.deck.findIndex(card => card.effect === 'karama');
|
|
assert.ok(karama >= 0);
|
|
hand.push(...constant.deck.splice(karama,1));
|
|
const residual = structuredClone(constant), differentHand = player(residual,f.target).hand;
|
|
const projectile = differentHand.findIndex(card => card.id === f.ordinary);
|
|
const shield = residual.deck.findIndex(card => card.kind === 'shield');
|
|
assert.ok(projectile >= 0 && shield >= 0);
|
|
[differentHand[projectile],residual.deck[shield]] = [residual.deck[shield],differentHand[projectile]];
|
|
assert.deepEqual(inventory(constant),f.originalCards);
|
|
assert.deepEqual(inventory(residual),f.originalCards);
|
|
assert.equal(player(constant,f.target).hand.length,player(residual,f.target).hand.length);
|
|
assert.equal(truthFactAnswer(player(constant,f.target),f.heldFact),'yes');
|
|
assert.equal(truthFactAnswer(player(residual,f.target),f.heldFact),'no');
|
|
return {f,constant,residual};
|
|
}
|
|
|
|
void test('a hidden mixed battle fact cannot change public bribe availability during Prescience', () => {
|
|
const {f,constant,residual} = sources();
|
|
// Same announced question and Yes answer: a held projectile makes the OR
|
|
// already true; without it, the native unarmed plan satisfies the answer.
|
|
const mixed = group('or',fact(f.heldFact),action({kind:'weapon',name:null}));
|
|
const build = (source: Game) => {
|
|
let game = bind(f,'yes',mixed,source).game;
|
|
assert.equal(game.battle?.preparation?.kind,'prescience');
|
|
game = act(game,f.asker,{type:'prescience',field:'weapon'});
|
|
assert.equal(game.response?.kind,'prescience');
|
|
return game;
|
|
};
|
|
const a = build(constant), b = build(residual);
|
|
assert.equal(a.mixedBattleQuestions?.at(-1)?.binding,false);
|
|
assert.equal(b.mixedBattleQuestions?.at(-1)?.binding,true);
|
|
assert.equal(a.battle?.truthPromises?.length ?? 0,0);
|
|
assert.equal(b.battle?.truthPromises?.length,1);
|
|
assert.deepEqual(viewGame(a,f.asker).truthHistory,viewGame(b,f.asker).truthHistory);
|
|
assert.deepEqual(a.response,b.response);
|
|
for (const seat of a.players) {
|
|
const aView = viewGame(a,seat.id), bView = viewGame(b,seat.id);
|
|
assert.equal(aView.bribeOptions.blocked,bView.bribeOptions.blocked,
|
|
`${seat.id} must not infer the private fact from bribe availability`);
|
|
assert.ok(aView.bribeOptions.blocked,'Mixed answers remain outside this interruption prototype');
|
|
}
|
|
});
|