updates
This commit is contained in:
parent
5368464042
commit
937f44defe
100 changed files with 10185 additions and 2042 deletions
|
|
@ -3,25 +3,25 @@
|
|||
* directly and drive decisions one at a time.
|
||||
*/
|
||||
import assert from 'node:assert/strict';
|
||||
import { loadCards } from '../src/cards.ts';
|
||||
import { loadCards } from '../src/load.ts';
|
||||
import { actionKey, applyAction, createGame, decider, legalActions, openWindow } from '../src/engine.ts';
|
||||
import { checkInvariants } from '../src/invariants.ts';
|
||||
import type { LocId } from '../src/map.ts';
|
||||
import { coresOf, fighterOf, sideCores } from '../src/query.ts';
|
||||
import { DEFAULT_RULES, type RulesConfig } from '../src/rules.ts';
|
||||
import { avatar, removeFrom } from '../src/state.ts';
|
||||
import type { Action, Args, AvatarRef, GameState, PlayerId } from '../src/types.ts';
|
||||
import { anomaly, logFor, removeFrom } from '../src/state.ts';
|
||||
import type { Action, Args, AnomalyRef, GameState, PlayerId } from '../src/types.ts';
|
||||
|
||||
export const pool = loadCards();
|
||||
|
||||
/** Cards that do nothing in hand and can't be played in response, used to pad decks. */
|
||||
const FILLER = 'Network Interface Upgrade';
|
||||
const PLAIN_SERVER = 'Network Throttle';
|
||||
/** Avatars whose Abilities only work in combat, so they don't open response windows. */
|
||||
const DEFAULT_AVATARS = ['Broken Bits', 'Pixelated Picture', 'Corrupt Driver', 'Code Zero'];
|
||||
/** Anomalies whose Abilities only work in combat, so they don't open response windows. */
|
||||
const DEFAULT_ANOMALIES = ['Broken Bits', 'Pixelated Picture', 'Corrupt Driver', 'Code Zero'];
|
||||
|
||||
export interface Side {
|
||||
avatars?: string[];
|
||||
anomalies?: string[];
|
||||
servers?: string[];
|
||||
main?: string[];
|
||||
}
|
||||
|
|
@ -31,12 +31,12 @@ export class Table {
|
|||
|
||||
constructor(o: { south?: Side; north?: Side; first?: PlayerId; seed?: number; health?: boolean } = {}) {
|
||||
const side = (x: Side = {}) => ({
|
||||
avatars: x.avatars ?? DEFAULT_AVATARS,
|
||||
anomalies: x.anomalies ?? DEFAULT_ANOMALIES,
|
||||
servers: [...(x.servers ?? []), ...Array(12).fill(PLAIN_SERVER)],
|
||||
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), no turn-1 draw for the first player, and
|
||||
// Classic turns (one turn each, every Anomaly 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 = {
|
||||
|
|
@ -45,7 +45,7 @@ export class Table {
|
|||
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 },
|
||||
deck: { anomalies: 4, servers: decks[0].servers.length, main: decks[0].main.length, maxCopies: 99 },
|
||||
};
|
||||
// Both decks must be the same size under one rules object; pad the shorter one.
|
||||
const n = Math.max(decks[0].main.length, decks[1].main.length);
|
||||
|
|
@ -65,10 +65,10 @@ export class Table {
|
|||
const L = this.s.locations[start];
|
||||
this.s.players[p].serverPile.push(L.server!);
|
||||
L.server = this.take(p, PLAIN_SERVER);
|
||||
this.s.players[p].ram = 0;
|
||||
// Avatars in the order given, slot 1 face up.
|
||||
const want = (p === 0 ? o.south : o.north)?.avatars ?? DEFAULT_AVATARS;
|
||||
const avs = this.s.players[p].avatars;
|
||||
this.s.players[p].bandwidth = 0;
|
||||
// Anomalies in the order given, slot 1 face up.
|
||||
const want = (p === 0 ? o.south : o.north)?.anomalies ?? DEFAULT_ANOMALIES;
|
||||
const avs = this.s.players[p].anomalies;
|
||||
want.forEach((name, i) => {
|
||||
const j = avs.findIndex((a, k) => k < 4 && k >= i && this.s.cards[a.card].name === name);
|
||||
[avs[i].card, avs[j].card] = [avs[j].card, avs[i].card];
|
||||
|
|
@ -116,8 +116,8 @@ export class Table {
|
|||
return id;
|
||||
}
|
||||
|
||||
ram(p: PlayerId, n: number): this {
|
||||
this.s.players[p].ram = n;
|
||||
bandwidth(p: PlayerId, n: number): this {
|
||||
this.s.players[p].bandwidth = n;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -130,9 +130,9 @@ export class Table {
|
|||
return L.server;
|
||||
}
|
||||
|
||||
/** Puts Avatar `slot` of `p` in play on `at` (face up). */
|
||||
place(p: PlayerId, slot: number, at: LocId): AvatarRef {
|
||||
const av = this.s.players[p].avatars[slot - 1];
|
||||
/** Puts Anomaly `slot` of `p` in play on `at` (face up). */
|
||||
place(p: PlayerId, slot: number, at: LocId): AnomalyRef {
|
||||
const av = this.s.players[p].anomalies[slot - 1];
|
||||
av.faceUp = true;
|
||||
av.at = at;
|
||||
return { player: p, slot };
|
||||
|
|
@ -146,7 +146,7 @@ export class Table {
|
|||
|
||||
hardware(p: PlayerId, slot: number, name: string): number {
|
||||
const id = this.take(p, name);
|
||||
this.s.players[p].avatars[slot - 1].hardware.push(id);
|
||||
this.s.players[p].anomalies[slot - 1].hardware.push(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ export class Table {
|
|||
return this.act({ type: 'play', card, target, args, from });
|
||||
}
|
||||
|
||||
/** Activates the ability of the card `id` (an Avatar's card id, a Program or Hardware). */
|
||||
/** Activates the ability of the card `id` (an Anomaly's card id, a Program or Hardware). */
|
||||
use(id: number, args: Args = {}): this {
|
||||
return this.act({ type: 'activate', card: id, name: this.s.cards[id].name, args });
|
||||
}
|
||||
|
|
@ -220,8 +220,8 @@ export class Table {
|
|||
// -------------------------------------------------------------------------------------------
|
||||
// Reading
|
||||
|
||||
avatar(p: PlayerId, slot: number) {
|
||||
return avatar(this.s, { player: p, slot });
|
||||
anomaly(p: PlayerId, slot: number) {
|
||||
return anomaly(this.s, { player: p, slot });
|
||||
}
|
||||
|
||||
cores(p: PlayerId, slot: number): number {
|
||||
|
|
@ -239,6 +239,6 @@ export class Table {
|
|||
}
|
||||
|
||||
logText(): string {
|
||||
return (this.s.log ?? []).join('\n');
|
||||
return logFor(this.s, null).join('\n');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue