rule change

This commit is contained in:
Forrest 2026-09-29 13:28:06 -04:00
parent 62b2b9feca
commit 5d771eed1b
9 changed files with 199 additions and 75 deletions

View file

@ -29,21 +29,21 @@ test('setup follows rules.md', () => {
assert.deepEqual(checkInvariants(s), []);
});
test('the first player skips the draw; the second player draws', () => {
test('both players draw on their first turn (since v0.9); firstTurn.draw=false makes the first player skip it', () => {
// The test table pins the old skip, so card tests start from a known hand.
const t = new Table({ south: { main: ['Additional Core'] }, north: { main: ['Additional Core'] } });
assert.equal(t.s.players[0].hand.length, 0);
t.to('playAgain').end();
assert.equal(t.s.active, 1);
assert.equal(t.s.players[1].hand.length, 1);
});
test('rule variants: the first player draws on turn 1', () => {
const pool = loadCards();
const hand = (rules: RulesConfig) => {
const s = createGame({ pool, decks: [randomDeck(pool, makeRng(1), rules), randomDeck(pool, makeRng(2), rules)], seed: 5, rules });
return s.players[s.firstPlayer].hand.length;
};
assert.equal(hand(withRule(DEFAULT_RULES, 'firstTurn.draw=true')), hand(DEFAULT_RULES) + 1);
assert.equal(DEFAULT_RULES.firstTurn.draw, true);
assert.equal(hand(withRule(DEFAULT_RULES, 'firstTurn.draw=false')), hand(DEFAULT_RULES) - 1);
});
test('rule variants: the second player draws extra in their first draw step only', () => {
@ -119,7 +119,8 @@ test('rule variants: the second player can start with extra cards and a location
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.players[p2].hand.length, rules.openingHand + 2);
assert.equal(s.players[s.firstPlayer].hand.length, rules.openingHand + 1, 'the first player drew on turn 1');
assert.equal(s.locations[p2 === 0 ? 'A2' : 'E2'].owner, p2);
assert.equal(s.players[p2].serverPile.length, 18);
assert.deepEqual(checkInvariants(s), []);
@ -389,10 +390,10 @@ test('buy rule: captures unlock nothing', () => {
// ---------------------------------------------------------------------------------------------
// Command rule (prototype): alternating commands, 2 per player per round
/** Command rule with plain A B A B rounds, so tests can predict whose command it is. */
/** Command rule with plain A B A B rounds and an alternating lead, so tests can predict whose command it is. */
function commandTable(): Table {
const t = new Table();
t.s.rules = withRule(withRule(t.s.rules, 'commands.on=true'), 'commands.snake=false');
for (const sp of ['commands.on=true', 'commands.snake=false', 'commands.leads=FS']) t.s.rules = withRule(t.s.rules, sp);
return t;
}
@ -418,8 +419,8 @@ test('command rule: the order of commands can follow a pattern of round leads, o
assert.equal(order('commands.leads=FFSS'), 'FSFS' + 'FSFS' + 'SFSF' + 'SFSF');
assert.equal(order('commands.leads=thue'), 'FSFS' + 'SFSF' + 'SFSF' + 'FSFS');
assert.equal(order('commands.snake=true', 'commands.leads=F'), 'FSSF'.repeat(4));
assert.equal(order('commands.snake=true'), 'FSSF' + 'SFFS' + 'FSSF' + 'SFFS', 'the default order');
assert.equal(DEFAULT_RULES.commands.snake, true);
assert.equal(order('commands.snake=true'), 'FSSF' + 'SFFS' + 'FSSF' + 'SFFS', 'the v0.8 order');
assert.deepEqual(DEFAULT_RULES.commands, { on: true, perPlayer: 2, leads: 'F', snake: true }, 'the default since v0.9: the first player leads every round, snake order');
});
test('command rule: one advance or attack per command, each Avatar once a round', () => {

View file

@ -36,12 +36,13 @@ export class Table {
main: [...(x.main ?? []), ...Array(12).fill(FILLER)],
});
const decks = [side(o.south), side(o.north)] as const;
// Classic turns (one turn each, every Avatar acts) and one-roll combats, which the card tests
// are written for. The command rule has its own tests in engine.test.ts, the health rule in
// health.test.ts (`health: true`).
// Classic turns (one turn each, every Avatar acts), no turn-1 draw for the first player, and
// one-roll combats, which the card tests are written for. The command rule has its own tests in
// engine.test.ts, the health rule in health.test.ts (`health: true`).
const rules: RulesConfig = {
...DEFAULT_RULES,
commands: { ...DEFAULT_RULES.commands, on: false },
firstTurn: { ...DEFAULT_RULES.firstTurn, draw: false },
health: { ...DEFAULT_RULES.health, on: o.health ?? false },
openingHand: 0,
deck: { avatars: 4, servers: decks[0].servers.length, main: decks[0].main.length, maxCopies: 99 },