updates
This commit is contained in:
parent
e590baf28d
commit
6382de19c9
15 changed files with 239 additions and 28 deletions
|
|
@ -5,7 +5,7 @@ import { randomDeck } from '../src/deck.ts';
|
|||
import { advanceTargets, avatarCores, createGame, legalActions, viewFor } from '../src/engine.ts';
|
||||
import { checkInvariants } from '../src/invariants.ts';
|
||||
import { makeRng } from '../src/rng.ts';
|
||||
import { DEFAULT_RULES } from '../src/rules.ts';
|
||||
import { DEFAULT_RULES, withRule } from '../src/rules.ts';
|
||||
import { Table } from './table.ts';
|
||||
|
||||
const pool = loadCards();
|
||||
|
|
@ -36,7 +36,7 @@ test('the first player skips the draw; the second player draws', () => {
|
|||
assert.equal(t.s.players[1].hand.length, 1);
|
||||
});
|
||||
|
||||
test('advancing captures an unowned location in step 5, pays its level and unlocks an Avatar', () => {
|
||||
test('advancing captures an unowned location in step 5 and pays 4 RAM; Lv 1 unlocks nothing', () => {
|
||||
const t = new Table();
|
||||
t.ram(0, 4);
|
||||
assert.deepEqual(advanceTargets(t.s, 0), ['A2']);
|
||||
|
|
@ -46,11 +46,59 @@ test('advancing captures an unowned location in step 5, pays its level and unloc
|
|||
t.end();
|
||||
assert.equal(t.s.locations.A2.owner, 0);
|
||||
assert.equal(t.avatar(0, 1).at, 'A2');
|
||||
assert.equal(t.s.players[0].ram, 8, '4 RAM + 4 for a Lv 2 capture');
|
||||
assert.equal(t.avatar(0, 2).faceUp, true, 'Lv 2 unlocks Avatar 2');
|
||||
assert.equal(t.s.players[0].ram, 8, '4 RAM + 4 for the capture');
|
||||
assert.equal(t.avatar(0, 2).faceUp, false, 'A2 is Lv 1 for South');
|
||||
assert.equal(t.s.step, 'playAgain');
|
||||
});
|
||||
|
||||
test('the second row (Lv 2) unlocks Avatar 2; the middle row (Lv 3) unlocks Avatars 2 and 3', () => {
|
||||
for (const [from, to, unlocked] of [['A2', 'B1', [true, false]], ['B1', 'C2', [true, true]]] as const) {
|
||||
const t = new Table();
|
||||
t.own(0, from);
|
||||
t.place(0, 1, from);
|
||||
t.go({ type: 'advance', slot: 1, to }).to('attack').end();
|
||||
assert.equal(t.s.locations[to].owner, 0);
|
||||
assert.deepEqual([t.avatar(0, 2).faceUp, t.avatar(0, 3).faceUp], unlocked, to);
|
||||
}
|
||||
});
|
||||
|
||||
test('rule variants: a turn-1 capture can pay no RAM and unlock nothing', () => {
|
||||
const t = new Table();
|
||||
t.s.rules = withRule(withRule(t.s.rules, 'firstTurn.captureRam=false'), 'firstTurn.unlock=false');
|
||||
t.ram(0, 4).own(0, 'A2');
|
||||
t.place(0, 1, 'A2');
|
||||
t.go({ type: 'advance', slot: 1, to: 'B1' }).to('attack').end();
|
||||
assert.equal(t.s.locations.B1.owner, 0);
|
||||
assert.equal(t.s.players[0].ram, 4);
|
||||
assert.equal(t.avatar(0, 2).faceUp, false);
|
||||
});
|
||||
|
||||
test('rule variants: the first player can be barred from playing cards on turn 1', () => {
|
||||
const t = new Table({ south: { main: ['Additional Core'] }, north: { main: ['Additional Core'] } });
|
||||
t.s.rules = withRule(t.s.rules, 'firstTurn.cards=false');
|
||||
t.hand(0, 'Additional Core');
|
||||
t.ram(0, 9).place(0, 1, 'S1');
|
||||
t.to('playAgain');
|
||||
assert.ok(!t.legal().some((a) => a.type === 'installHardware'));
|
||||
t.end();
|
||||
t.hand(1, 'Additional Core');
|
||||
t.ram(1, 9).place(1, 1, 'S2');
|
||||
t.to('playAgain');
|
||||
assert.ok(t.legal().some((a) => a.type === 'installHardware'), 'the second player can on turn 2');
|
||||
});
|
||||
|
||||
test('rule variants: the second player can start with extra cards and a location', () => {
|
||||
const rng = makeRng(5);
|
||||
const decks = [randomDeck(pool, rng, DEFAULT_RULES), randomDeck(pool, rng, DEFAULT_RULES)] as const;
|
||||
const rules = withRule(withRule(DEFAULT_RULES, 'secondPlayer.cards=2'), 'secondPlayer.locations=1');
|
||||
const s = createGame({ pool, decks: [decks[0], decks[1]], seed: 3, rules });
|
||||
const p2 = s.firstPlayer === 0 ? 1 : 0;
|
||||
assert.equal(s.players[p2].hand.length, s.players[s.firstPlayer].hand.length + 2);
|
||||
assert.equal(s.locations[p2 === 0 ? 'A2' : 'E2'].owner, p2);
|
||||
assert.equal(s.players[p2].serverPile.length, 18);
|
||||
assert.deepEqual(checkInvariants(s), []);
|
||||
});
|
||||
|
||||
test('placement closes once an advance is declared', () => {
|
||||
const t = new Table();
|
||||
t.go({ type: 'place', slot: 1, to: 'S1' }).go({ type: 'advance', slot: 1, to: 'A2' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue