updates
This commit is contained in:
parent
5368464042
commit
937f44defe
100 changed files with 10185 additions and 2042 deletions
|
|
@ -2,13 +2,14 @@
|
|||
* Hardware. It works while its wearer is in play. "The occupied Server" is the location the
|
||||
* wearer stands on.
|
||||
*/
|
||||
import { describeArgs } from '../describe.ts';
|
||||
import { knockOut } from '../flow.ts';
|
||||
import { desynced, hardwareActive, portsFit, takesPort } from '../query.ts';
|
||||
import { desynced, hardwareActive, slotsFit, takesSlot } from '../query.ts';
|
||||
import { scriptOf, type Script } from '../scripts.ts';
|
||||
import {
|
||||
ask,
|
||||
avatar,
|
||||
avatarName,
|
||||
anomaly,
|
||||
anomalyName,
|
||||
defOf,
|
||||
fired,
|
||||
isCopy,
|
||||
|
|
@ -30,12 +31,12 @@ import {
|
|||
usedThisTurn,
|
||||
wearerOf,
|
||||
} from '../state.ts';
|
||||
import type { AvatarRef, GameState, LocationState, PlayerId, StackItem } from '../types.ts';
|
||||
import type { AnomalyRef, GameState, LocationState, PlayerId, StackItem } from '../types.ts';
|
||||
import { cardOptions, programsOn } from './util.ts';
|
||||
|
||||
/**
|
||||
* Uses a Hardware card has left this turn. Its "once per turn" or "first ... each turn" effect gets
|
||||
* one use, or two when Cooling System on the same Avatar picks it (Cooling helps one Hardware a turn).
|
||||
* one use, or two when Cooling System on the same Anomaly picks it (Cooling helps one Hardware a turn).
|
||||
*/
|
||||
export function hardwareUsesLeft(s: GameState, hw: number): number {
|
||||
const used = usedThisTurn(s, `hw:${hw}`);
|
||||
|
|
@ -46,7 +47,7 @@ export function hardwareUsesLeft(s: GameState, hw: number): number {
|
|||
function coolerFor(s: GameState, hw: number): number | null {
|
||||
const ref = wearerOf(s, hw);
|
||||
if (!ref) return null;
|
||||
for (const id of avatar(s, ref).hardware) {
|
||||
for (const id of anomaly(s, ref).hardware) {
|
||||
if (id === hw || s.cards[id].name !== 'Cooling System' || !hardwareActive(s, id)) continue;
|
||||
const pickedFor = s.used[`cool:${id}`];
|
||||
if (pickedFor === undefined || pickedFor === hw) return id;
|
||||
|
|
@ -55,16 +56,16 @@ function coolerFor(s: GameState, hw: number): number | null {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reading: an Avatar that loses a port (Network Interface Upgrade removed) discards Hardware until it
|
||||
* Reading: an Anomaly that loses an Expansion Slot (Network Interface Upgrade removed) discards Hardware until it
|
||||
* fits, the most recently installed first.
|
||||
*/
|
||||
export function shedHardware(s: GameState, r: AvatarRef): void {
|
||||
while (!portsFit(s, r)) {
|
||||
const hw = avatar(s, r).hardware.findLast((id) => takesPort(s, id))!;
|
||||
export function shedHardware(s: GameState, r: AnomalyRef): void {
|
||||
while (!slotsFit(s, r)) {
|
||||
const hw = anomaly(s, r).hardware.findLast((id) => takesSlot(s, id))!;
|
||||
uninstallHardware(s, hw);
|
||||
toDiscard(s, hw);
|
||||
stat(s, 'hardwareLost', r.player);
|
||||
say(s, `${avatarName(s, r)} is out of ports and discards ${nameOf(s, hw)}.`);
|
||||
say(s, `${anomalyName(s, r)} is out of Expansion Slots and discards ${nameOf(s, hw)}.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,13 +78,13 @@ export function useHardware(s: GameState, hw: number): void {
|
|||
}
|
||||
}
|
||||
|
||||
const wearing = (ref: AvatarRef | undefined, f: { ref: AvatarRef }) =>
|
||||
const wearing = (ref: AnomalyRef | undefined, f: { ref: AnomalyRef }) =>
|
||||
!!ref && ref.player === f.ref.player && (ref.slot === f.ref.slot || ref.slot + 4 === f.ref.slot);
|
||||
|
||||
/** Installs a Hardware card from its owner's hand onto an Avatar, without paying. */
|
||||
export function attachHardware(s: GameState, card: number, ref: AvatarRef): void {
|
||||
/** Installs a Hardware card from its owner's hand onto an Anomaly, without paying. */
|
||||
export function attachHardware(s: GameState, card: number, ref: AnomalyRef): void {
|
||||
removeFrom(s.players[ref.player].hand, card);
|
||||
avatar(s, ref).hardware.push(card);
|
||||
anomaly(s, ref).hardware.push(card);
|
||||
s.cards[card].installedTurn = s.turn;
|
||||
stat(s, 'hardwareInstalled', ref.player);
|
||||
played(s, nameOf(s, card), ref.player);
|
||||
|
|
@ -92,18 +93,18 @@ export function attachHardware(s: GameState, card: number, ref: AvatarRef): void
|
|||
export const HARDWARE: Record<string, Script> = {
|
||||
// Health rule: the wearer's Health goes up by 2 (query.ts healthOf). Without the rule it does nothing.
|
||||
'RAM Expansion': {
|
||||
text: 'Avatar gains +2 Health.',
|
||||
text: 'Anomaly gains +2 Health.',
|
||||
health: 2,
|
||||
},
|
||||
'Additional Core': {
|
||||
text: 'Avatar gains +1 Core.',
|
||||
text: 'Anomaly gains +1 Core.',
|
||||
cores: () => 1,
|
||||
},
|
||||
|
||||
// Reading: the Program is one on the location the wearer fought from, the owner picks it, and it
|
||||
// stays disabled through the end of the next turn.
|
||||
'Overclocked CPU': {
|
||||
text: 'Avatar gains +2 Cores during combat, but one installed Program at the current server becomes disabled afterward for 2 commands.',
|
||||
text: 'Anomaly gains +2 Cores during combat, but one installed Program at the current server becomes disabled afterward for 2 commands.',
|
||||
cores: (_s, _src, f) => (f.role !== null ? 2 : 0),
|
||||
onCombatEnd(s, src) {
|
||||
const c = s.combat!;
|
||||
|
|
@ -132,7 +133,7 @@ export const HARDWARE: Record<string, Script> = {
|
|||
},
|
||||
|
||||
'Solid-State Cache': {
|
||||
text: 'The first Program installed on the occupied Server each round costs 3 less RAM.',
|
||||
text: 'The first Program installed on the occupied Server each round costs 3 less Gb.',
|
||||
costMod: (s, src, pay) =>
|
||||
pay.kind === 'program' && pay.player === src.controller && pay.at === src.at && hardwareUsesLeft(s, src.id) > 0 ? -3 : 0,
|
||||
onPaid(s, src) {
|
||||
|
|
@ -144,36 +145,36 @@ export const HARDWARE: Record<string, Script> = {
|
|||
// Reading: the first time the wearer is defeated with this installed, all its Hardware stays on
|
||||
// it (in its slot) instead of being discarded.
|
||||
'Redundant Power Supply': {
|
||||
text: 'The first time this Avatar would be destroyed, do not destroy the Hardware.',
|
||||
text: 'The first time this Anomaly would be destroyed, do not destroy the Hardware.',
|
||||
savePriority: 0,
|
||||
onWearerDefeated(s, hw, ev) {
|
||||
if (s.cards[hw].spent) return false;
|
||||
s.cards[hw].spent = true;
|
||||
fired(s, 'Redundant Power Supply', ev.ref.player);
|
||||
say(s, `Redundant Power Supply: ${avatarName(s, ev.ref)} keeps its Hardware.`);
|
||||
say(s, `Redundant Power Supply: ${anomalyName(s, ev.ref)} keeps its Hardware.`);
|
||||
knockOut(s, ev.ref, ev.loc, ev.role, true);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
|
||||
// Ruling: it takes no port and adds one, so the wearer nets +1 Expansion Slot.
|
||||
// Ruling: it takes no Expansion Slot and adds one, so the wearer nets +1 Expansion Slot.
|
||||
'Network Interface Upgrade': {
|
||||
text: 'This Hardware can be played without taking an upgrade port on the Avatar.',
|
||||
noPort: true,
|
||||
text: 'This Hardware can be played without taking an Expansion Slot on the Anomaly.',
|
||||
noSlot: true,
|
||||
extraSlots: 1,
|
||||
},
|
||||
|
||||
// Ruling: Servers perform Executions, so this works for Executions performed by the Server the
|
||||
// wearer stands on. +1 to the number the Execution uses (cards drawn, Cores, RAM recovered).
|
||||
// wearer stands on. +1 to the number the Execution uses (cards drawn, Cores, Bandwidth recovered).
|
||||
'Dedicated GPU': {
|
||||
text: 'Executions performed by this Avatar receive +1 effectiveness or combat strength.',
|
||||
text: 'Executions performed by this Anomaly receive +1 effectiveness or combat strength.',
|
||||
executionPower: 1,
|
||||
},
|
||||
|
||||
// Blocks opponents' Bug counters (see addBugs in util.ts; no card places them yet) and their
|
||||
// Bug Program effects on the wearer (Memory Leak, Stock Rice).
|
||||
// Bug Program effects on the wearer (Bloatware, Stock Rice).
|
||||
'ECC Memory': {
|
||||
text: 'Opponents cannot place Bug counters or Bug status effects on this Avatar.',
|
||||
text: 'Opponents cannot place Bug counters or Bug status effects on this Anomaly.',
|
||||
bugImmunity: true,
|
||||
},
|
||||
|
||||
|
|
@ -182,19 +183,19 @@ export const HARDWARE: Record<string, Script> = {
|
|||
text: 'Allow one Hardware to activate twice per round.',
|
||||
},
|
||||
|
||||
// Reading: half the combined printed RAM of its Hardware, rounded up.
|
||||
// Reading: half the combined printed Bandwidth of its Hardware, rounded up.
|
||||
'RAID Array': {
|
||||
text: 'When this Avatar is destroyed, all hardware can be kept by paying half the RAM cost.',
|
||||
text: 'When this Anomaly is destroyed, all hardware can be kept by paying half the Bandwidth cost.',
|
||||
savePriority: 1,
|
||||
onWearerDefeated(s, hw, ev) {
|
||||
const av = avatar(s, ev.ref);
|
||||
const cost = Math.ceil(av.hardware.reduce((t, h) => t + defOf(s, h).ram, 0) / 2);
|
||||
const av = anomaly(s, ev.ref);
|
||||
const cost = Math.ceil(av.hardware.reduce((t, h) => t + defOf(s, h).bandwidth, 0) / 2);
|
||||
ask(s, {
|
||||
player: ev.ref.player,
|
||||
kind: 'RAID Array:keep',
|
||||
prompt: `RAID Array: pay ${cost} RAM to keep ${av.hardware.map((h) => nameOf(s, h)).join(', ')}?`,
|
||||
prompt: `RAID Array: pay ${cost} Gb to keep ${av.hardware.map((h) => nameOf(s, h)).join(', ')}?`,
|
||||
options: [
|
||||
{ label: `Keep all Hardware for ${cost} RAM`, value: true, cost },
|
||||
{ label: `Keep all Hardware for ${cost} Gb`, value: true, cost },
|
||||
{ label: 'Lose the Hardware', value: false },
|
||||
],
|
||||
resume: { name: 'RAID Array', fn: 'keep', data: { ref: ev.ref as never, loc: ev.loc, role: ev.role, cost } },
|
||||
|
|
@ -202,10 +203,10 @@ export const HARDWARE: Record<string, Script> = {
|
|||
return true;
|
||||
},
|
||||
resume: {
|
||||
keep(s, data: { ref: AvatarRef; loc: string; role: 'attack' | 'defend'; cost: number }, keep: boolean) {
|
||||
keep(s, data: { ref: AnomalyRef; loc: string; role: 'attack' | 'defend'; cost: number }, keep: boolean) {
|
||||
if (keep) {
|
||||
s.players[data.ref.player].ram -= data.cost;
|
||||
stat(s, 'ramOnCards', data.ref.player, data.cost);
|
||||
s.players[data.ref.player].bandwidth -= data.cost;
|
||||
stat(s, 'bandwidthOnCards', data.ref.player, data.cost);
|
||||
fired(s, 'RAID Array', data.ref.player);
|
||||
}
|
||||
knockOut(s, data.ref, data.loc, data.role, keep);
|
||||
|
|
@ -214,13 +215,13 @@ export const HARDWARE: Record<string, Script> = {
|
|||
},
|
||||
|
||||
'Packet Accelerator': {
|
||||
text: 'This Avatar gains +1 Core hen attacking.',
|
||||
text: 'This Anomaly gains +1 Core hen attacking.',
|
||||
cores: (_s, _src, f) => (f.role === 'attack' ? 1 : 0),
|
||||
},
|
||||
|
||||
// Programs never target Avatars, so this taxes Executions (and Hardware they hit).
|
||||
// Programs never target Anomalies, so this taxes Executions (and Hardware they hit).
|
||||
'Firewall Appliance': {
|
||||
text: 'The first hostile Program or Execution targeting this Avatar each round costs the opponent +3 RAM.',
|
||||
text: 'The first hostile Program or Execution targeting this Anomaly each round costs the opponent +3 Gb.',
|
||||
costMod: (s, src, pay) =>
|
||||
pay.kind === 'execution' && pay.player !== src.controller && hardwareUsesLeft(s, src.id) > 0 &&
|
||||
(pay.hostile ?? []).some((r) => wearing(src.ref, { ref: r })) ? 3 : 0,
|
||||
|
|
@ -262,6 +263,7 @@ export const HARDWARE: Record<string, Script> = {
|
|||
ask(s, {
|
||||
player: src.controller,
|
||||
kind: 'Diagnostic Module:bottom',
|
||||
secret: true,
|
||||
prompt: `Diagnostic Module: the top card of your deck is ${nameOf(s, deck[0])}. Put it on the bottom?`,
|
||||
options: [
|
||||
{ label: `Keep ${nameOf(s, deck[0])} on top`, value: false },
|
||||
|
|
@ -278,44 +280,44 @@ export const HARDWARE: Record<string, Script> = {
|
|||
},
|
||||
},
|
||||
|
||||
// Reading: swap Hardware on this Avatar, paying the difference in printed RAM (no refund).
|
||||
// Reading: swap Hardware on this Anomaly, paying the difference in printed Bandwidth (no refund).
|
||||
'Hot-Swap Bay': {
|
||||
text: 'Once per round, return one Hardware to your hand and install another Hardware from your hand, paying the difference in cost.',
|
||||
ability: {
|
||||
hardwareOncePerTurn: true,
|
||||
uses(s, src) {
|
||||
const av = avatar(s, src.ref!);
|
||||
const av = anomaly(s, src.ref!);
|
||||
const hand = s.players[src.controller].hand.filter((id) => defOf(s, id).kind === 'hardware');
|
||||
return av.hardware.flatMap((out) => cardOptions(s, hand)
|
||||
.filter((o) => portsFit(s, src.ref!, out, o.value as number))
|
||||
.filter((o) => slotsFit(s, src.ref!, out, o.value as number))
|
||||
.map((o) => ({ card: out, cards: [o.value as number] })));
|
||||
},
|
||||
extraCost: (s, _src, args) => Math.max(0, defOf(s, args.cards![0]).ram - defOf(s, args.card!).ram),
|
||||
extraCost: (s, _src, args) => Math.max(0, defOf(s, args.cards![0]).bandwidth - defOf(s, args.card!).bandwidth),
|
||||
resolve(s, item, src) {
|
||||
const out = item.args.card!;
|
||||
const into = item.args.cards![0];
|
||||
const ref = src.ref!;
|
||||
if (!avatar(s, ref).hardware.includes(out) || !s.players[src.controller].hand.includes(into)) return;
|
||||
if (!portsFit(s, ref, out, into)) return;
|
||||
if (!anomaly(s, ref).hardware.includes(out) || !s.players[src.controller].hand.includes(into)) return;
|
||||
if (!slotsFit(s, ref, out, into)) return;
|
||||
uninstallHardware(s, out);
|
||||
toHand(s, out);
|
||||
attachHardware(s, into, ref);
|
||||
fired(s, 'Hot-Swap Bay', src.controller);
|
||||
say(s, `Hot-Swap Bay swaps ${nameOf(s, out)} for ${nameOf(s, into)} on ${avatarName(s, ref)}.`);
|
||||
say(s, `Hot-Swap Bay swaps ${nameOf(s, out)} for ${nameOf(s, into)} on ${anomalyName(s, ref)}.`);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Ruling: Servers perform Executions, so "this Avatar uses an Execution" means one performed by
|
||||
// Ruling: Servers perform Executions, so "this Anomaly uses an Execution" means one performed by
|
||||
// the Server the wearer stands on. "Disable this Hardware" lasts until your next turn.
|
||||
'Quantum Coprocessor': {
|
||||
text: "Once per round when this Avatar uses an Execution, you may copy that Execution's effect with a different legal target, then disable this Hardware.",
|
||||
text: "Once per round when this Anomaly uses an Execution, you may copy that Execution's effect with a different legal target, then disable this Hardware.",
|
||||
copiesExecutions: true,
|
||||
resume: {
|
||||
offer(s, data: { item: StackItem }) {
|
||||
const item = data.item;
|
||||
const wearers = refsInPlay(s, item.player).filter((r) => !isCopy(r) && avatar(s, r).at === item.from && !desynced(s, r));
|
||||
const qc = wearers.flatMap((r) => avatar(s, r).hardware)
|
||||
const wearers = refsInPlay(s, item.player).filter((r) => !isCopy(r) && anomaly(s, r).at === item.from && !desynced(s, r));
|
||||
const qc = wearers.flatMap((r) => anomaly(s, r).hardware)
|
||||
.find((hw) => s.cards[hw].name === 'Quantum Coprocessor' && hardwareActive(s, hw) && hardwareUsesLeft(s, hw) > 0);
|
||||
if (qc === undefined) return;
|
||||
const ex = scriptOf(item.name)?.execution;
|
||||
|
|
@ -329,7 +331,7 @@ export const HARDWARE: Record<string, Script> = {
|
|||
prompt: `Quantum Coprocessor: copy ${item.name} with a different target?`,
|
||||
options: [
|
||||
{ label: "Don't copy", value: null },
|
||||
...plays.map((p) => ({ label: `${p.target ?? 'no target'} ${describeArgs(s, p.args)}`, value: { target: p.target, args: p.args as never } })),
|
||||
...plays.map((p) => ({ label: `${p.target ?? 'no target'} ${describeArgs(s, p.args, item.player)}`, value: { target: p.target, args: p.args as never } })),
|
||||
],
|
||||
resume: { name: 'Quantum Coprocessor', fn: 'copy', data: { item: item as never, qc } },
|
||||
});
|
||||
|
|
@ -346,15 +348,6 @@ export const HARDWARE: Record<string, Script> = {
|
|||
},
|
||||
};
|
||||
|
||||
function describeArgs(s: GameState, a: StackItem['args']): string {
|
||||
const parts: string[] = [];
|
||||
if (a.ref) parts.push(avatarName(s, a.ref));
|
||||
if (a.card !== undefined) parts.push(nameOf(s, a.card));
|
||||
if (a.to) parts.push(`→ ${a.to}`);
|
||||
if (a.mode) parts.push(a.mode);
|
||||
return parts.join(' ');
|
||||
}
|
||||
|
||||
function disableForTwoTurns(s: GameState, id: number): void {
|
||||
s.cards[id].disabledUntil = Math.max(s.cards[id].disabledUntil, endOf(s.turn + 1));
|
||||
say(s, `Overclocked CPU: ${nameOf(s, id)} is disabled for 2 turns.`);
|
||||
|
|
@ -362,7 +355,7 @@ function disableForTwoTurns(s: GameState, id: number): void {
|
|||
|
||||
function askSandbox(s: GameState, card: number): void {
|
||||
const ref = wearerOf(s, card);
|
||||
const at = ref ? avatar(s, ref).at : null;
|
||||
const at = ref ? anomaly(s, ref).at : null;
|
||||
if (!ref || !at) return;
|
||||
const progs = (s.locations[at] as LocationState).programs.filter((id) => ownerOf(s, id) === ref.player);
|
||||
if (progs.length === 0) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue