updates
This commit is contained in:
parent
e590baf28d
commit
6382de19c9
15 changed files with 239 additions and 28 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* wearer stands on.
|
||||
*/
|
||||
import { knockOut } from '../flow.ts';
|
||||
import { desynced, hardwareActive } from '../query.ts';
|
||||
import { desynced, hardwareActive, portsFit, takesPort } from '../query.ts';
|
||||
import { scriptOf, type Script } from '../scripts.ts';
|
||||
import {
|
||||
ask,
|
||||
|
|
@ -24,6 +24,7 @@ import {
|
|||
startOf,
|
||||
endOf,
|
||||
stat,
|
||||
toDiscard,
|
||||
toHand,
|
||||
uninstallHardware,
|
||||
usedThisTurn,
|
||||
|
|
@ -53,6 +54,20 @@ function coolerFor(s: GameState, hw: number): number | null {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading: an Avatar that loses a port (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))!;
|
||||
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)}.`);
|
||||
}
|
||||
}
|
||||
|
||||
export function useHardware(s: GameState, hw: number): void {
|
||||
const cooler = coolerFor(s, hw);
|
||||
markUsed(s, `hw:${hw}`);
|
||||
|
|
@ -271,7 +286,9 @@ export const HARDWARE: Record<string, Script> = {
|
|||
uses(s, src) {
|
||||
const av = avatar(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).map((o) => ({ card: out, cards: [o.value as number] })));
|
||||
return av.hardware.flatMap((out) => cardOptions(s, hand)
|
||||
.filter((o) => portsFit(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),
|
||||
resolve(s, item, src) {
|
||||
|
|
@ -279,6 +296,7 @@ export const HARDWARE: Record<string, Script> = {
|
|||
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;
|
||||
uninstallHardware(s, out);
|
||||
toHand(s, out);
|
||||
attachHardware(s, into, ref);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue