updates
This commit is contained in:
parent
5d771eed1b
commit
5368464042
28 changed files with 887 additions and 187 deletions
|
|
@ -28,7 +28,7 @@ card('Carbon NanoBots', () => {
|
|||
const t = scene('Carbon NanoBots', 'Broken Bits', { south: { main: ['Additional Core'] } });
|
||||
t.own(0, 'A2');
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
t.ram(0, 5).use(avatarCard(t, 0, 1), { to: 'A2' }).settle();
|
||||
t.ram(0, 6).use(avatarCard(t, 0, 1), { to: 'A2' }).settle();
|
||||
assert.equal(t.avatar(0, 5).at, 'A2', 'the copy is in play');
|
||||
assert.equal(avatarCores(t.s, 0, 5, 'defend'), 3, "2 Cores + the original's Additional Core");
|
||||
// The copy attacks and loses: the original keeps its Hardware.
|
||||
|
|
@ -44,7 +44,7 @@ test('copy rule variants: a new copy defends but only advances or attacks from i
|
|||
const t = scene('Carbon NanoBots', 'Broken Bits');
|
||||
t.s.rules = withRule(t.s.rules, 'copies.waitATurn=true');
|
||||
t.own(0, 'A2');
|
||||
t.ram(0, 5).use(avatarCard(t, 0, 1), { to: 'A2' }).settle();
|
||||
t.ram(0, 6).use(avatarCard(t, 0, 1), { to: 'A2' }).settle();
|
||||
assert.equal(t.avatar(0, 5).at, 'A2', 'the copy is in play, defending A2');
|
||||
const acts = () => t.legal().filter((a) => (a.type === 'advance' || a.type === 'attack') && a.slot === 5);
|
||||
assert.deepEqual(acts(), []);
|
||||
|
|
@ -58,7 +58,7 @@ test('copy rule variants: a new copy defends but only advances or attacks from i
|
|||
test('copy rule variants: copies can need Avatar 2 unlocked, or be off', () => {
|
||||
const t = scene('Carbon NanoBots', 'Broken Bits');
|
||||
t.own(0, 'A2');
|
||||
t.ram(0, 5);
|
||||
t.ram(0, 6);
|
||||
const replicate = () => t.legal().some((a) => a.type === 'activate' && a.name === 'Carbon NanoBots');
|
||||
assert.ok(replicate());
|
||||
t.s.rules = withRule(t.s.rules, 'copies.needAvatar2=true');
|
||||
|
|
@ -73,7 +73,7 @@ test('no copy can enter a location while a combat is going on there', () => {
|
|||
const t = scene('Broken Bits', 'Carbon NanoBots', { north: { servers: ['Cluster Server'] } });
|
||||
t.own(1, 'C1', 'Cluster Server');
|
||||
assert.ok(hasRoom(t.s, 1, 'C1'), 'the Cluster Server has room for a second defender');
|
||||
t.ram(1, 5);
|
||||
t.ram(1, 6);
|
||||
fight(t);
|
||||
assert.ok(t.s.combat, 'North can Replicate, so the combat stops for a response');
|
||||
assert.ok(!hasRoom(t.s, 1, 'C1'));
|
||||
|
|
@ -101,8 +101,8 @@ card('Pixelated Picture', () => {
|
|||
});
|
||||
|
||||
card('Beta Version 1.0', () => {
|
||||
const t = scene('Beta Version 1.0', 'Broken Bits', { south: { main: ['Additional Core', 'RAM Expansion', 'Packet Accelerator'] } });
|
||||
t.hardware(0, 1, 'RAM Expansion');
|
||||
const t = scene('Beta Version 1.0', 'Broken Bits', { south: { main: ['Additional Core', 'Overclocked CPU', 'Packet Accelerator'] } });
|
||||
t.hardware(0, 1, 'Overclocked CPU');
|
||||
t.hardware(0, 1, 'Packet Accelerator');
|
||||
const [ac] = t.hand(0, 'Additional Core');
|
||||
t.ram(0, 4 + 5);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,37 @@ test('every card has its own test', () => {
|
|||
assert.deepEqual(pool.all.map((c) => c.name).filter((n) => !tested.has(n)), []);
|
||||
});
|
||||
|
||||
test('set 2 loads on request, is well formed, and is unscripted', () => {
|
||||
const two = loadCards(undefined, [2]);
|
||||
const count = (kind: string) => two.all.filter((c) => c.kind === kind).length;
|
||||
assert.equal(count('avatar'), 12);
|
||||
assert.equal(count('server'), 7);
|
||||
assert.equal(count('program'), 17);
|
||||
assert.equal(count('hardware'), 8);
|
||||
assert.equal(count('execution'), 8);
|
||||
for (const c of two.all) {
|
||||
assert.equal(c.set, 2, c.name);
|
||||
assert.ok(!pool.byName.has(c.name), `${c.name} clashes with a set 1 card`);
|
||||
assert.ok(c.text || c.ability, `${c.name} has text`);
|
||||
if (c.kind === 'avatar') {
|
||||
assert.equal(c.cores + c.slots, 6, `${c.name}: Cores + Slots = 6`);
|
||||
assert.equal(c.health, { 4: 9, 3: 10, 2: 12 }[c.cores], `${c.name}: Health by Cores`);
|
||||
assert.ok(c.type && c.ability && c.ability.cost >= 3 && c.ability.cost <= 5, `${c.name}: typed, Ability 3-5 RAM`);
|
||||
} else if (c.kind === 'program') {
|
||||
assert.ok(c.type && c.ram >= 4 && c.ram <= 6, `${c.name}: typed, 4-6 RAM`);
|
||||
} else if (c.kind === 'execution') {
|
||||
assert.ok(c.ram >= 3 && c.ram <= 5, `${c.name}: 3-5 RAM`);
|
||||
} else if (c.kind === 'hardware') {
|
||||
assert.ok(c.ram >= 4 && c.ram <= 7, `${c.name}: 4-7 RAM`);
|
||||
}
|
||||
}
|
||||
const all = loadCards(undefined, 'all');
|
||||
assert.equal(all.all.length, pool.all.length + two.all.length);
|
||||
const warnings = staleScripts(all);
|
||||
assert.equal(warnings.length, two.all.length, 'one warning per set 2 card');
|
||||
assert.ok(warnings.every((w) => w.endsWith('no script yet')), 'the only warnings are missing scripts');
|
||||
});
|
||||
|
||||
test('random decks are legal', () => {
|
||||
const rng = makeRng(3);
|
||||
for (let i = 0; i < 50; i++) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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 { portsFree } from '../src/query.ts';
|
||||
import { healthOf, portsFree } from '../src/query.ts';
|
||||
import { card } from './card.ts';
|
||||
import { Table, type Side } from './table.ts';
|
||||
|
||||
|
|
@ -20,7 +20,8 @@ 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'), 6);
|
||||
assert.equal(avatarCores(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', () => {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ function turnOf(t: Table, p: 0 | 1): Table {
|
|||
}
|
||||
|
||||
/** South's Avatar 1 (Broken Bits, 4 Cores, 9 Health) on B1 facing North's Avatar 1 on C1. */
|
||||
function standoff(o: { northMain?: string[] } = {}): Table {
|
||||
const t = new Table({ health: true, north: { main: o.northMain } });
|
||||
function standoff(o: { northMain?: string[]; southMain?: string[] } = {}): Table {
|
||||
const t = new Table({ health: true, north: { main: o.northMain }, south: { main: o.southMain } });
|
||||
t.own(0, 'B1');
|
||||
t.own(1, 'C1');
|
||||
t.place(0, 1, 'B1');
|
||||
|
|
@ -180,3 +180,68 @@ test('health: with two defenders the damage destroys the weakest first, and the
|
|||
assert.equal(u.s.locations.C1.owner, 0);
|
||||
assert.equal(u.avatar(0, 1).at, 'C1');
|
||||
});
|
||||
|
||||
test('health: Resource Leech and Persistent Infection fire on a lost roll, not only a destruction', () => {
|
||||
const t = standoff({ northMain: ['Resource Leech', 'Persistent Infection'] });
|
||||
t.program(1, 'C1', 'Resource Leech');
|
||||
t.program(1, 'C1', 'Persistent Infection');
|
||||
const ram = t.s.players[1].ram;
|
||||
t.to('attack').go({ type: 'attack', slot: 1, to: 'C1' });
|
||||
t.rig(3, 3, 3, 3, 4, 4, 4, 4); // 12 to 16: the attacker takes 4 and lives
|
||||
t.end();
|
||||
assert.equal(t.avatar(0, 1).at, 'B1');
|
||||
assert.equal(t.avatar(0, 1).damage, 4);
|
||||
assert.equal(t.s.players[1].ram, ram + 3, 'Resource Leech pays 3');
|
||||
assert.equal(t.avatar(0, 1).permanentInfection, 1, 'a permanent Infection counter');
|
||||
});
|
||||
|
||||
test('health: Overflow Error only disables, until the next command, while the attacker lives', () => {
|
||||
const t = standoff({ northMain: ['Overflow Error'], southMain: ['Stack Overflow'] });
|
||||
t.program(1, 'C1', 'Overflow Error');
|
||||
const so = t.program(0, 'B1', 'Stack Overflow');
|
||||
t.to('attack').go({ type: 'attack', slot: 1, to: 'C1' });
|
||||
t.rig(3, 3, 3, 3, 4, 4, 4, 4);
|
||||
t.end();
|
||||
assert.equal(t.s.choice?.kind, 'Overflow Error:hit');
|
||||
assert.ok(t.s.choice!.options.every((o) => o.label.startsWith('Disable')), 'no destroy option while the attacker lives');
|
||||
t.choose('Disable Stack Overflow').settle();
|
||||
assert.ok(t.s.cards[so].disabledUntil > t.s.clock && t.s.cards[so].disabledUntil < FOREVER, 'disabled until the next command');
|
||||
assert.ok(t.s.locations.B1.programs.includes(so), 'still installed');
|
||||
});
|
||||
|
||||
test('health: Overflow Error may destroy a Program when the attacker is destroyed', () => {
|
||||
const t = standoff({ northMain: ['Overflow Error'], southMain: ['Stack Overflow'] });
|
||||
t.program(1, 'C1', 'Overflow Error');
|
||||
const so = t.program(0, 'B1', 'Stack Overflow');
|
||||
t.to('attack').go({ type: 'attack', slot: 1, to: 'C1' });
|
||||
t.rig(1, 1, 1, 1, 6, 6, 6, 6); // 4 to 24: 20 damage on 9 Health
|
||||
t.end();
|
||||
assert.equal(t.s.choice?.kind, 'Overflow Error:hit');
|
||||
t.choose('Destroy Stack Overflow').settle();
|
||||
assert.ok(t.s.players[0].discard.includes(so));
|
||||
assert.equal(t.avatar(0, 1).at, null);
|
||||
});
|
||||
|
||||
test("health: Backup Machine's Restore Point heals 3 damage", () => {
|
||||
const t = new Table({ health: true, south: { avatars: ['Backup Machine', 'Broken Bits', 'Pixelated Picture', 'Corrupt Driver'] } });
|
||||
t.own(0, 'B1');
|
||||
t.place(0, 1, 'B1');
|
||||
const bm = t.avatar(0, 1).card;
|
||||
assert.ok(!t.legal().some((a) => a.type === 'activate' && a.card === bm && a.args.heal), 'nothing to heal yet');
|
||||
t.avatar(0, 1).damage = 5;
|
||||
t.ram(0, 5).use(bm, { heal: true }).settle();
|
||||
assert.equal(t.avatar(0, 1).damage, 2);
|
||||
assert.equal(t.s.players[0].ram, 0);
|
||||
assert.equal(healthLeft(t.s, { player: 0, slot: 1 }), 8);
|
||||
});
|
||||
|
||||
test('health: RAM Expansion adds 2 Health, so a hit that would destroy the wearer leaves it standing', () => {
|
||||
const t = standoff({ northMain: ['RAM Expansion'] });
|
||||
t.hardware(1, 1, 'RAM Expansion');
|
||||
assert.equal(healthOf(t.s, { player: 1, slot: 1 }), 11);
|
||||
t.to('attack').go({ type: 'attack', slot: 1, to: 'C1' });
|
||||
t.rig(6, 6, 6, 6, 4, 4, 4, 3); // 24 to 15: 9 damage against 11 Health
|
||||
t.end();
|
||||
assert.equal(t.avatar(1, 1).at, 'C1', 'C1 holds');
|
||||
assert.equal(healthLeft(t.s, { player: 1, slot: 1 }), 2);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,16 +38,16 @@ card('Recursive Infection', () => {
|
|||
});
|
||||
|
||||
card('Memory Parasite', () => {
|
||||
const t = scene({ south: { main: ['Additional Core', 'RAM Expansion'] }, north: { main: ['Memory Parasite'] } });
|
||||
const t = scene({ south: { main: ['Additional Core', 'Overclocked CPU'] }, north: { main: ['Memory Parasite'] } });
|
||||
t.program(1, 'C1', 'Memory Parasite');
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
t.hardware(0, 1, 'RAM Expansion');
|
||||
t.hardware(0, 1, 'Overclocked CPU');
|
||||
attackC1(t);
|
||||
t.rig(6, 6, 6, 6, 6, 6, 1, 1, 1, 1).end();
|
||||
assert.equal(t.s.choice?.kind, 'Memory Parasite:disable');
|
||||
assert.equal(t.s.choice?.player, 0, "the attacking Avatar's owner chooses");
|
||||
t.choose('Additional Core').settle();
|
||||
assert.equal(attackerDice(t), 6, '4 + RAM Expansion only');
|
||||
assert.equal(attackerDice(t), 6, '4 + Overclocked CPU only');
|
||||
});
|
||||
|
||||
card('Replication Routine', () => {
|
||||
|
|
@ -67,7 +67,7 @@ card('Resource Leech', () => {
|
|||
attackC1(t);
|
||||
t.rig(1, 1, 1, 1, 6, 6, 6, 6).end();
|
||||
assert.equal(t.avatar(0, 1).at, null);
|
||||
assert.equal(t.s.players[1].ram, 5);
|
||||
assert.equal(t.s.players[1].ram, 3);
|
||||
});
|
||||
|
||||
card('Worm Protocol', () => {
|
||||
|
|
@ -151,10 +151,10 @@ card('Race Condition', () => {
|
|||
});
|
||||
|
||||
card('Memory Leak', () => {
|
||||
const t = scene({ south: { main: ['Additional Core', 'RAM Expansion'] }, north: { main: ['Memory Leak'] } });
|
||||
const t = scene({ south: { main: ['Additional Core', 'Overclocked CPU'] }, north: { main: ['Memory Leak'] } });
|
||||
t.program(1, 'C1', 'Memory Leak');
|
||||
t.hardware(0, 1, 'Additional Core');
|
||||
t.hardware(0, 1, 'RAM Expansion');
|
||||
t.hardware(0, 1, 'Overclocked CPU');
|
||||
attackC1(t);
|
||||
t.rig(6, 6, 6, 6, 6, 1, 1, 1, 1).end();
|
||||
assert.equal(attackerDice(t), 5, '4 + 3 - 2 Hardware');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue