updates
This commit is contained in:
parent
5368464042
commit
937f44defe
100 changed files with 10185 additions and 2042 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { addBugs } from '../src/cards/util.ts';
|
||||
import { avatarCores, canWear, executionActions, executionCost, programCost } from '../src/engine.ts';
|
||||
import { healthOf, portsFree } from '../src/query.ts';
|
||||
import { anomalyCores, canWear, executionActions, executionCost, programCost } from '../src/engine.ts';
|
||||
import { healthOf, slotsFree } from '../src/query.ts';
|
||||
import { card } from './card.ts';
|
||||
import { Table, type Side } from './table.ts';
|
||||
|
||||
|
|
@ -20,21 +20,21 @@ const attackerDice = (t: Table) => t.logText().match(/Roll: Broken Bits \[([\d,]
|
|||
card('RAM Expansion', () => {
|
||||
const t = scene({ south: { main: ['RAM Expansion'] } });
|
||||
t.hardware(0, 1, 'RAM Expansion');
|
||||
assert.equal(avatarCores(t.s, 0, 1, 'defend'), 4, 'no Cores');
|
||||
assert.equal(anomalyCores(t.s, 0, 1, 'defend'), 4, 'no Cores');
|
||||
assert.equal(healthOf(t.s, { player: 0, slot: 1 }), 9 + 2, 'Broken Bits: 9 Health, +2');
|
||||
});
|
||||
|
||||
card('Additional Core', () => {
|
||||
const t = scene({ south: { main: ['Additional Core'] } });
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
assert.equal(avatarCores(t.s, 0, 1, 'defend'), 5);
|
||||
assert.equal(anomalyCores(t.s, 0, 1, 'defend'), 5);
|
||||
});
|
||||
|
||||
card('Overclocked CPU', () => {
|
||||
const t = scene({ south: { main: ['Overclocked CPU', 'Stack Overflow'] } });
|
||||
t.hardware(0, 1, 'Overclocked CPU');
|
||||
const so = t.program(0, 'B1', 'Stack Overflow');
|
||||
assert.equal(avatarCores(t.s, 0, 1, 'attack'), 6, '+2 in combat');
|
||||
assert.equal(anomalyCores(t.s, 0, 1, 'attack'), 6, '+2 in combat');
|
||||
attackC1(t);
|
||||
t.rig(6, 6, 6, 6, 6, 6, 1, 1, 1, 1).end();
|
||||
assert.equal(attackerDice(t), 6);
|
||||
|
|
@ -53,7 +53,7 @@ card('Solid-State Cache', () => {
|
|||
const [so, hf] = t.hand(0, 'Stack Overflow', 'Hotfix');
|
||||
assert.equal(programCost(t.s, 0, so, 'B1'), 4);
|
||||
assert.equal(programCost(t.s, 0, so, 'S1'), 7, 'only on the occupied Server');
|
||||
t.ram(0, 4).to('play').go({ type: 'installProgram', card: so, at: 'B1' });
|
||||
t.bandwidth(0, 4).to('play').go({ type: 'installProgram', card: so, at: 'B1' });
|
||||
assert.equal(programCost(t.s, 0, hf, 'B1'), 7, 'first each turn');
|
||||
});
|
||||
|
||||
|
|
@ -63,28 +63,28 @@ card('Redundant Power Supply', () => {
|
|||
const ac = t.hardware(0, 1, 'Additional Core');
|
||||
attackC1(t);
|
||||
t.rig(1, 1, 1, 1, 1, 6, 6, 6, 6).end();
|
||||
assert.equal(t.avatar(0, 1).at, null);
|
||||
assert.deepEqual(t.avatar(0, 1).hardware, [rps, ac], 'kept, in its slot');
|
||||
assert.equal(t.anomaly(0, 1).at, null);
|
||||
assert.deepEqual(t.anomaly(0, 1).hardware, [rps, ac], 'kept, in its slot');
|
||||
// The second defeat loses it.
|
||||
t.to('playAgain').end().to('playAgain').end();
|
||||
t.go({ type: 'place', slot: 1, to: 'B1' });
|
||||
attackC1(t);
|
||||
t.rig(1, 1, 1, 1, 1, 6, 6, 6, 6).end();
|
||||
assert.deepEqual(t.avatar(0, 1).hardware, []);
|
||||
assert.deepEqual(t.anomaly(0, 1).hardware, []);
|
||||
});
|
||||
|
||||
card('Network Interface Upgrade', () => {
|
||||
const t = new Table({ south: { avatars: ['Beta Version 1.0', 'Broken Bits', 'Code Zero', 'Pixelated Picture'], main: ['Additional Core', 'RAM Expansion', 'Network Interface Upgrade', 'Packet Accelerator'] } });
|
||||
const t = new Table({ south: { anomalies: ['Beta Version 1.0', 'Broken Bits', 'Code Zero', 'Pixelated Picture'], main: ['Additional Core', 'RAM Expansion', 'Network Interface Upgrade', 'Packet Accelerator'] } });
|
||||
const beta = { player: 0 as const, slot: 1 };
|
||||
t.place(0, 1, 'S1');
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
t.hardware(0, 1, 'RAM Expansion');
|
||||
const [niu, pa] = t.hand(0, 'Network Interface Upgrade', 'Packet Accelerator');
|
||||
assert.equal(portsFree(t.s, beta), 0);
|
||||
assert.equal(slotsFree(t.s, beta), 0);
|
||||
assert.ok(!canWear(t.s, pa, beta));
|
||||
assert.ok(canWear(t.s, niu, beta), 'fits with both ports full');
|
||||
t.ram(0, 4).to('play').go({ type: 'installHardware', card: niu, slot: 1 });
|
||||
assert.equal(portsFree(t.s, beta), 1, 'and adds a port');
|
||||
assert.ok(canWear(t.s, niu, beta), 'fits with both Expansion Slots full');
|
||||
t.bandwidth(0, 4).to('play').go({ type: 'installHardware', card: niu, slot: 1 });
|
||||
assert.equal(slotsFree(t.s, beta), 1, 'and adds an Expansion Slot');
|
||||
assert.ok(canWear(t.s, pa, beta));
|
||||
});
|
||||
|
||||
|
|
@ -93,22 +93,22 @@ card('Dedicated GPU', () => {
|
|||
t.place(0, 1, 'S1');
|
||||
t.hardware(0, 1, 'Dedicated GPU');
|
||||
t.hand(0, 'Execute: Ping Sweep');
|
||||
t.ram(0, 4).play(0, 'Execute: Ping Sweep', null, {}, 'S1').settle();
|
||||
t.bandwidth(0, 4).play(0, 'Execute: Ping Sweep', null, {}, 'S1').settle();
|
||||
assert.equal(t.s.players[0].hand.length, 3, 'performed by the Server it stands on: draws 2 + 1');
|
||||
});
|
||||
|
||||
card('ECC Memory', () => {
|
||||
const t = scene({ south: { main: ['ECC Memory', 'Additional Core'] }, north: { main: ['Memory Leak', 'Stock Rice'] } });
|
||||
const t = scene({ south: { main: ['ECC Memory', 'Additional Core'] }, north: { main: ['Bloatware', 'Stock Rice'] } });
|
||||
t.hardware(0, 1, 'ECC Memory');
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
t.program(1, 'C1', 'Memory Leak');
|
||||
t.program(1, 'C1', 'Bloatware');
|
||||
t.program(1, 'C1', 'Stock Rice');
|
||||
attackC1(t);
|
||||
t.rig(6, 6, 6, 6, 6, 1, 1, 1, 1).end();
|
||||
assert.equal(attackerDice(t), 5, "neither Bug Program touches it");
|
||||
assert.equal(addBugs(t.s, { player: 0, slot: 1 }, 1, 'a Bug card', 1), false, "and opponents can't give it Bug counters");
|
||||
assert.equal(t.avatar(0, 1).bugs, 0);
|
||||
assert.equal(addBugs(t.s, { player: 1, slot: 1 }, 1, 'a Bug card', 0), true, 'Avatars without it can get them');
|
||||
assert.equal(t.anomaly(0, 1).bugs, 0);
|
||||
assert.equal(addBugs(t.s, { player: 1, slot: 1 }, 1, 'a Bug card', 0), true, 'Anomalies without it can get them');
|
||||
});
|
||||
|
||||
card('Cooling System', () => {
|
||||
|
|
@ -118,43 +118,43 @@ card('Cooling System', () => {
|
|||
t.hardware(0, 1, 'Cooling System');
|
||||
t.hardware(0, 1, 'Solid-State Cache');
|
||||
const [so, hf] = t.hand(0, 'Stack Overflow', 'Hotfix');
|
||||
t.ram(0, 20).to('play');
|
||||
t.bandwidth(0, 20).to('play');
|
||||
t.go({ type: 'installProgram', card: so, at: 'B1' });
|
||||
assert.equal(programCost(t.s, 0, hf, 'B1'), 4, 'Solid-State Cache works twice');
|
||||
t.go({ type: 'installProgram', card: hf, at: 'B1' });
|
||||
assert.equal(t.s.players[0].ram, 20 - 4 - 4);
|
||||
assert.equal(t.s.players[0].bandwidth, 20 - 4 - 4);
|
||||
});
|
||||
|
||||
card('RAID Array', () => {
|
||||
const t = scene({ south: { main: ['RAID Array', 'Additional Core'] } });
|
||||
t.hardware(0, 1, 'RAID Array');
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
t.ram(0, 5);
|
||||
t.bandwidth(0, 5);
|
||||
attackC1(t);
|
||||
t.rig(1, 1, 1, 1, 1, 6, 6, 6, 6).end();
|
||||
assert.equal(t.s.choice?.kind, 'RAID Array:keep');
|
||||
t.choose('Keep').settle();
|
||||
assert.equal(t.avatar(0, 1).hardware.length, 2);
|
||||
assert.equal(t.s.players[0].ram, 0, 'half of 5 + 5');
|
||||
assert.equal(t.anomaly(0, 1).hardware.length, 2);
|
||||
assert.equal(t.s.players[0].bandwidth, 0, 'half of 5 + 5');
|
||||
});
|
||||
|
||||
card('Packet Accelerator', () => {
|
||||
const t = scene({ south: { main: ['Packet Accelerator'] } });
|
||||
t.hardware(0, 1, 'Packet Accelerator');
|
||||
assert.equal(avatarCores(t.s, 0, 1, 'attack'), 5);
|
||||
assert.equal(avatarCores(t.s, 0, 1, 'defend'), 4);
|
||||
assert.equal(anomalyCores(t.s, 0, 1, 'attack'), 5);
|
||||
assert.equal(anomalyCores(t.s, 0, 1, 'defend'), 4);
|
||||
});
|
||||
|
||||
card('Firewall Appliance', () => {
|
||||
const t = scene({ south: { main: ['Execute: Sabotage'] }, north: { main: ['Firewall Appliance'] } });
|
||||
const fa = t.hardware(1, 1, 'Firewall Appliance');
|
||||
const [sab] = t.hand(0, 'Execute: Sabotage');
|
||||
t.ram(0, 10);
|
||||
t.bandwidth(0, 10);
|
||||
attackC1(t);
|
||||
t.act({ type: 'end' });
|
||||
assert.equal(executionCost(t.s, 0, sab, 'C1', { card: fa, mode: 'destroy' }), 10, '+3 for the first hostile Execution');
|
||||
t.play(0, 'Execute: Sabotage', 'C1', { card: fa, mode: 'destroy' });
|
||||
assert.equal(t.s.players[0].ram, 0);
|
||||
assert.equal(t.s.players[0].bandwidth, 0);
|
||||
});
|
||||
|
||||
card('Hardware Sandbox', () => {
|
||||
|
|
@ -164,11 +164,11 @@ card('Hardware Sandbox', () => {
|
|||
const so = t.program(1, 'C1', 'Stack Overflow');
|
||||
const hf = t.program(1, 'C1', 'Hotfix');
|
||||
const [sandbox] = t.hand(1, 'Hardware Sandbox');
|
||||
t.ram(1, 7).to('play').act({ type: 'installHardware', card: sandbox, slot: 1 });
|
||||
t.bandwidth(1, 7).to('play').act({ type: 'installHardware', card: sandbox, slot: 1 });
|
||||
t.choose('Stack Overflow').settle();
|
||||
t.to('playAgain').end();
|
||||
t.hand(0, 'Execute: Kill Process', 'Execute: Root Access');
|
||||
t.ram(0, 9);
|
||||
t.bandwidth(0, 9);
|
||||
const kills = () => executionActions(t.s, 0, 'now').filter((a) => a.type === 'play' && t.s.cards[a.card].name === 'Execute: Kill Process').map((a) => a.type === 'play' && a.args.card);
|
||||
assert.deepEqual(kills(), [hf], 'Stack Overflow is protected');
|
||||
t.play(0, 'Execute: Root Access', 'C1').settle();
|
||||
|
|
@ -193,16 +193,16 @@ card('Hot-Swap Bay', () => {
|
|||
const hsb = t.hardware(0, 1, 'Hot-Swap Bay');
|
||||
const ac = t.hardware(0, 1, 'Additional Core');
|
||||
const [oc] = t.hand(0, 'Overclocked CPU');
|
||||
t.ram(0, 1).use(hsb, { card: ac, cards: [oc] }).settle();
|
||||
assert.deepEqual(t.avatar(0, 1).hardware, [hsb, oc]);
|
||||
t.bandwidth(0, 1).use(hsb, { card: ac, cards: [oc] }).settle();
|
||||
assert.deepEqual(t.anomaly(0, 1).hardware, [hsb, oc]);
|
||||
assert.deepEqual(t.s.players[0].hand, [ac]);
|
||||
assert.equal(t.s.players[0].ram, 0, 'pays the 1 RAM difference');
|
||||
assert.equal(t.s.players[0].bandwidth, 0, 'pays the 1 Gb difference');
|
||||
});
|
||||
|
||||
test('Hardware must still fit its ports when Network Interface Upgrade leaves', () => {
|
||||
test('Hardware must still fit its Expansion Slots when Network Interface Upgrade leaves', () => {
|
||||
const t = new Table({
|
||||
south: {
|
||||
avatars: ['Beta Version 1.0', 'Broken Bits', 'Code Zero', 'Pixelated Picture'],
|
||||
anomalies: ['Beta Version 1.0', 'Broken Bits', 'Code Zero', 'Pixelated Picture'],
|
||||
main: ['Network Interface Upgrade', 'Hot-Swap Bay', 'Additional Core', 'Packet Accelerator', 'RAM Expansion', 'Execute: Rollback'],
|
||||
},
|
||||
});
|
||||
|
|
@ -212,15 +212,15 @@ test('Hardware must still fit its ports when Network Interface Upgrade leaves',
|
|||
const ac = t.hardware(0, 1, 'Additional Core');
|
||||
const pa = t.hardware(0, 1, 'Packet Accelerator');
|
||||
t.hand(0, 'RAM Expansion', 'Execute: Rollback');
|
||||
t.ram(0, 20);
|
||||
// Beta Version 1.0 has 2 ports, +1 from the NIU, and all 3 are in use.
|
||||
t.bandwidth(0, 20);
|
||||
// Beta Version 1.0 has 2 Expansion Slots, +1 from the NIU, and all 3 are in use.
|
||||
const swaps = t.legal().filter((a) => a.type === 'activate' && a.card === hsb);
|
||||
assert.ok(!swaps.some((a) => a.type === 'activate' && a.args.card === niu), "Hot-Swap Bay can't swap the NIU for a card that needs a port");
|
||||
assert.ok(!swaps.some((a) => a.type === 'activate' && a.args.card === niu), "Hot-Swap Bay can't swap the NIU for a card that needs an Expansion Slot");
|
||||
assert.ok(swaps.some((a) => a.type === 'activate' && a.args.card === ac));
|
||||
// Rollback returns the NIU: the newest Hardware no longer fits and is discarded.
|
||||
t.s.cards[niu].installedTurn = t.s.turn;
|
||||
t.play(0, 'Execute: Rollback', 'S1', { card: niu }).settle();
|
||||
assert.deepEqual(t.avatar(0, 1).hardware, [hsb, ac]);
|
||||
assert.deepEqual(t.anomaly(0, 1).hardware, [hsb, ac]);
|
||||
assert.ok(t.s.players[0].discard.includes(pa));
|
||||
});
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ card('Quantum Coprocessor', () => {
|
|||
t.place(0, 1, 'S1');
|
||||
const qc = t.hardware(0, 1, 'Quantum Coprocessor');
|
||||
t.hand(0, 'Execute: Kill Process');
|
||||
t.ram(0, 5).play(0, 'Execute: Kill Process', 'C1', { card: so }, 'S1').settle();
|
||||
t.bandwidth(0, 5).play(0, 'Execute: Kill Process', 'C1', { card: so }, 'S1').settle();
|
||||
assert.equal(t.s.choice?.kind, 'Quantum Coprocessor:copy');
|
||||
t.choose('Hotfix').settle();
|
||||
assert.ok(t.s.cards[so].disabledUntil > t.s.clock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue