Prototype charity Truthtrance and coalition rule foundations
Verify and publish checkpoint container / container (push) Successful in 10m14s
Verify and publish checkpoint container / container (push) Successful in 10m14s
This commit is contained in:
1 parent
e896570f07
commit
cea310b030
17 files changed
+1024
-35
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { type Action, type Game } from '../game/engine';
|
||||
import { nextTruthRevival, truthRevivalClean, truthRevivalPlayer } from './fixture-truth-revival';
|
||||
import {
|
||||
actFutureBattleCharity as act, askFutureBattleCharity as ask,
|
||||
createFutureBattleCharityFixture as fixture, futureBattleCharityInventory as inventory,
|
||||
futureBattleCharityRecords as records, reachFutureBattleCharityBattle as reachBattle,
|
||||
reachFutureBattleCharityWindow as reachMovement,
|
||||
} from './fixture-truth-future-battle-charity';
|
||||
|
||||
function rejected(game: Game, actor: string, action: Action) {
|
||||
const before = structuredClone(game);
|
||||
assert.throws(() => act(game, actor, action));
|
||||
assert.deepEqual(game, before);
|
||||
}
|
||||
|
||||
for (const answer of ['yes', 'no'] as const) {
|
||||
void test(`Basic Charity future-battle leader ${answer} binds the first actual later battle`, () => {
|
||||
const f = fixture(), asked = ask(f);
|
||||
assert.equal(asked.phase, 2); assert.deepEqual(asked.truthtrance?.question, f.question);
|
||||
let game = act(asked, f.target, {type: 'truthAnswer', answer});
|
||||
assert.equal(records(game).length, 1); assert.equal(records(game)[0].status, 'waiting');
|
||||
game = reachMovement(game, f);
|
||||
assert.equal(records(game)[0].status, 'waiting');
|
||||
game = reachBattle(game, f);
|
||||
assert.equal(records(game)[0].status, 'bound');
|
||||
assert.equal(records(game)[0].battle, game.battle!.event);
|
||||
const plan = (leader: string): Action => ({type: 'battlePlan', leader, dial: 0, support: 0, weapon: null, defense: null});
|
||||
rejected(game, f.target, plan(answer === 'yes' ? f.alternative : f.leader));
|
||||
game = act(game, f.target, plan(answer === 'yes' ? f.leader : f.alternative));
|
||||
assert.equal(records(game)[0].status, 'bound');
|
||||
const opponent = game.battle!.attacker === f.target ? game.battle!.defender : game.battle!.attacker;
|
||||
const other = truthRevivalPlayer(game, opponent).leaders.find(leader =>
|
||||
!leader.dead && !leader.capturedBy && !leader.gholaBy && !leader.usedAt);
|
||||
assert.ok(other);
|
||||
game = act(game, opponent, plan(other.id));
|
||||
assert.ok(game.battle?.revealed); assert.equal(records(game)[0].status, 'settled');
|
||||
assert.equal(records(game).length, 1);
|
||||
assert.equal(game.discard.filter(card => card.id === f.truth).length, 1);
|
||||
assert.deepEqual(inventory(game), f.originalCards);
|
||||
});
|
||||
}
|
||||
|
||||
void test('Basic Charity conditional leader answer expires if the respondent never fights', () => {
|
||||
const f = fixture();
|
||||
for (const answer of ['yes', 'no'] as const) {
|
||||
let game = act(ask(f), f.target, {type: 'truthAnswer', answer});
|
||||
game = reachMovement(game, f);
|
||||
assert.ok(Object.values(truthRevivalPlayer(game, f.target).forces).every(amount => amount === 0));
|
||||
for (let count = 0; count < 1200 && game.turn === f.game.turn && game.phase <= 6 && game.status === 'playing'; count++) {
|
||||
if (game.phase === 5 && game.active && truthRevivalClean(game)) {
|
||||
game = act(game, game.active, {type: 'endMovement'}); continue;
|
||||
}
|
||||
const next = nextTruthRevival(game); assert.ok(next, 'Finish the real turn without inventing a target battle.');
|
||||
game = act(game, next.actor, next.action);
|
||||
}
|
||||
assert.equal(records(game).length, 1); assert.equal(records(game)[0].status, 'expired');
|
||||
assert.equal(game.discard.filter(card => card.id === f.truth).length, 1);
|
||||
assert.deepEqual(inventory(game), f.originalCards);
|
||||
}
|
||||
});
|
||||
|
||||
void test('a pending Truthtrance priority must finish before its Charity-phase question can be asked', () => {
|
||||
const f = fixture();
|
||||
const game = act(f.game, f.asker, {type: 'card', card: f.truth});
|
||||
assert.equal(game.truthtrance?.stage, 'priority');
|
||||
rejected(game, f.asker, f.ask);
|
||||
assert.deepEqual(inventory(game), f.originalCards);
|
||||
});
|
||||
Reference in new issue
Block a user