init
This commit is contained in:
commit
0cba7f5ee0
385 changed files with 17912 additions and 0 deletions
271
engine/cards/anomalies.gd
Normal file
271
engine/cards/anomalies.gd
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
class_name AnomalyCards
|
||||
## Anomaly Abilities (cards/anomalies.ts). Each costs the Bandwidth printed on the card, can be used
|
||||
## once per turn at Execution timing, and only while the Anomaly is in play. For Abilities, "a combat
|
||||
## at this Server" means any combat the Anomaly is fighting in, attacking or defending.
|
||||
|
||||
|
||||
## Hardware cost after discounts (Upgraded Hardware), for Abilities that install Hardware.
|
||||
static func _install_cost(s: Dictionary, card: int, r: Dictionary) -> int:
|
||||
return Query.cost_of(s, {"kind": "hardware", "player": r.player, "card": card, "ref": r, "at": State.anomaly(s, r).at})
|
||||
|
||||
|
||||
static func scripts() -> Dictionary:
|
||||
return {
|
||||
# The copy has the same Cores and uses the original's Hardware bonuses, but no Hardware or
|
||||
# Ability of its own. It enters play on a location you control with room.
|
||||
"Carbon NanoBots": {
|
||||
"text": "Anomaly may create a copy of itself. Only one copy is allowed at a time. If the copy is defeated the original does not lose any hardware upgrades. If the original is defeated the replicate is as well.",
|
||||
"ability": {"uses": _nanobots_uses, "resolve": _nanobots_resolve},
|
||||
},
|
||||
|
||||
"Corrupt Driver": {
|
||||
"text": "Choose one Hardware on an enemy Anomaly in combat with this Anomaly. It is disabled until the end of your next command.",
|
||||
"ability": {"uses": _driver_uses, "resolve": _driver_resolve},
|
||||
},
|
||||
|
||||
"Pixelated Picture": {
|
||||
"text": "Attacking Anomalies have -1 cores against this Anomaly.",
|
||||
"ability": {"uses": _pixelated_uses, "resolve": _pixelated_resolve},
|
||||
},
|
||||
|
||||
# Reading: during a combat it's in, install one Hardware from hand on it (paying its cost),
|
||||
# ignoring Expansion Slots. That Hardware is discarded at the end of your turn.
|
||||
"Beta Version 1.0": {
|
||||
"text": "While in combat an additional piece of hardware can be placed on this anomaly until the end of your command. If there are no Expansion Slots available this can still be attached.",
|
||||
"ability": {
|
||||
"uses": _beta_uses,
|
||||
"extraCost": func(s, src, args): return _install_cost(s, args.card, src.ref),
|
||||
"resolve": _beta_resolve,
|
||||
},
|
||||
},
|
||||
|
||||
"Code Zero": {
|
||||
"text": "Place an Infection counter on every enemy Anomaly in combat at this Server. While this Anomaly is in play, an Anomaly with 1+ Infection counters has -1 Core.",
|
||||
"globalCores": func(s, f): return -1 if State.infection_of(State.anomaly(s, f.ref)) >= 1 else 0,
|
||||
"ability": {
|
||||
"uses": func(s, src): return [{}] if not State.opponents_in_combat(s, src.ref).is_empty() else [],
|
||||
"resolve": _code_zero_resolve,
|
||||
},
|
||||
},
|
||||
|
||||
# "Breached a Server" = captured an enemy location this turn.
|
||||
"Data Leaker": {
|
||||
"text": "Look at your opponent's hand and choose one card in it. They must discard that card without gaining Bandwidth. If this Anomaly breached a Server this command, draw a card.",
|
||||
"ability": {
|
||||
"uses": func(s, src): return [{}] if not s.players[State.other(src.controller)].hand.is_empty() else [],
|
||||
"resolve": _leaker_resolve,
|
||||
},
|
||||
"resume": {"discard": _leaker_discard},
|
||||
},
|
||||
|
||||
# Restore Point either heals 3 damage (health rule) or recovers a card from the discard pile.
|
||||
"Backup Machine": {
|
||||
"text": "Remove 3 damage from this Anomaly, or return one Hardware or Program from your discard pile to your hand. If it is a Hardware and this Anomaly has an open Expansion Slot, you may install it immediately for 2 less Gb.",
|
||||
"ability": {"uses": _backup_uses, "resolve": _backup_resolve},
|
||||
"resume": {"install": _backup_install},
|
||||
},
|
||||
|
||||
# Rerolls this Anomaly's dice showing k or less; that's always the best way to pick dice.
|
||||
"Broken Bits": {
|
||||
"text": "During a combat at this Server, reroll any number of this Anomaly's Core dice.",
|
||||
"ability": {"uses": _bits_uses, "resolve": _bits_resolve},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Carbon NanoBots
|
||||
|
||||
static func _nanobots_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
if State.anomaly(s, State.copy_of(src.ref)).at != null or not Query.can_copy(s, src.controller):
|
||||
return []
|
||||
var out := []
|
||||
for l in GameMap.LOCATIONS:
|
||||
if Query.has_room(s, src.controller, l):
|
||||
out.append({"to": l})
|
||||
return out
|
||||
|
||||
|
||||
static func _nanobots_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var to: String = item.args.to
|
||||
if State.anomaly(s, State.copy_of(src.ref)).at != null or not Query.can_copy(s, src.controller) \
|
||||
or not Query.has_room(s, src.controller, to):
|
||||
return
|
||||
State.fired(s, "Carbon NanoBots", src.controller)
|
||||
Flow.create_copy(s, src.ref, to)
|
||||
|
||||
|
||||
# Corrupt Driver
|
||||
|
||||
static func _driver_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
var hws := []
|
||||
for r in State.opponents_in_combat(s, src.ref):
|
||||
hws.append_array(State.hardware_of(s, r))
|
||||
var out := []
|
||||
for hw in Util.uniq(hws):
|
||||
if Query.hardware_active(s, hw):
|
||||
out.append({"card": hw})
|
||||
return out
|
||||
|
||||
|
||||
static func _driver_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var hw: int = item.args.card
|
||||
s.cards[hw].disabledUntil = maxi(s.cards[hw].disabledUntil, State.end_of(State.next_turn_of(s, src.controller)))
|
||||
State.fired(s, "Corrupt Driver", src.controller)
|
||||
State.say(s, "Driver Fault disables %s until the end of %s's next turn." % [State.name_of(s, hw), State.player_name(src.controller)])
|
||||
|
||||
|
||||
# Pixelated Picture
|
||||
|
||||
static func _pixelated_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
if not State.in_combat(s, src.ref):
|
||||
return []
|
||||
for d in s.combat.defenders:
|
||||
if State.ref_key(d) == State.ref_key(src.ref):
|
||||
return [{}]
|
||||
return []
|
||||
|
||||
|
||||
static func _pixelated_resolve(s: Dictionary, _item: Dictionary, src: Dictionary) -> void:
|
||||
var c = s.combat
|
||||
if c == null or c.ended:
|
||||
return
|
||||
State.add_mod(s, c.attacker, -1, "Low Resolution", src.controller, {"combat": c.id})
|
||||
State.fired(s, "Pixelated Picture", src.controller)
|
||||
State.say(s, "Low Resolution: %s gets -1 Core." % State.anomaly_name(s, c.attacker))
|
||||
|
||||
|
||||
# Beta Version 1.0
|
||||
|
||||
static func _beta_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
if not State.in_combat(s, src.ref):
|
||||
return []
|
||||
var hand: Array = s.players[src.controller].hand.filter(func(id): return State.def_of(s, id).kind == "hardware")
|
||||
return CardUtil.card_options(s, hand).map(func(o): return {"card": o.value})
|
||||
|
||||
|
||||
static func _beta_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if not s.players[src.controller].hand.has(card) or not State.in_combat(s, src.ref):
|
||||
return
|
||||
HardwareCards.attach_hardware(s, card, src.ref)
|
||||
var turn: int = s.turn if s.active == src.controller else State.next_turn_of(s, src.controller)
|
||||
s.cards[card].pushedUntil = State.end_of(turn)
|
||||
State.fired(s, "Beta Version 1.0", src.controller)
|
||||
State.say(s, "Push Update attaches %s to %s until the end of %s's turn." % [State.name_of(s, card), State.anomaly_name(s, src.ref), State.player_name(src.controller)])
|
||||
|
||||
|
||||
# Code Zero
|
||||
|
||||
static func _code_zero_resolve(s: Dictionary, _item: Dictionary, src: Dictionary) -> void:
|
||||
var foes := State.opponents_in_combat(s, src.ref)
|
||||
for r in foes:
|
||||
State.anomaly(s, r).infection += 1
|
||||
State.fired(s, "Code Zero", src.controller)
|
||||
var names := ", ".join(foes.map(func(r): return "%s (%d)" % [State.anomaly_name(s, r), State.infection_of(State.anomaly(s, r))]))
|
||||
State.say(s, "Patient Zero infects %s." % names)
|
||||
|
||||
|
||||
# Data Leaker
|
||||
|
||||
static func _leaker_resolve(s: Dictionary, _item: Dictionary, src: Dictionary) -> void:
|
||||
var hand: Array = s.players[State.other(src.controller)].hand
|
||||
if hand.is_empty():
|
||||
return
|
||||
State.fired(s, "Data Leaker", src.controller)
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Data Leaker:discard",
|
||||
"prompt": "Exfiltrate: choose a card from your opponent's hand for them to discard.",
|
||||
"options": CardUtil.card_options(s, hand),
|
||||
"resume": {"name": "Data Leaker", "fn": "discard", "data": {"ref": src.ref}},
|
||||
})
|
||||
|
||||
|
||||
static func _leaker_discard(s: Dictionary, data: Dictionary, card: Variant) -> void:
|
||||
var p: int = data.ref.player
|
||||
if State.remove_from(s.players[State.other(p)].hand, card):
|
||||
State.to_discard(s, card)
|
||||
State.say(s, "Exfiltrate: %s discards %s." % [State.player_name(State.other(p)), State.name_of(s, card)])
|
||||
if State.anomaly(s, data.ref).breachedTurn == s.turn:
|
||||
Flow.draw_cards(s, p, 1)
|
||||
|
||||
|
||||
# Backup Machine
|
||||
|
||||
static func _backup_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
var out := []
|
||||
if s.rules.health.on and State.anomaly(s, src.ref).damage > 0:
|
||||
out.append({"heal": true})
|
||||
var discard: Array = s.players[src.controller].discard.filter(func(id): return ["hardware", "program"].has(State.def_of(s, id).kind))
|
||||
for o in CardUtil.card_options(s, discard):
|
||||
out.append({"card": o.value})
|
||||
return out
|
||||
|
||||
|
||||
static func _backup_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var p: int = src.controller
|
||||
if item.args.get("heal", false):
|
||||
var av := State.anomaly(s, src.ref)
|
||||
if av.at == null or av.damage == 0:
|
||||
return
|
||||
var healed := mini(3, av.damage)
|
||||
av.damage -= healed
|
||||
State.fired(s, "Backup Machine", p)
|
||||
State.say(s, "Restore Point heals %d damage on %s." % [healed, State.anomaly_name(s, src.ref)])
|
||||
return
|
||||
var card: int = item.args.card
|
||||
if not State.remove_from(s.players[p].discard, card):
|
||||
return
|
||||
State.to_hand(s, card)
|
||||
State.fired(s, "Backup Machine", p)
|
||||
State.say(s, "Restore Point returns %s to %s's hand." % [State.name_of(s, card), State.player_name(p)])
|
||||
if State.def_of(s, card).kind != "hardware" or Query.slots_free(s, src.ref) <= 0:
|
||||
return
|
||||
var cost := maxi(0, _install_cost(s, card, src.ref) - 2)
|
||||
State.ask(s, {
|
||||
"player": p,
|
||||
"kind": "Backup Machine:install",
|
||||
"prompt": "Restore Point: install %s on %s now for %d Gb?" % [State.name_of(s, card), State.anomaly_name(s, src.ref), cost],
|
||||
"options": [
|
||||
{"label": "Keep it in hand", "value": false},
|
||||
{"label": "Install it for %d Gb" % cost, "value": true, "cost": cost},
|
||||
],
|
||||
"resume": {"name": "Backup Machine", "fn": "install", "data": {"card": card, "ref": src.ref, "cost": cost}},
|
||||
})
|
||||
|
||||
|
||||
static func _backup_install(s: Dictionary, data: Dictionary, yes: Variant) -> void:
|
||||
if not yes or State.anomaly(s, data.ref).at == null or not s.players[data.ref.player].hand.has(data.card):
|
||||
return
|
||||
s.players[data.ref.player].bandwidth -= data.cost
|
||||
s.stats.bandwidthOnCards[data.ref.player] += data.cost
|
||||
HardwareCards.attach_hardware(s, data.card, data.ref)
|
||||
State.say(s, "%s is installed on %s." % [State.name_of(s, data.card), State.anomaly_name(s, data.ref)])
|
||||
|
||||
|
||||
# Broken Bits
|
||||
|
||||
static func _bits_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
var c = s.combat
|
||||
if c == null or c.ended or not c.rolled or not State.in_combat(s, src.ref):
|
||||
return []
|
||||
var dice: Array = c.dice.get(State.ref_key(src.ref), [])
|
||||
var ks: Array = Util.uniq(dice).filter(func(v): return v < 6)
|
||||
ks.sort()
|
||||
return ks.map(func(k): return {"k": k})
|
||||
|
||||
|
||||
static func _bits_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var c = s.combat
|
||||
if c == null or c.ended or not c.rolled:
|
||||
return
|
||||
var key := State.ref_key(src.ref)
|
||||
var before: Array = c.dice.get(key, []).duplicate()
|
||||
var k: int = item.args.k
|
||||
var after := []
|
||||
for v in before:
|
||||
after.append(State.roll_die(s) if v <= k else v)
|
||||
c.dice[key] = after
|
||||
State.fired(s, "Broken Bits", src.controller)
|
||||
var rerolled := before.filter(func(v): return v <= k).size()
|
||||
State.say(s, "Bit Flip rerolls %d dice: [%s] → [%s]." % [rerolled, ",".join(before.map(func(v): return str(v))), ",".join(after.map(func(v): return str(v)))])
|
||||
1
engine/cards/anomalies.gd.uid
Normal file
1
engine/cards/anomalies.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ch4bumb8x8y5x
|
||||
598
engine/cards/executions.gd
Normal file
598
engine/cards/executions.gd
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
class_name ExecutionCards
|
||||
## Executions (cards/executions.ts). Each targets a location (the "target Server") and resolves there,
|
||||
## then goes to the discard pile. Ghost Process lets its controller's Executions reach one adjacent
|
||||
## location too.
|
||||
|
||||
|
||||
static func _live_combat(s: Dictionary) -> Variant:
|
||||
return s.combat if s.combat != null and not s.combat.ended else null
|
||||
|
||||
|
||||
## Unique Anomaly refs, first seen first.
|
||||
static func _uniq_refs(refs: Array) -> Array:
|
||||
var seen := {}
|
||||
var out := []
|
||||
for r in refs:
|
||||
var k := State.ref_key(r)
|
||||
if not seen.has(k):
|
||||
seen[k] = true
|
||||
out.append(r)
|
||||
return out
|
||||
|
||||
|
||||
## Plays for every target whose reach includes a location, with the args `args_at(loc)` allows there.
|
||||
static func _across_scope(s: Dictionary, p: int, args_at: Callable) -> Array:
|
||||
var out := []
|
||||
var ghosts := CardUtil.ghosts_of(s, p)
|
||||
var at := {}
|
||||
for target in GameMap.LOCATIONS:
|
||||
for loc in CardUtil.scope_of(s, p, target, ghosts):
|
||||
if not at.has(loc):
|
||||
at[loc] = args_at.call(loc)
|
||||
for args in at[loc]:
|
||||
out.append({"target": target, "args": args})
|
||||
return out
|
||||
|
||||
|
||||
static func _wearer_list(s: Dictionary, hw: Variant) -> Array:
|
||||
var r = State.wearer_of(s, hw) if hw != null else null
|
||||
return [r] if r != null else []
|
||||
|
||||
|
||||
static func _ref_target(_s: Dictionary, item: Dictionary) -> Array:
|
||||
return [item.args.ref] if item.args.get("ref") != null else []
|
||||
|
||||
|
||||
static func _draw_n(s: Dictionary, p: int, n: int) -> void:
|
||||
Flow.draw_cards(s, p, n)
|
||||
|
||||
|
||||
static func _has_negatives(s: Dictionary, r: Dictionary) -> bool:
|
||||
var av := State.anomaly(s, r)
|
||||
if av.infection > 0 or av.permanentInfection > 0 or State.running(s, av.rootedUntil) or State.running(s, av.disabledUntil):
|
||||
return true
|
||||
for m in State.active_mods(s, av):
|
||||
if m.cores < 0:
|
||||
return true
|
||||
for hw in State.hardware_of(s, r):
|
||||
if not Query.hardware_active(s, hw):
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
static func scripts() -> Dictionary:
|
||||
return {
|
||||
# Reading: the Anomaly moves to a location you control with room. An attacker "at" the target
|
||||
# (attacking it) can retreat back to where it stands.
|
||||
"Execute: Disconnect": {
|
||||
"text": "Move one Anomaly you control at the target Server to an adjacent Server, removing it from any combat there.",
|
||||
"execution": {"plays": _disconnect_plays, "targetsAnomalies": _ref_target, "resolve": _disconnect_resolve},
|
||||
},
|
||||
|
||||
# Reading: an unspecified disable lasts until something re-enables it (Execute: Defragment).
|
||||
"Execute: Sabotage": {
|
||||
"text": "Destroy or disable one Hardware on an enemy Anomaly in combat at the target Server.",
|
||||
"execution": {
|
||||
"plays": _sabotage_plays,
|
||||
"targetsAnomalies": func(s, item): return _wearer_list(s, item.args.get("card")),
|
||||
"resolve": _sabotage_resolve,
|
||||
},
|
||||
},
|
||||
|
||||
"Execute: Kill Process": {
|
||||
"text": "Disable one Program installed on the target Server until its controller's next command.",
|
||||
"execution": {"plays": _targetable_program_plays, "resolve": _kill_resolve},
|
||||
},
|
||||
|
||||
# Ruling: Servers perform Executions, so "that Anomaly cannot play another Execution" stops the
|
||||
# Server it stands on from performing Executions for the rest of the turn.
|
||||
"Execute: Force Reboot": {
|
||||
"text": "Remove all temporary bonuses and penalties from one Anomaly you control at the target Server, or one Anomaly attacking it. That Anomaly cannot play another Execution until end of current command.",
|
||||
"execution": {"plays": _reboot_plays, "targetsAnomalies": _ref_target, "resolve": _reboot_resolve},
|
||||
},
|
||||
|
||||
"Execute: Fork": {
|
||||
"text": "Copy the localized effect of one Program installed on the target Server until end of current command.",
|
||||
"execution": {"plays": _targetable_program_plays, "resolve": _fork_resolve},
|
||||
},
|
||||
|
||||
"Execute: Ping Sweep": {
|
||||
"text": "You may draw 2 cards from the top of your deck.",
|
||||
"execution": {
|
||||
"plays": func(_s, _p): return [{"target": null, "args": {}}],
|
||||
"resolve": _ping_resolve,
|
||||
},
|
||||
},
|
||||
|
||||
# Reading: resolves right away, only while no combat is going on. Into your own location it's a
|
||||
# move; into an unowned or undefended one it's a capture; into a defended one it's an attack.
|
||||
"Execute: Trace Route": {
|
||||
"text": "Move one Anomaly you control from an adjacent Server to the target Server. If the target Server is enemy-controlled, your Anomaly attacks it with +1 Core for the resulting combat.",
|
||||
"execution": {"plays": _trace_plays, "targetsAnomalies": _ref_target, "resolve": _trace_resolve},
|
||||
},
|
||||
|
||||
"Execute: Override": {
|
||||
"text": "Choose one enemy Program installed on the target Server. Ignore its text until end of current command.",
|
||||
"execution": {"plays": _override_plays, "resolve": _override_resolve},
|
||||
},
|
||||
|
||||
"Execute: Memory Dump": {
|
||||
"text": "Draw 2 cards, then discard 1. If you control the target Server, draw 1 extra card instead of discarding.",
|
||||
"execution": {"plays": _every_location, "resolve": _dump_resolve},
|
||||
"resume": {"discard": _dump_discard, "drop": _dump_drop},
|
||||
},
|
||||
|
||||
"Execute: Rollback": {
|
||||
"text": "Return one Program or Hardware installed at the target Server this command to its owner's hand.",
|
||||
"execution": {
|
||||
"plays": _rollback_plays,
|
||||
"targetsAnomalies": func(s, item): return _wearer_list(s, item.args.get("card")),
|
||||
"resolve": _rollback_resolve,
|
||||
},
|
||||
},
|
||||
|
||||
# Protected = Hardware Sandbox's Program. No card protects Hardware yet.
|
||||
"Execute: Root Access": {
|
||||
"text": "Until end of current command, your Programs and Executions at the target Server may target protected Programs and Hardware as though they were unprotected.",
|
||||
"execution": {"plays": _every_location, "resolve": _root_resolve},
|
||||
},
|
||||
|
||||
# Rooted Anomalies can't advance, attack, reposition, or be moved; their declared moves fail.
|
||||
"Execute: Packet Flood": {
|
||||
"text": "Anomalies based at the target Server cannot move or retreat until the start of their controller's next command.",
|
||||
"execution": {"plays": _flood_plays, "resolve": _flood_resolve},
|
||||
},
|
||||
|
||||
# Reading: Disabled Anomalies still defend, but can't advance, attack, move or use Abilities.
|
||||
"Execute: Emergency Shutdown": {
|
||||
"text": "End any combat at the target Server immediately. All Anomalies there remain and become Disabled until end of current command.",
|
||||
"execution": {"plays": _shutdown_plays, "resolve": _shutdown_resolve},
|
||||
},
|
||||
|
||||
"Execute: Process Clone": {
|
||||
"text": "Choose one Program installed on the target Server you control. Treat it as though a second copy were installed there until end of current command.",
|
||||
"execution": {"plays": _clone_plays, "resolve": _clone_resolve},
|
||||
},
|
||||
|
||||
"Execute: Defragment": {
|
||||
"text": "Re-enable one Disabled Program on the target Server, or one Disabled Hardware on an Anomaly there.",
|
||||
"execution": {"plays": _defrag_plays, "resolve": _defrag_resolve},
|
||||
},
|
||||
|
||||
# Reading: the Program keeps its owner, and runs at both locations until end of turn.
|
||||
"Execute: Remote Access": {
|
||||
"text": "Activate one Program installed on a Server adjacent to the target Server as though it were installed on the target Server, until end of current command.",
|
||||
"execution": {"plays": _remote_plays, "resolve": _remote_resolve},
|
||||
},
|
||||
|
||||
"Execute: Purge": {
|
||||
"text": "Remove all Virus/Infection counters and hostile persistent effects from every Anomaly you control at the target Server.",
|
||||
"execution": {"plays": _purge_plays, "resolve": _purge_resolve},
|
||||
},
|
||||
|
||||
"Execute: Hard Reset": {
|
||||
"text": "Uninstall any number of Programs from the target Server you control. For each card returned to your hand this way, recover 1 Gb.",
|
||||
"execution": {"plays": _reset_plays, "resolve": _reset_resolve},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
static func _every_location(_s: Dictionary, _p: int) -> Array:
|
||||
return GameMap.LOCATIONS.map(func(target): return {"target": target, "args": {}})
|
||||
|
||||
|
||||
## Plays on each active Program `p` may target, in the scope of each target (Kill Process, Fork).
|
||||
static func _targetable_program_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
return CardUtil.programs_on(s, loc).filter(func(id): return Query.can_target_program(s, id, p)).map(func(card): return {"card": card}))
|
||||
|
||||
|
||||
# Disconnect
|
||||
|
||||
static func _disconnect_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
var out := []
|
||||
for r in CardUtil.mine(s, p, loc):
|
||||
if not State.can_act(s, r):
|
||||
continue
|
||||
var at: String = State.anomaly(s, r).at
|
||||
var dests: Array = State.neighbors(s, loc).filter(func(d): return d != at and Query.has_room(s, p, d))
|
||||
if State.in_combat(s, r) and at != loc:
|
||||
dests.append(at)
|
||||
for to in dests:
|
||||
out.append({"ref": r, "to": to})
|
||||
return out)
|
||||
|
||||
|
||||
static func _disconnect_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var r: Dictionary = item.args.ref
|
||||
var to: String = item.args.to
|
||||
var av := State.anomaly(s, r)
|
||||
if av.at == null or not State.can_act(s, r) or (to != av.at and not Query.has_room(s, r.player, to)):
|
||||
return
|
||||
State.fired(s, item.name, item.player)
|
||||
if State.in_combat(s, r):
|
||||
Flow.drop_from_combat(s, r)
|
||||
if to != av.at:
|
||||
Flow.move_anomaly(s, r, to)
|
||||
|
||||
|
||||
# Sabotage
|
||||
|
||||
static func _sabotage_plays(s: Dictionary, p: int) -> Array:
|
||||
var c = _live_combat(s)
|
||||
if c == null:
|
||||
return []
|
||||
var hws := []
|
||||
for r in State.fighters_of(c):
|
||||
if r.player != p:
|
||||
hws.append_array(State.hardware_of(s, r))
|
||||
hws = Util.uniq(hws)
|
||||
var out := []
|
||||
for target in GameMap.LOCATIONS:
|
||||
if not CardUtil.scope_of(s, p, target).has(c.loc):
|
||||
continue
|
||||
for card in hws:
|
||||
out.append({"target": target, "args": {"card": card, "mode": "destroy"}})
|
||||
if Query.hardware_active(s, card):
|
||||
out.append({"target": target, "args": {"card": card, "mode": "disable"}})
|
||||
return out
|
||||
|
||||
|
||||
static func _sabotage_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var hw: int = item.args.card
|
||||
var owner = State.wearer_of(s, hw)
|
||||
if owner == null:
|
||||
return
|
||||
State.fired(s, item.name, item.player)
|
||||
if item.args.mode == "destroy":
|
||||
State.uninstall_hardware(s, hw)
|
||||
State.to_discard(s, hw)
|
||||
State.stat(s, "hardwareLost", owner.player)
|
||||
State.say(s, "Sabotage destroys %s." % State.name_of(s, hw))
|
||||
HardwareCards.shed_hardware(s, owner)
|
||||
else:
|
||||
s.cards[hw].disabledUntil = Types.FOREVER
|
||||
State.say(s, "Sabotage disables %s." % State.name_of(s, hw))
|
||||
|
||||
|
||||
# Kill Process
|
||||
|
||||
static func _kill_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) == null:
|
||||
return
|
||||
var until := State.start_of(State.next_turn_of(s, State.owner_of(s, card)))
|
||||
s.cards[card].disabledUntil = maxi(s.cards[card].disabledUntil, until)
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Kill Process disables %s until %s's next turn." % [State.name_of(s, card), State.player_name(State.owner_of(s, card))])
|
||||
|
||||
|
||||
# Force Reboot
|
||||
|
||||
static func _reboot_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
var c = _live_combat(s)
|
||||
var attacker := [c.attacker] if c != null and c.loc == loc else []
|
||||
return _uniq_refs(CardUtil.mine(s, p, loc) + attacker).map(func(r): return {"ref": r}))
|
||||
|
||||
|
||||
static func _reboot_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var r: Dictionary = item.args.ref
|
||||
var av := State.anomaly(s, r)
|
||||
if av.at == null:
|
||||
return
|
||||
var live := State.active_mods(s, av)
|
||||
av.mods = av.mods.filter(func(m): return not live.has(m))
|
||||
# Servers perform Executions: the Server this Anomaly stands on can't for the rest of the turn.
|
||||
State.mark_used(s, "noExec:%s" % av.at)
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Force Reboot clears %d temporary effect(s) from %s." % [live.size(), State.anomaly_name(s, r)])
|
||||
|
||||
|
||||
# Fork
|
||||
|
||||
static func _fork_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) == null or not Query.program_active(s, card):
|
||||
return
|
||||
s.seq += 1
|
||||
s.virtuals.append({
|
||||
"id": s.seq, "name": State.name_of(s, card), "controller": item.player, "at": item.target,
|
||||
"until": State.end_of_turn(s), "installed": false, "from": card,
|
||||
})
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Fork copies %s on %s for %s until end of turn." % [State.name_of(s, card), item.target, State.player_name(item.player)])
|
||||
|
||||
|
||||
# Ping Sweep
|
||||
|
||||
static func _ping_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
State.fired(s, item.name, item.player)
|
||||
_draw_n(s, item.player, 2 + item.power)
|
||||
|
||||
|
||||
# Trace Route
|
||||
|
||||
static func _trace_plays(s: Dictionary, p: int) -> Array:
|
||||
if _live_combat(s) != null:
|
||||
return []
|
||||
var out := []
|
||||
for target in GameMap.LOCATIONS:
|
||||
if GameMap.is_start(target) and not State.controls(s, p, target):
|
||||
continue
|
||||
var mine_there := State.controls(s, p, target)
|
||||
if mine_there and not Query.has_room(s, p, target):
|
||||
continue
|
||||
for r in State.refs_in_play(s, p):
|
||||
var at: String = State.anomaly(s, r).at
|
||||
if at != target and State.can_act(s, r) and State.adjacent(s, at, target):
|
||||
out.append({"target": target, "args": {"ref": r}})
|
||||
return out
|
||||
|
||||
|
||||
static func _trace_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var r: Dictionary = item.args.ref
|
||||
var t: String = item.target
|
||||
var av := State.anomaly(s, r)
|
||||
if av.at == null or not State.can_act(s, r) or not State.adjacent(s, av.at, t) or _live_combat(s) != null:
|
||||
return
|
||||
var owner = s.locations[t].owner
|
||||
State.fired(s, item.name, item.player)
|
||||
if owner == item.player:
|
||||
if Query.has_room(s, item.player, t):
|
||||
Flow.move_anomaly(s, r, t)
|
||||
elif owner == null:
|
||||
State.push_capture(s, r, t, "capturesUnowned")
|
||||
elif State.defenders_at(s, t).is_empty():
|
||||
State.push_capture(s, r, t, "capturesUndefended")
|
||||
else:
|
||||
var c := State.start_combat(s, r, av.at, t, "traceRoute")
|
||||
State.add_mod(s, r, 1 + item.power, "Trace Route", item.player, {"combat": c.id})
|
||||
Query.emit(s, "onAttackDeclared", {"ref": r, "to": t})
|
||||
|
||||
|
||||
# Override
|
||||
|
||||
static func _override_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
return CardUtil.programs_on(s, loc) \
|
||||
.filter(func(id): return State.owner_of(s, id) != p and Query.can_target_program(s, id, p)) \
|
||||
.map(func(card): return {"card": card}))
|
||||
|
||||
|
||||
static func _override_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) == null:
|
||||
return
|
||||
s.cards[card].ignoredUntil = State.end_of_turn(s)
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Override: %s's text is ignored until end of turn." % State.name_of(s, card))
|
||||
|
||||
|
||||
# Memory Dump
|
||||
|
||||
static func _dump_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var p: int = item.player
|
||||
State.fired(s, item.name, p)
|
||||
if State.controls(s, p, item.target):
|
||||
_draw_n(s, p, 3 + item.power)
|
||||
return
|
||||
var tasks := []
|
||||
for i in 2 + item.power:
|
||||
tasks.append({"t": "draw", "player": p})
|
||||
tasks.append(State.later("Execute: Memory Dump", "discard", {"player": p}))
|
||||
State.push_tasks(s, tasks)
|
||||
|
||||
|
||||
static func _dump_discard(s: Dictionary, data: Dictionary, _value: Variant) -> void:
|
||||
var hand: Array = s.players[data.player].hand
|
||||
if hand.is_empty():
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": data.player,
|
||||
"kind": "Execute: Memory Dump:discard",
|
||||
"prompt": "Memory Dump: discard a card.",
|
||||
"options": CardUtil.card_options(s, hand),
|
||||
"resume": {"name": "Execute: Memory Dump", "fn": "drop", "data": {"player": data.player}},
|
||||
})
|
||||
|
||||
|
||||
static func _dump_drop(s: Dictionary, data: Dictionary, card: Variant) -> void:
|
||||
if State.remove_from(s.players[data.player].hand, card):
|
||||
State.to_discard(s, card)
|
||||
|
||||
|
||||
# Rollback
|
||||
|
||||
static func _rollback_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
var progs: Array = s.locations[loc].programs.filter(func(id):
|
||||
return s.cards[id].installedTurn == s.turn and Query.can_target_program(s, id, p))
|
||||
var worn := []
|
||||
for r in State.anomalies_at(s, loc):
|
||||
worn.append_array(State.anomaly(s, r).hardware)
|
||||
var hws: Array = Util.uniq(worn).filter(func(id): return s.cards[id].installedTurn == s.turn)
|
||||
return (progs + hws).map(func(card): return {"card": card}))
|
||||
|
||||
|
||||
static func _rollback_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
var wearer = State.wearer_of(s, card)
|
||||
if State.uninstall_program(s, card) == null and State.uninstall_hardware(s, card) == null:
|
||||
return
|
||||
State.to_hand(s, card)
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Rollback returns %s to %s's hand." % [State.name_of(s, card), State.player_name(State.owner_of(s, card))])
|
||||
if wearer != null:
|
||||
HardwareCards.shed_hardware(s, wearer)
|
||||
|
||||
|
||||
# Root Access
|
||||
|
||||
static func _root_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
s.locations[item.target].rootAccess[item.player] = State.end_of_turn(s)
|
||||
State.fired(s, item.name, item.player)
|
||||
|
||||
|
||||
# Packet Flood
|
||||
|
||||
static func _flood_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc): return [{"to": loc}] if not State.anomalies_at(s, loc).is_empty() else [])
|
||||
|
||||
|
||||
static func _flood_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var loc: String = item.args.get("to") if item.args.get("to") != null else item.target
|
||||
var here := State.anomalies_at(s, loc)
|
||||
if here.is_empty():
|
||||
return
|
||||
for r in here:
|
||||
var av := State.anomaly(s, r)
|
||||
av.rootedUntil = maxi(av.rootedUntil, State.start_of(State.next_turn_of(s, r.player)))
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Packet Flood: %s can't move." % ", ".join(here.map(func(r): return State.anomaly_name(s, r))))
|
||||
|
||||
|
||||
# Emergency Shutdown
|
||||
|
||||
static func _shutdown_plays(s: Dictionary, p: int) -> Array:
|
||||
var c = _live_combat(s)
|
||||
if c == null:
|
||||
return []
|
||||
var out := []
|
||||
for target in GameMap.LOCATIONS:
|
||||
if CardUtil.scope_of(s, p, target).has(c.loc):
|
||||
out.append({"target": target, "args": {}})
|
||||
return out
|
||||
|
||||
|
||||
static func _shutdown_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var c = _live_combat(s)
|
||||
if c == null or not CardUtil.scope_of(s, item.player, item.target).has(c.loc):
|
||||
return
|
||||
var everyone := _uniq_refs(State.fighters_of(c) + State.anomalies_at(s, c.loc))
|
||||
Flow.end_combat(s, "Emergency Shutdown")
|
||||
for r in everyone:
|
||||
State.anomaly(s, r).disabledUntil = maxi(State.anomaly(s, r).disabledUntil, State.end_of_turn(s))
|
||||
State.fired(s, item.name, item.player)
|
||||
|
||||
|
||||
# Process Clone
|
||||
|
||||
static func _clone_plays(s: Dictionary, p: int) -> Array:
|
||||
var out := []
|
||||
for target in GameMap.LOCATIONS:
|
||||
if not State.controls(s, p, target):
|
||||
continue
|
||||
for loc in CardUtil.scope_of(s, p, target):
|
||||
if State.controls(s, p, loc):
|
||||
for card in CardUtil.programs_on(s, loc):
|
||||
out.append({"target": target, "args": {"card": card}})
|
||||
return out
|
||||
|
||||
|
||||
static func _clone_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) == null or not State.controls(s, item.player, item.target):
|
||||
return
|
||||
s.seq += 1
|
||||
s.virtuals.append({
|
||||
"id": s.seq, "name": State.name_of(s, card), "controller": item.player, "at": item.target,
|
||||
"until": State.end_of_turn(s), "installed": true, "from": card,
|
||||
})
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Process Clone: a second %s runs on %s until end of turn." % [State.name_of(s, card), item.target])
|
||||
|
||||
|
||||
# Defragment
|
||||
|
||||
static func _defrag_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
var progs: Array = s.locations[loc].programs.filter(func(id): return State.running(s, s.cards[id].disabledUntil))
|
||||
var worn := []
|
||||
for r in State.anomalies_at(s, loc):
|
||||
worn.append_array(State.hardware_of(s, r))
|
||||
var hws: Array = Util.uniq(worn).filter(func(id): return not Query.hardware_active(s, id))
|
||||
return (progs + hws).map(func(card): return {"card": card}))
|
||||
|
||||
|
||||
static func _defrag_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if not State.running(s, s.cards[card].disabledUntil):
|
||||
return
|
||||
s.cards[card].disabledUntil = 0
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Defragment re-enables %s." % State.name_of(s, card))
|
||||
|
||||
|
||||
# Remote Access
|
||||
|
||||
static func _remote_plays(s: Dictionary, p: int) -> Array:
|
||||
var out := []
|
||||
for target in GameMap.LOCATIONS:
|
||||
for n in State.neighbors(s, target):
|
||||
for id in CardUtil.programs_on(s, n):
|
||||
if Query.can_target_program(s, id, p):
|
||||
out.append({"target": target, "args": {"card": id}})
|
||||
return out
|
||||
|
||||
|
||||
static func _remote_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) == null:
|
||||
return
|
||||
s.seq += 1
|
||||
s.virtuals.append({
|
||||
"id": s.seq, "name": State.name_of(s, card), "controller": State.owner_of(s, card), "at": item.target,
|
||||
"until": State.end_of_turn(s), "installed": true, "from": card,
|
||||
})
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Remote Access: %s also runs on %s until end of turn." % [State.name_of(s, card), item.target])
|
||||
|
||||
|
||||
# Purge
|
||||
|
||||
static func _purge_plays(s: Dictionary, p: int) -> Array:
|
||||
return _across_scope(s, p, func(loc):
|
||||
for r in CardUtil.mine(s, p, loc):
|
||||
if _has_negatives(s, r):
|
||||
return [{"to": loc}]
|
||||
return [])
|
||||
|
||||
|
||||
static func _purge_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var loc: String = item.args.get("to") if item.args.get("to") != null else item.target
|
||||
var here := CardUtil.mine(s, item.player, loc)
|
||||
for r in here:
|
||||
var av := State.anomaly(s, r)
|
||||
av.infection = 0
|
||||
av.permanentInfection = 0
|
||||
av.mods = av.mods.filter(func(m): return m.cores >= 0 or m.by == item.player)
|
||||
av.rootedUntil = 0
|
||||
av.disabledUntil = 0
|
||||
for hw in State.hardware_of(s, r):
|
||||
s.cards[hw].disabledUntil = 0
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Purge cleans %s." % ", ".join(here.map(func(r): return State.anomaly_name(s, r))))
|
||||
|
||||
|
||||
# Hard Reset
|
||||
|
||||
static func _reset_plays(s: Dictionary, p: int) -> Array:
|
||||
var out := []
|
||||
for target in GameMap.LOCATIONS:
|
||||
if State.controls(s, p, target) and not s.locations[target].programs.is_empty():
|
||||
for cards in CardUtil.subsets(s.locations[target].programs):
|
||||
out.append({"target": target, "args": {"cards": cards}})
|
||||
return out
|
||||
|
||||
|
||||
static func _reset_resolve(s: Dictionary, item: Dictionary) -> void:
|
||||
var back: Array = item.args.cards.filter(func(id): return State.program_location(s, id) == item.target)
|
||||
for id in back:
|
||||
State.uninstall_program(s, id)
|
||||
State.to_hand(s, id)
|
||||
var gain: int = back.size() * (1 + item.power)
|
||||
State.gain_bandwidth(s, item.player, gain)
|
||||
State.fired(s, item.name, item.player)
|
||||
State.say(s, "Hard Reset returns %s to hand (+%d Gb)." % [", ".join(back.map(func(id): return State.name_of(s, id))), gain])
|
||||
1
engine/cards/executions.gd.uid
Normal file
1
engine/cards/executions.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b3a807yeclr0l
|
||||
422
engine/cards/hardware.gd
Normal file
422
engine/cards/hardware.gd
Normal file
|
|
@ -0,0 +1,422 @@
|
|||
class_name HardwareCards
|
||||
## Hardware (cards/hardware.ts). It works while its wearer is in play. "The occupied Server" is the
|
||||
## location the wearer stands on.
|
||||
|
||||
|
||||
## 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 Anomaly picks it (Cooling helps one Hardware a turn).
|
||||
static func hardware_uses_left(s: Dictionary, hw: int) -> int:
|
||||
var used := State.used_this_turn(s, "hw:%d" % hw)
|
||||
var cooler = _cooler_for(s, hw)
|
||||
return (1 if cooler == null else 2) - used
|
||||
|
||||
|
||||
static func _cooler_for(s: Dictionary, hw: int) -> Variant:
|
||||
var r = State.wearer_of(s, hw)
|
||||
if r == null:
|
||||
return null
|
||||
for id in State.anomaly(s, r).hardware:
|
||||
if id == hw or s.cards[id].name != "Cooling System" or not Query.hardware_active(s, id):
|
||||
continue
|
||||
var picked_for = s.used.get("cool:%d" % id)
|
||||
if picked_for == null or picked_for == hw:
|
||||
return id
|
||||
return null
|
||||
|
||||
|
||||
## Reading: an Anomaly that loses an Expansion Slot (Network Interface Upgrade removed) discards
|
||||
## Hardware until it fits, the most recently installed first.
|
||||
static func shed_hardware(s: Dictionary, r: Dictionary) -> void:
|
||||
while not Query.slots_fit(s, r):
|
||||
var hw = null
|
||||
var list: Array = State.anomaly(s, r).hardware
|
||||
for i in range(list.size() - 1, -1, -1):
|
||||
if Query.takes_slot(s, list[i]):
|
||||
hw = list[i]
|
||||
break
|
||||
State.uninstall_hardware(s, hw)
|
||||
State.to_discard(s, hw)
|
||||
State.stat(s, "hardwareLost", r.player)
|
||||
State.say(s, "%s is out of Expansion Slots and discards %s." % [State.anomaly_name(s, r), State.name_of(s, hw)])
|
||||
|
||||
|
||||
static func use_hardware(s: Dictionary, hw: int) -> void:
|
||||
var cooler = _cooler_for(s, hw)
|
||||
State.mark_used(s, "hw:%d" % hw)
|
||||
if State.used_this_turn(s, "hw:%d" % hw) >= 2 and cooler != null:
|
||||
s.used["cool:%d" % cooler] = hw
|
||||
State.fired(s, "Cooling System", State.owner_of(s, hw))
|
||||
|
||||
|
||||
## Whether `r` is the Anomaly (or a copy of the Anomaly) wearing Hardware at `wearer`.
|
||||
static func _wearing(wearer: Variant, r: Dictionary) -> bool:
|
||||
return wearer != null and wearer.player == r.player and (wearer.slot == r.slot or wearer.slot + 4 == r.slot)
|
||||
|
||||
|
||||
## Installs a Hardware card from its owner's hand onto an Anomaly, without paying.
|
||||
static func attach_hardware(s: Dictionary, card: int, r: Dictionary) -> void:
|
||||
State.remove_from(s.players[r.player].hand, card)
|
||||
State.anomaly(s, r).hardware.append(card)
|
||||
s.cards[card].installedTurn = s.turn
|
||||
State.stat(s, "hardwareInstalled", r.player)
|
||||
State.played(s, State.name_of(s, card), r.player)
|
||||
|
||||
|
||||
static func scripts() -> Dictionary:
|
||||
return {
|
||||
# Health rule: the wearer's Health goes up by 2 (Query.health_of). Without the rule it does nothing.
|
||||
"RAM Expansion": {"text": "Anomaly gains +2 Health.", "health": 2},
|
||||
"Additional Core": {"text": "Anomaly gains +1 Core.", "cores": func(_s, _src, _f): return 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": "Anomaly gains +2 Cores during combat, but one installed Program at the current server becomes disabled afterward for 2 commands.",
|
||||
"cores": func(_s, _src, f): return 2 if f.role != null else 0,
|
||||
"onCombatEnd": _overclocked_combat_end,
|
||||
"resume": {"disable": func(s, _data, id): _disable_for_two_turns(s, id)},
|
||||
},
|
||||
|
||||
"Solid-State Cache": {
|
||||
"text": "The first Program installed on the occupied Server each round costs 3 less Gb.",
|
||||
"costMod": _cache_cost,
|
||||
"onPaid": _use_and_fire.bind("Solid-State Cache"),
|
||||
},
|
||||
|
||||
# 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 Anomaly would be destroyed, do not destroy the Hardware.",
|
||||
"savePriority": 0,
|
||||
"onWearerDefeated": _rps_defeated,
|
||||
},
|
||||
|
||||
# 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 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, Bandwidth recovered).
|
||||
"Dedicated GPU": {
|
||||
"text": "Executions performed by this Anomaly receive +1 effectiveness or combat strength.",
|
||||
"executionPower": 1,
|
||||
},
|
||||
|
||||
# Blocks opponents' Bug counters (see CardUtil.add_bugs; no card places them yet) and their
|
||||
# Bug Program effects on the wearer (Bloatware, Stock Rice).
|
||||
"ECC Memory": {
|
||||
"text": "Opponents cannot place Bug counters or Bug status effects on this Anomaly.",
|
||||
"bugImmunity": true,
|
||||
},
|
||||
|
||||
# Works through hardware_uses_left() above.
|
||||
"Cooling System": {"text": "Allow one Hardware to activate twice per round."},
|
||||
|
||||
# Reading: half the combined printed Bandwidth of its Hardware, rounded up.
|
||||
"RAID Array": {
|
||||
"text": "When this Anomaly is destroyed, all hardware can be kept by paying half the Bandwidth cost.",
|
||||
"savePriority": 1,
|
||||
"onWearerDefeated": _raid_defeated,
|
||||
"resume": {"keep": _raid_keep},
|
||||
},
|
||||
|
||||
"Packet Accelerator": {
|
||||
"text": "This Anomaly gains +1 Core hen attacking.",
|
||||
"cores": func(_s, _src, f): return 1 if f.role == "attack" else 0,
|
||||
},
|
||||
|
||||
# Programs never target Anomalies, so this taxes Executions (and Hardware they hit).
|
||||
"Firewall Appliance": {
|
||||
"text": "The first hostile Program or Execution targeting this Anomaly each round costs the opponent +3 Gb.",
|
||||
"costMod": _appliance_cost,
|
||||
"onPaid": _use_and_fire.bind("Firewall Appliance"),
|
||||
},
|
||||
|
||||
# Reading: pick the Program on install, and again at the start of your turn if the wearer has
|
||||
# moved. Protection only holds while the wearer stands on that Program's location.
|
||||
"Hardware Sandbox": {
|
||||
"text": "Choose one Program installed on the occupied Server. It cannot be targeted by opponents.",
|
||||
"onInstall": _sandbox_install,
|
||||
"onTurnStart": _sandbox_turn_start,
|
||||
"resume": {"protect": _sandbox_protect},
|
||||
},
|
||||
|
||||
# Reading: at the start of your turn, look at the top card and you may put it on the bottom.
|
||||
"Diagnostic Module": {
|
||||
"text": "Look at one face down card in your draw pile. You may place it at the bottom and draw another to start your first command each round.",
|
||||
"onTurnStart": _diagnostic_turn_start,
|
||||
"resume": {"bottom": _diagnostic_bottom},
|
||||
},
|
||||
|
||||
# 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": _hot_swap_uses,
|
||||
"extraCost": _hot_swap_extra,
|
||||
"resolve": _hot_swap_resolve,
|
||||
},
|
||||
},
|
||||
|
||||
# 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 Anomaly uses an Execution, you may copy that Execution's effect with a different legal target, then disable this Hardware.",
|
||||
"copiesExecutions": true,
|
||||
"resume": {"offer": _quantum_offer, "copy": _quantum_copy},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
static func _use_and_fire(s: Dictionary, src: Dictionary, _pay: Dictionary, card_name: String) -> void:
|
||||
use_hardware(s, src.id)
|
||||
State.fired(s, card_name, src.controller)
|
||||
|
||||
|
||||
# Overclocked CPU
|
||||
|
||||
static func _overclocked_combat_end(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
var c: Dictionary = s.combat
|
||||
var role := ""
|
||||
if _wearing(src.get("ref"), c.attacker):
|
||||
role = "attack"
|
||||
else:
|
||||
for d in c.defenders:
|
||||
if _wearing(src.get("ref"), d):
|
||||
role = "defend"
|
||||
break
|
||||
if role == "":
|
||||
return
|
||||
var loc: String = c.origin if role == "attack" else c.loc
|
||||
if s.locations[loc].owner != src.controller:
|
||||
return
|
||||
var progs := CardUtil.programs_on(s, loc)
|
||||
if progs.is_empty():
|
||||
return
|
||||
State.fired(s, "Overclocked CPU", src.controller)
|
||||
if progs.size() == 1:
|
||||
_disable_for_two_turns(s, progs[0])
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Overclocked CPU:disable",
|
||||
"prompt": "Overclocked CPU: which Program on %s is disabled for 2 turns?" % loc,
|
||||
"options": progs.map(func(id): return {"label": State.name_of(s, id), "value": id}),
|
||||
"resume": {"name": "Overclocked CPU", "fn": "disable", "data": null},
|
||||
})
|
||||
|
||||
|
||||
static func _disable_for_two_turns(s: Dictionary, id: int) -> void:
|
||||
s.cards[id].disabledUntil = maxi(s.cards[id].disabledUntil, State.end_of(s.turn + 1))
|
||||
State.say(s, "Overclocked CPU: %s is disabled for 2 turns." % State.name_of(s, id))
|
||||
|
||||
|
||||
# Solid-State Cache, Firewall Appliance
|
||||
|
||||
static func _cache_cost(s: Dictionary, src: Dictionary, pay: Dictionary) -> int:
|
||||
return -3 if pay.kind == "program" and pay.player == src.controller and pay.get("at") == src.at \
|
||||
and hardware_uses_left(s, src.id) > 0 else 0
|
||||
|
||||
|
||||
static func _appliance_cost(s: Dictionary, src: Dictionary, pay: Dictionary) -> int:
|
||||
if pay.kind != "execution" or pay.player == src.controller or hardware_uses_left(s, src.id) <= 0:
|
||||
return 0
|
||||
for r in pay.get("hostile", []):
|
||||
if _wearing(src.get("ref"), r):
|
||||
return 3
|
||||
return 0
|
||||
|
||||
|
||||
# Redundant Power Supply, RAID Array
|
||||
|
||||
static func _rps_defeated(s: Dictionary, hw: int, ev: Dictionary) -> bool:
|
||||
if s.cards[hw].get("spent", false):
|
||||
return false
|
||||
s.cards[hw].spent = true
|
||||
State.fired(s, "Redundant Power Supply", ev.ref.player)
|
||||
State.say(s, "Redundant Power Supply: %s keeps its Hardware." % State.anomaly_name(s, ev.ref))
|
||||
Flow.knock_out(s, ev.ref, ev.loc, ev.role, true)
|
||||
return true
|
||||
|
||||
|
||||
static func _raid_defeated(s: Dictionary, _hw: int, ev: Dictionary) -> bool:
|
||||
var av := State.anomaly(s, ev.ref)
|
||||
var total := 0
|
||||
for h in av.hardware:
|
||||
total += State.def_of(s, h).bandwidth
|
||||
var cost := ceili(total / 2.0)
|
||||
State.ask(s, {
|
||||
"player": ev.ref.player,
|
||||
"kind": "RAID Array:keep",
|
||||
"prompt": "RAID Array: pay %d Gb to keep %s?" % [cost, ", ".join(av.hardware.map(func(h): return State.name_of(s, h)))],
|
||||
"options": [
|
||||
{"label": "Keep all Hardware for %d Gb" % cost, "value": true, "cost": cost},
|
||||
{"label": "Lose the Hardware", "value": false},
|
||||
],
|
||||
"resume": {"name": "RAID Array", "fn": "keep", "data": {"ref": ev.ref, "loc": ev.loc, "role": ev.role, "cost": cost}},
|
||||
})
|
||||
return true
|
||||
|
||||
|
||||
static func _raid_keep(s: Dictionary, data: Dictionary, keep: Variant) -> void:
|
||||
if keep:
|
||||
s.players[data.ref.player].bandwidth -= data.cost
|
||||
State.stat(s, "bandwidthOnCards", data.ref.player, data.cost)
|
||||
State.fired(s, "RAID Array", data.ref.player)
|
||||
Flow.knock_out(s, data.ref, data.loc, data.role, keep)
|
||||
|
||||
|
||||
# Hardware Sandbox
|
||||
|
||||
static func _sandbox_install(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.card == src.id:
|
||||
_ask_sandbox(s, src.id)
|
||||
|
||||
|
||||
static func _sandbox_turn_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
if s.active != src.controller:
|
||||
return
|
||||
var p = s.cards[src.id].get("protects")
|
||||
if p == null or State.program_location(s, p) != src.at:
|
||||
_ask_sandbox(s, src.id)
|
||||
|
||||
|
||||
static func _sandbox_protect(s: Dictionary, data: Dictionary, program: Variant) -> void:
|
||||
s.cards[data.card].protects = program
|
||||
State.fired(s, "Hardware Sandbox", State.owner_of(s, data.card))
|
||||
|
||||
|
||||
static func _ask_sandbox(s: Dictionary, card: int) -> void:
|
||||
var r = State.wearer_of(s, card)
|
||||
var at = State.anomaly(s, r).at if r != null else null
|
||||
if r == null or not at:
|
||||
return
|
||||
var progs: Array = s.locations[at].programs.filter(func(id): return State.owner_of(s, id) == r.player)
|
||||
if progs.is_empty():
|
||||
return
|
||||
if progs.size() == 1:
|
||||
s.cards[card].protects = progs[0]
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": r.player,
|
||||
"kind": "Hardware Sandbox:protect",
|
||||
"prompt": "Hardware Sandbox: protect which Program on %s?" % at,
|
||||
"options": progs.map(func(id): return {"label": State.name_of(s, id), "value": id}),
|
||||
"resume": {"name": "Hardware Sandbox", "fn": "protect", "data": {"card": card}},
|
||||
})
|
||||
|
||||
|
||||
# Diagnostic Module
|
||||
|
||||
static func _diagnostic_turn_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
if s.active != src.controller or hardware_uses_left(s, src.id) <= 0:
|
||||
return
|
||||
var deck: Array = s.players[src.controller].deck
|
||||
if deck.size() < 2:
|
||||
return
|
||||
use_hardware(s, src.id)
|
||||
State.fired(s, "Diagnostic Module", src.controller)
|
||||
var top := State.name_of(s, deck[0])
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Diagnostic Module:bottom",
|
||||
"secret": true,
|
||||
"prompt": "Diagnostic Module: the top card of your deck is %s. Put it on the bottom?" % top,
|
||||
"options": [
|
||||
{"label": "Keep %s on top" % top, "value": false},
|
||||
{"label": "Put %s on the bottom" % top, "value": true},
|
||||
],
|
||||
"resume": {"name": "Diagnostic Module", "fn": "bottom", "data": {"player": src.controller}},
|
||||
})
|
||||
|
||||
|
||||
static func _diagnostic_bottom(s: Dictionary, data: Dictionary, bottom: Variant) -> void:
|
||||
var deck: Array = s.players[data.player].deck
|
||||
if bottom and not deck.is_empty():
|
||||
deck.append(deck.pop_front())
|
||||
|
||||
|
||||
# Hot-Swap Bay
|
||||
|
||||
static func _hot_swap_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
var av := State.anomaly(s, src.ref)
|
||||
var hand: Array = s.players[src.controller].hand.filter(func(id): return State.def_of(s, id).kind == "hardware")
|
||||
var out := []
|
||||
for out_card in av.hardware:
|
||||
for o in CardUtil.card_options(s, hand):
|
||||
if Query.slots_fit(s, src.ref, out_card, o.value):
|
||||
out.append({"card": out_card, "cards": [o.value]})
|
||||
return out
|
||||
|
||||
|
||||
static func _hot_swap_extra(s: Dictionary, _src: Dictionary, args: Dictionary) -> int:
|
||||
return maxi(0, State.def_of(s, args.cards[0]).bandwidth - State.def_of(s, args.card).bandwidth)
|
||||
|
||||
|
||||
static func _hot_swap_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var out_card: int = item.args.card
|
||||
var into: int = item.args.cards[0]
|
||||
var r: Dictionary = src.ref
|
||||
if not State.anomaly(s, r).hardware.has(out_card) or not s.players[src.controller].hand.has(into):
|
||||
return
|
||||
if not Query.slots_fit(s, r, out_card, into):
|
||||
return
|
||||
State.uninstall_hardware(s, out_card)
|
||||
State.to_hand(s, out_card)
|
||||
attach_hardware(s, into, r)
|
||||
State.fired(s, "Hot-Swap Bay", src.controller)
|
||||
State.say(s, "Hot-Swap Bay swaps %s for %s on %s." % [State.name_of(s, out_card), State.name_of(s, into), State.anomaly_name(s, r)])
|
||||
|
||||
|
||||
# Quantum Coprocessor
|
||||
|
||||
static func _quantum_offer(s: Dictionary, data: Dictionary, _value: Variant) -> void:
|
||||
var item: Dictionary = data.item
|
||||
var qc = null
|
||||
for r in State.refs_in_play(s, item.player):
|
||||
if State.is_copy(r) or State.anomaly(s, r).at != item.from or Query.desynced(s, r):
|
||||
continue
|
||||
for hw in State.anomaly(s, r).hardware:
|
||||
if s.cards[hw].name == "Quantum Coprocessor" and Query.hardware_active(s, hw) and hardware_uses_left(s, hw) > 0:
|
||||
qc = hw
|
||||
break
|
||||
if qc != null:
|
||||
break
|
||||
if qc == null:
|
||||
return
|
||||
var ex: Dictionary = CardScripts.of(item.name).get("execution", {})
|
||||
if ex.is_empty():
|
||||
return
|
||||
var same := {"t": item.target, "a": item.args}
|
||||
var plays: Array = ex.plays.call(s, item.player).filter(func(p): return {"t": p.target, "a": p.args} != same)
|
||||
if plays.is_empty():
|
||||
return
|
||||
var options := [{"label": "Don't copy", "value": null}]
|
||||
for p in plays:
|
||||
var label := "%s %s" % [p.target if p.target != null else "no target", Describe.describe_args(s, p.args, item.player)]
|
||||
options.append({"label": label, "value": {"target": p.target, "args": p.args}})
|
||||
State.ask(s, {
|
||||
"player": item.player,
|
||||
"kind": "Quantum Coprocessor:copy",
|
||||
"prompt": "Quantum Coprocessor: copy %s with a different target?" % item.name,
|
||||
"options": options,
|
||||
"resume": {"name": "Quantum Coprocessor", "fn": "copy", "data": {"item": item, "qc": qc}},
|
||||
})
|
||||
|
||||
|
||||
static func _quantum_copy(s: Dictionary, data: Dictionary, v: Variant) -> void:
|
||||
if not v:
|
||||
return
|
||||
use_hardware(s, data.qc)
|
||||
s.cards[data.qc].disabledUntil = State.start_of(State.next_turn_of(s, data.item.player))
|
||||
State.fired(s, "Quantum Coprocessor", data.item.player)
|
||||
State.say(s, "Quantum Coprocessor copies %s onto %s." % [data.item.name, v.target if v.target != null else "a new target"])
|
||||
var copy: Dictionary = data.item.duplicate()
|
||||
copy.target = v.target
|
||||
copy.args = v.args
|
||||
copy.from = null
|
||||
CardScripts.of(data.item.name).execution.resolve.call(s, copy)
|
||||
1
engine/cards/hardware.gd.uid
Normal file
1
engine/cards/hardware.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b4f3qutsfuf6y
|
||||
734
engine/cards/programs.gd
Normal file
734
engine/cards/programs.gd
Normal file
|
|
@ -0,0 +1,734 @@
|
|||
class_name ProgramCards
|
||||
## Programs (cards/programs.ts). A Program sits on a location its owner controls and its effect is
|
||||
## local: "this Server" is the location it's on (or where Worm Protocol spreads it). Enemy Anomalies
|
||||
## are only ever "at" your location while attacking or capturing it.
|
||||
|
||||
|
||||
static func _enemy_of(src: Dictionary, r: Dictionary) -> bool:
|
||||
return r.player != src.controller
|
||||
|
||||
|
||||
## The first active source with this name at the location, so duplicates don't double up.
|
||||
static func _first_here(s: Dictionary, src: Dictionary, loc: String) -> bool:
|
||||
var named := Query.sources_named(s, src.name, loc)
|
||||
return not named.is_empty() and Query.same_source(named[0], src)
|
||||
|
||||
|
||||
## Destroys an installed Program. Hotfix (first each turn) disables it instead; otherwise Version
|
||||
## Control returns it to its owner's hand.
|
||||
static func destroy_program(s: Dictionary, id: int) -> void:
|
||||
var loc = State.program_location(s, id)
|
||||
if loc == null:
|
||||
return
|
||||
var owner := State.owner_of(s, id)
|
||||
var here: Array = Query.sources(s).filter(func(x): return x.at == loc and x.controller == owner and x.get("virtual") == null)
|
||||
var hotfix = null
|
||||
for x in here:
|
||||
if x.name == "Hotfix" and State.used_this_turn(s, "hotfix:%d" % x.id) == 0:
|
||||
hotfix = x
|
||||
break
|
||||
if hotfix != null:
|
||||
State.mark_used(s, "hotfix:%d" % hotfix.id)
|
||||
s.cards[id].disabledUntil = maxi(s.cards[id].disabledUntil, State.start_of(State.next_turn_of(s, owner)))
|
||||
State.fired(s, "Hotfix", owner)
|
||||
State.say(s, "Hotfix: %s is disabled instead of destroyed." % State.name_of(s, id))
|
||||
return
|
||||
State.uninstall_program(s, id)
|
||||
State.stat(s, "programsLost", owner)
|
||||
for x in here:
|
||||
if x.name == "Version Control":
|
||||
State.fired(s, "Version Control", owner)
|
||||
State.to_hand(s, id)
|
||||
State.say(s, "Version Control: %s returns to %s's hand." % [State.name_of(s, id), State.player_name(owner)])
|
||||
return
|
||||
State.to_discard(s, id)
|
||||
State.say(s, "%s is destroyed." % State.name_of(s, id))
|
||||
|
||||
|
||||
## Installs a Program for free (Replication Routine).
|
||||
static func _install_free(s: Dictionary, card: int, at: String) -> void:
|
||||
var p := State.owner_of(s, card)
|
||||
State.remove_from(s.players[p].hand, card)
|
||||
s.locations[at].programs.append(card)
|
||||
s.cards[card].installedTurn = s.turn
|
||||
State.stat(s, "programsInstalled", p)
|
||||
State.played(s, State.name_of(s, card), p)
|
||||
State.say(s, "%s installs %s on %s for free." % [State.player_name(p), State.name_of(s, card), at])
|
||||
Query.emit(s, "onInstall", {"card": card, "at": at, "ref": null})
|
||||
|
||||
|
||||
## Negative things on an Anomaly that Error Correction can remove, one at a time, as options.
|
||||
static func _negatives(s: Dictionary, r: Dictionary) -> Array:
|
||||
var av := State.anomaly(s, r)
|
||||
var out := []
|
||||
if av.infection > 0:
|
||||
out.append({"label": "an Infection counter", "value": "infection"})
|
||||
if av.bugs > 0:
|
||||
out.append({"label": "a Bug counter", "value": "bug"})
|
||||
if av.permanentInfection > 0:
|
||||
out.append({"label": "a permanent Infection counter", "value": "permanent"})
|
||||
for hw in State.hardware_of(s, r):
|
||||
if not Query.hardware_active(s, hw):
|
||||
out.append({"label": "disabled %s" % State.name_of(s, hw), "value": "hw:%d" % hw})
|
||||
var worst = _latest_penalty(s, av)
|
||||
if worst != null:
|
||||
out.append({"label": "%d Cores from %s" % [worst.cores, worst.source], "value": "mod:%d" % worst.seq})
|
||||
if State.running(s, av.rootedUntil):
|
||||
out.append({"label": "Packet Flood", "value": "rooted"})
|
||||
if State.running(s, av.disabledUntil):
|
||||
out.append({"label": "Disabled", "value": "disabled"})
|
||||
return out
|
||||
|
||||
|
||||
## The most recent active modifier that lowers an Anomaly's Cores, or null.
|
||||
static func _latest_penalty(s: Dictionary, av: Dictionary) -> Variant:
|
||||
var worst = null
|
||||
for m in State.active_mods(s, av):
|
||||
if m.cores < 0 and (worst == null or m.seq > worst.seq):
|
||||
worst = m
|
||||
return worst
|
||||
|
||||
|
||||
static func _remove_negative(s: Dictionary, r: Dictionary, what: String) -> void:
|
||||
var av := State.anomaly(s, r)
|
||||
if what == "infection":
|
||||
av.infection -= 1
|
||||
elif what == "bug":
|
||||
av.bugs -= 1
|
||||
elif what == "permanent":
|
||||
av.permanentInfection -= 1
|
||||
elif what == "rooted":
|
||||
av.rootedUntil = 0
|
||||
elif what == "disabled":
|
||||
av.disabledUntil = 0
|
||||
elif what.begins_with("hw:"):
|
||||
s.cards[what.substr(3).to_int()].disabledUntil = 0
|
||||
elif what.begins_with("mod:"):
|
||||
var seq := what.substr(4).to_int()
|
||||
av.mods = av.mods.filter(func(m): return m.seq != seq)
|
||||
|
||||
|
||||
static func scripts() -> Dictionary:
|
||||
return {
|
||||
# Reading: one counter per attack declared on this Server, or per capture of it that wasn't an
|
||||
# attack. The -2 applies anywhere while this Program is in play, and doesn't stack with copies.
|
||||
"Recursive Infection": {
|
||||
"text": "Whenever an enemy Anomaly attacks or breaches this Server, place an Infection counter on it. An Anomaly with 3+ Infection counters has -2 Core.",
|
||||
"onAttackDeclared": _recursive_attack,
|
||||
"onBreach": _recursive_breach,
|
||||
"globalCores": func(s, f): return -2 if State.infection_of(State.anomaly(s, f.ref)) >= 3 else 0,
|
||||
},
|
||||
|
||||
# Reading: "owner" is the attacking Anomaly's owner, who picks which of its Hardware is disabled
|
||||
# for that combat.
|
||||
"Memory Parasite": {
|
||||
"text": "Enemy Anomalies attacking this Server have 1 hardware component disabled of the owners choosing.",
|
||||
"onCombatStart": _parasite_combat_start,
|
||||
"resume": {"disable": _parasite_disable},
|
||||
},
|
||||
|
||||
# Reading: installing this card counts, so it can bring a second Virus with it.
|
||||
"Replication Routine": {
|
||||
"text": "When you install a Virus Program on this Server, you may install a second Virus Program from your hand here for no Bandwidth cost.",
|
||||
"onInstall": _replication_install,
|
||||
"resume": {"install": _replication_resume},
|
||||
},
|
||||
|
||||
# Fires on every roll the attacker loses here (with the health rule off, that's every defeat).
|
||||
"Resource Leech": {
|
||||
"text": "Whenever an enemy Anomaly takes damage while attacking this Server, gain 3 Gb.",
|
||||
"onDamage": _leech_damage,
|
||||
},
|
||||
|
||||
"Worm Protocol": {
|
||||
"text": "The localized effects of your other Programs on this Server also apply at one adjacent Server you choose when this is installed.",
|
||||
"onInstall": _worm_install,
|
||||
"resume": {"spread": _worm_spread},
|
||||
},
|
||||
|
||||
"Payload Injector": {
|
||||
"text": "The first Execution you play targeting this Server each round costs 2 less Gb.",
|
||||
"costMod": _payload_cost,
|
||||
"onPaid": _payload_paid,
|
||||
},
|
||||
|
||||
# Enemy Anomalies are only ever at this location while attacking it. The counter survives defeat.
|
||||
"Persistent Infection": {
|
||||
"text": "Whenever an enemy Anomaly takes damage at this Server, place an Infection counter on it permanently.",
|
||||
"onDamage": _persistent_damage,
|
||||
},
|
||||
|
||||
# Reading: your Anomaly attacking from this Server may declare a second attack on another
|
||||
# adjacent location. Both come from this Server, even if the first one moved it.
|
||||
"Infinite Loop": {
|
||||
"text": "If the attacking Anomaly is controlled by the owner of this Program, it may attack a second adjacent Server in the same command.",
|
||||
"extraAttacks": 1,
|
||||
},
|
||||
|
||||
"Stack Overflow": {
|
||||
"text": "Anomalies you control defending this Server gain +1 Core for each Program installed on this Server (including this one).",
|
||||
"cores": _stack_overflow_cores,
|
||||
},
|
||||
|
||||
# Both players pick at the same time; the attacker's pick stays hidden from the defender.
|
||||
"Race Condition": {
|
||||
"text": "During any combat at this Server, both players secretly choose Attack or Defend. If the choices differ, the defender gains a combat bonus of +2 Cores.",
|
||||
"onCombatStart": _race_combat_start,
|
||||
"resume": {"pick": _race_pick},
|
||||
},
|
||||
|
||||
"Bloatware": {
|
||||
"text": "At the start of any combat at this Server, the attacking Anomaly loses 1 Core for each Hardware installed on it.",
|
||||
"onCombatStart": _bloatware_combat_start,
|
||||
},
|
||||
|
||||
"Null Pointer": {
|
||||
"text": "Once per round, when an enemy Execution would resolve at this Server, it's effect does not occur.",
|
||||
"negates": _null_pointer_negates,
|
||||
},
|
||||
|
||||
# Reading: "Hardware bonuses" are the Cores Hardware adds.
|
||||
"Stock Rice": {
|
||||
"text": "Neither Anomaly in a combat that takes place at this Server may use any Hardware bonuses.",
|
||||
"blocksHardwareInCombat": true,
|
||||
"onCombatStart": _stock_rice_combat_start,
|
||||
},
|
||||
|
||||
# Every lost roll disables a Program until its controller's next command; a destroyed attacker
|
||||
# lets the owner destroy it instead.
|
||||
"Overflow Error": {
|
||||
"text": "When an enemy Anomaly takes damage while attacking this Server, disable one Program its controller has in play until their next command. If the Anomaly was destroyed, you may destroy that Program instead.",
|
||||
"onDamage": _overflow_damage,
|
||||
"resume": {"hit": _overflow_hit},
|
||||
},
|
||||
|
||||
# Reading: the copy lasts until your next turn, while this Program is disabled.
|
||||
"Undefined Behavior": {
|
||||
"text": "Once per round, copy the localized effect of another Program on another Server. Then disable this Program until your next command.",
|
||||
"ability": {"uses": _undefined_uses, "resolve": _undefined_resolve},
|
||||
},
|
||||
|
||||
"Packet Loss": {
|
||||
"text": "When an enemy successfully breaches this Server, its controller discards a card at random.",
|
||||
"onBreach": _packet_loss_breach,
|
||||
},
|
||||
|
||||
# The once-per-turn Hardware abilities are Hot-Swap Bay's and Quantum Coprocessor's.
|
||||
"Desynchronization": {
|
||||
"text": "Enemy Anomalies attacking this Server cannot use their Hardware's \"once per round\" abilities during that combat.",
|
||||
"blocksHardwareAbilities": true,
|
||||
},
|
||||
|
||||
# Reading: "each turn" was removed from the card, so this works once per installation.
|
||||
"Visual Artifact": {
|
||||
"text": "The first attack made against an Anomaly you control at this Server suffers -1 Core.",
|
||||
"onCombatStart": _artifact_combat_start,
|
||||
},
|
||||
|
||||
# Executions check for this through CardUtil.scope_of().
|
||||
"Ghost Process": {
|
||||
"text": "Your Executions played targeting this Server may also affect Anomalies, Programs, and Hardware at one adjacent Server.",
|
||||
},
|
||||
|
||||
# Runs from the engine right after an enemy Execution that targets an Anomaly is played.
|
||||
"False Positive": {
|
||||
"text": "When an enemy Execution targets an Anomaly you control at this Server, you may redirect it to another legal Anomaly at another Server.",
|
||||
"resume": {"offer": _false_positive_offer, "redirect": _false_positive_redirect},
|
||||
},
|
||||
|
||||
"Fragmentation": {
|
||||
"text": "Executions your opponents play targeting this Server cost +2 Gb.",
|
||||
"costMod": func(_s, src, pay): return 2 if pay.kind == "execution" and pay.player != src.controller and pay.get("at") == src.at else 0,
|
||||
"onPaid": func(s, src, _pay): State.fired(s, "Fragmentation", src.controller),
|
||||
},
|
||||
|
||||
"Latency Spike": {
|
||||
"text": "The attacking player cannot play Executions during the first step of any combat at this Server.",
|
||||
"blocksAttackerExecutions": true,
|
||||
},
|
||||
|
||||
# Destroyed means destroyed by an effect (Overflow Error). A captured location's Programs aren't
|
||||
# destroyed; they're discarded (see Version Control).
|
||||
"Hotfix": {
|
||||
"text": "The first Program on this Server that would be destroyed each round is instead disabled until your next command.",
|
||||
},
|
||||
|
||||
"Error Correction": {
|
||||
"text": "At the beginning of your first command each round, remove one negative counter or status from each Anomaly you control at this Server.",
|
||||
"onTurnStart": _error_correction_turn_start,
|
||||
"resume": {"fix": _error_correction_fix, "remove": func(s, data, what): _remove_negative(s, data.ref, what)},
|
||||
},
|
||||
|
||||
# Reading: it can sacrifice itself.
|
||||
"Garbage Collection": {
|
||||
"text": "Once per round, sacrifice one Program installed on this Server to recover its printed Bandwidth value.",
|
||||
"ability": {"uses": _garbage_uses, "resolve": _garbage_resolve},
|
||||
},
|
||||
|
||||
"Version Control": {
|
||||
"text": "When a Program on this Server would be destroyed, or when this Server is captured, return one Program from this Server to your hand instead of discarding it.",
|
||||
"onCaptured": _version_captured,
|
||||
"resume": {"save": _version_save},
|
||||
},
|
||||
|
||||
"Rollback Routine": {
|
||||
"text": "Once per round, undo the most recent temporary stat reduction applied to an Anomaly you control at this Server.",
|
||||
"ability": {"uses": _rollback_uses, "resolve": _rollback_resolve},
|
||||
},
|
||||
|
||||
"Compatibility Layer": {
|
||||
"text": "This Server may hold one additional Program beyond the normal limit, and Patch Programs installed here cost 2 less Gb.",
|
||||
"programSlots": 1,
|
||||
"costMod": func(s, src, pay): return -2 if pay.kind == "program" and pay.player == src.controller and pay.get("at") == src.at and CardUtil.is_patch(s, pay.card) else 0,
|
||||
"onPaid": func(s, src, _pay): State.fired(s, "Compatibility Layer", src.controller),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Recursive Infection
|
||||
|
||||
static func _recursive_attack(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.to == src.at and _enemy_of(src, ev.ref):
|
||||
CardUtil.infect(s, ev.ref, 1, "Recursive Infection", src.controller)
|
||||
|
||||
|
||||
static func _recursive_breach(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.loc != src.at or not _enemy_of(src, ev.ref):
|
||||
return
|
||||
for d in s.declarations:
|
||||
if d.kind == "attack" and State.same_ref(d.ref, ev.ref) and d.to == ev.loc:
|
||||
return
|
||||
CardUtil.infect(s, ev.ref, 1, "Recursive Infection", src.controller)
|
||||
|
||||
|
||||
# Memory Parasite
|
||||
|
||||
static func _parasite_combat_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
var c: Dictionary = s.combat
|
||||
if c.loc != src.at or not _enemy_of(src, c.attacker):
|
||||
return
|
||||
var hw: Array = State.hardware_of(s, c.attacker).filter(func(h): return Query.hardware_active(s, h) and not c.suppressed.has(h))
|
||||
if hw.is_empty():
|
||||
return
|
||||
State.fired(s, "Memory Parasite", src.controller)
|
||||
if hw.size() == 1:
|
||||
c.suppressed.append(hw[0])
|
||||
State.say(s, "Memory Parasite disables %s for this combat." % State.name_of(s, hw[0]))
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": c.attacker.player,
|
||||
"kind": "Memory Parasite:disable",
|
||||
"prompt": "Memory Parasite: which of your Hardware is disabled for this combat?",
|
||||
"options": hw.map(func(h): return {"label": State.name_of(s, h), "value": h}),
|
||||
"resume": {"name": "Memory Parasite", "fn": "disable", "data": null},
|
||||
})
|
||||
|
||||
|
||||
static func _parasite_disable(s: Dictionary, _data: Variant, hw: Variant) -> void:
|
||||
if s.combat != null:
|
||||
s.combat.suppressed.append(hw)
|
||||
|
||||
|
||||
# Replication Routine
|
||||
|
||||
static func _replication_install(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if not src.at or ev.at != src.at or src.get("virtual") != null or not CardUtil.is_virus(s, ev.card):
|
||||
return
|
||||
if s.locations[src.at].programs.size() >= Query.program_slots(s, src.at):
|
||||
return
|
||||
var hand: Array = s.players[src.controller].hand.filter(func(id): return CardUtil.is_virus(s, id))
|
||||
if hand.is_empty():
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Replication Routine:install",
|
||||
"prompt": "Replication Routine: install a second Virus Program on %s for free?" % src.at,
|
||||
"options": [{"label": "No", "value": null}] + CardUtil.card_options(s, hand),
|
||||
"resume": {"name": "Replication Routine", "fn": "install", "data": {"at": src.at}},
|
||||
})
|
||||
|
||||
|
||||
static func _replication_resume(s: Dictionary, data: Dictionary, card: Variant) -> void:
|
||||
if card == null or not State.controls(s, State.owner_of(s, card), data.at):
|
||||
return
|
||||
if s.locations[data.at].programs.size() >= Query.program_slots(s, data.at):
|
||||
return
|
||||
State.fired(s, "Replication Routine", State.owner_of(s, card))
|
||||
_install_free(s, card, data.at)
|
||||
|
||||
|
||||
# Resource Leech, Persistent Infection
|
||||
|
||||
static func _leech_damage(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.loc != src.at or ev.role != "attack" or not _enemy_of(src, ev.ref):
|
||||
return
|
||||
State.gain_bandwidth(s, src.controller, 3)
|
||||
State.fired(s, "Resource Leech", src.controller)
|
||||
State.say(s, "Resource Leech: %s gains 3 Gb." % State.player_name(src.controller))
|
||||
|
||||
|
||||
static func _persistent_damage(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.loc != src.at or not _enemy_of(src, ev.ref) or State.is_copy(ev.ref):
|
||||
return
|
||||
CardUtil.infect(s, ev.ref, 1, "Persistent Infection", src.controller, true)
|
||||
|
||||
|
||||
# Worm Protocol
|
||||
|
||||
static func _worm_install(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.card != src.id or src.get("virtual") != null:
|
||||
return
|
||||
var near := State.neighbors(s, src.at)
|
||||
if near.is_empty():
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Worm Protocol:spread",
|
||||
"prompt": "Worm Protocol on %s: spread your other Programs' effects to which adjacent location?" % src.at,
|
||||
"options": near.map(func(l): return {"label": l, "value": l}),
|
||||
"resume": {"name": "Worm Protocol", "fn": "spread", "data": {"card": src.id}},
|
||||
})
|
||||
|
||||
|
||||
static func _worm_spread(s: Dictionary, data: Dictionary, to: Variant) -> void:
|
||||
s.cards[data.card].wormTo = to
|
||||
State.fired(s, "Worm Protocol", State.owner_of(s, data.card))
|
||||
|
||||
|
||||
# Payload Injector
|
||||
|
||||
static func _payload_cost(s: Dictionary, src: Dictionary, pay: Dictionary) -> int:
|
||||
return -2 if pay.kind == "execution" and pay.player == src.controller and pay.get("at") == src.at \
|
||||
and State.used_this_turn(s, "payload:%d" % src.id) == 0 else 0
|
||||
|
||||
|
||||
static func _payload_paid(s: Dictionary, src: Dictionary, _pay: Dictionary) -> void:
|
||||
State.mark_used(s, "payload:%d" % src.id)
|
||||
State.fired(s, "Payload Injector", src.controller)
|
||||
|
||||
|
||||
# Stack Overflow
|
||||
|
||||
static func _stack_overflow_cores(s: Dictionary, src: Dictionary, f: Dictionary) -> int:
|
||||
if f.role == "defend" and f.at == src.at and f.ref.player == src.controller:
|
||||
return Query.installed_count(s, src.at)
|
||||
return 0
|
||||
|
||||
|
||||
# Race Condition
|
||||
|
||||
static func _race_combat_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
var c: Dictionary = s.combat
|
||||
if c.loc != src.at or not _first_here(s, src, c.loc):
|
||||
return
|
||||
State.fired(s, "Race Condition", src.controller)
|
||||
_ask_race(s, c.attacker.player)
|
||||
|
||||
|
||||
static func _race_pick(s: Dictionary, data: Dictionary, pick: Variant) -> void:
|
||||
var c = s.combat
|
||||
if c == null or c.ended:
|
||||
return
|
||||
c.race[data.player] = pick
|
||||
var defender: int = c.defenders[0].player if not c.defenders.is_empty() else State.other(c.attacker.player)
|
||||
if data.player == c.attacker.player:
|
||||
_ask_race(s, defender)
|
||||
return
|
||||
var a = c.race[c.attacker.player]
|
||||
var d = c.race[defender]
|
||||
State.say(s, "Race Condition: attacker chose %s, defender chose %s." % [Util.js(a), Util.js(d)])
|
||||
if a != d and not c.defenders.is_empty():
|
||||
State.add_mod(s, c.defenders[0], 2, "Race Condition", defender, {"combat": c.id})
|
||||
State.say(s, "The choices differ: the defender gets +2 Cores.")
|
||||
|
||||
|
||||
static func _ask_race(s: Dictionary, player: int) -> void:
|
||||
State.ask(s, {
|
||||
"player": player,
|
||||
"kind": "Race Condition:pick",
|
||||
"secret": true,
|
||||
"prompt": "Race Condition: secretly choose Attack or Defend.",
|
||||
"options": [{"label": "Attack", "value": "attack"}, {"label": "Defend", "value": "defend"}],
|
||||
"resume": {"name": "Race Condition", "fn": "pick", "data": {"player": player}},
|
||||
})
|
||||
|
||||
|
||||
# Bloatware, Stock Rice, Visual Artifact
|
||||
|
||||
static func _bloatware_combat_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
var c: Dictionary = s.combat
|
||||
if c.loc != src.at or not _enemy_of(src, c.attacker) or Query.bug_immune(s, c.attacker, src.controller):
|
||||
return
|
||||
var n: int = State.hardware_of(s, c.attacker).size()
|
||||
if n == 0:
|
||||
return
|
||||
State.add_mod(s, c.attacker, -n, "Bloatware", src.controller, {"combat": c.id})
|
||||
State.fired(s, "Bloatware", src.controller)
|
||||
State.say(s, "Bloatware: %s loses %d Core%s." % [State.anomaly_name(s, c.attacker), n, "" if n == 1 else "s"])
|
||||
|
||||
|
||||
static func _stock_rice_combat_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
if s.combat.loc == src.at:
|
||||
State.fired(s, "Stock Rice", src.controller)
|
||||
|
||||
|
||||
static func _artifact_combat_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
var c: Dictionary = s.combat
|
||||
if c.loc != src.at or s.cards[src.id].get("spent", false):
|
||||
return
|
||||
var guarding := false
|
||||
for d in c.defenders:
|
||||
if d.player == src.controller:
|
||||
guarding = true
|
||||
if not guarding:
|
||||
return
|
||||
s.cards[src.id].spent = true
|
||||
State.add_mod(s, c.attacker, -1, "Visual Artifact", src.controller, {"combat": c.id})
|
||||
State.fired(s, "Visual Artifact", src.controller)
|
||||
State.say(s, "Visual Artifact: %s gets -1 Core." % State.anomaly_name(s, c.attacker))
|
||||
|
||||
|
||||
# Null Pointer
|
||||
|
||||
static func _null_pointer_negates(s: Dictionary, src: Dictionary, item: Dictionary) -> bool:
|
||||
if item.player == src.controller or item.target != src.at or State.used_this_turn(s, "null:%d" % src.id) > 0:
|
||||
return false
|
||||
State.mark_used(s, "null:%d" % src.id)
|
||||
State.fired(s, "Null Pointer", src.controller)
|
||||
State.say(s, "Null Pointer: %s has no effect." % item.name)
|
||||
return true
|
||||
|
||||
|
||||
# Overflow Error
|
||||
|
||||
static func _overflow_damage(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.loc != src.at or ev.role != "attack" or not _enemy_of(src, ev.ref):
|
||||
return
|
||||
var theirs := []
|
||||
for l in GameMap.LOCATIONS:
|
||||
if State.controls(s, ev.ref.player, l):
|
||||
for id in CardUtil.programs_on(s, l):
|
||||
if Query.can_target_program(s, id, src.controller):
|
||||
theirs.append(id)
|
||||
if theirs.is_empty():
|
||||
return
|
||||
State.fired(s, "Overflow Error", src.controller)
|
||||
var options := []
|
||||
for id in theirs:
|
||||
var where := "%s on %s" % [State.name_of(s, id), State.program_location(s, id)]
|
||||
if ev.destroyed:
|
||||
options.append({"label": "Destroy %s" % where, "value": {"card": id, "mode": "destroy"}})
|
||||
options.append({"label": "Disable %s" % where, "value": {"card": id, "mode": "disable"}})
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Overflow Error:hit",
|
||||
"prompt": "Overflow Error: destroy or disable one of their Programs." if ev.destroyed else "Overflow Error: disable one of their Programs.",
|
||||
"options": options,
|
||||
"resume": {"name": "Overflow Error", "fn": "hit", "data": null},
|
||||
})
|
||||
|
||||
|
||||
static func _overflow_hit(s: Dictionary, _data: Variant, v: Variant) -> void:
|
||||
if State.program_location(s, v.card) == null:
|
||||
return
|
||||
if v.mode == "destroy":
|
||||
destroy_program(s, v.card)
|
||||
else:
|
||||
var until := State.start_of(State.next_turn_of(s, State.owner_of(s, v.card)))
|
||||
s.cards[v.card].disabledUntil = maxi(s.cards[v.card].disabledUntil, until)
|
||||
|
||||
|
||||
# Undefined Behavior
|
||||
|
||||
static func _undefined_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
if src.kind != "program" or src.get("virtual") != null:
|
||||
return []
|
||||
var out := []
|
||||
for l in GameMap.LOCATIONS:
|
||||
if l == src.at:
|
||||
continue
|
||||
for id in CardUtil.programs_on(s, l):
|
||||
if State.name_of(s, id) != "Undefined Behavior" and Query.can_target_program(s, id, src.controller):
|
||||
out.append({"card": id})
|
||||
return out
|
||||
|
||||
|
||||
static func _undefined_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) == null:
|
||||
return
|
||||
var until := State.start_of(State.next_turn_of(s, src.controller))
|
||||
s.seq += 1
|
||||
s.virtuals.append({"id": s.seq, "name": State.name_of(s, card), "controller": src.controller, "at": src.at, "until": until, "installed": false, "from": card})
|
||||
s.cards[src.id].disabledUntil = maxi(s.cards[src.id].disabledUntil, until)
|
||||
State.fired(s, "Undefined Behavior", src.controller)
|
||||
State.say(s, "Undefined Behavior on %s copies %s and shuts itself off until %s's next turn." % [src.at, State.name_of(s, card), State.player_name(src.controller)])
|
||||
|
||||
|
||||
# Packet Loss
|
||||
|
||||
static func _packet_loss_breach(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.loc != src.at or not _enemy_of(src, ev.ref):
|
||||
return
|
||||
var hand: Array = s.players[ev.ref.player].hand
|
||||
if hand.is_empty():
|
||||
return
|
||||
var card: int = hand[Rng.rand_int(s.rng, hand.size())]
|
||||
State.remove_from(hand, card)
|
||||
State.to_discard(s, card)
|
||||
State.fired(s, "Packet Loss", src.controller)
|
||||
State.say(s, "Packet Loss: %s discards %s at random." % [State.player_name(ev.ref.player), State.name_of(s, card)])
|
||||
|
||||
|
||||
# False Positive
|
||||
|
||||
static func _false_positive_offer(s: Dictionary, data: Dictionary, _value: Variant) -> void:
|
||||
if data.index >= s.stack.size():
|
||||
return
|
||||
var item: Dictionary = s.stack[data.index]
|
||||
var ex: Dictionary = CardScripts.of(item.name).get("execution", {})
|
||||
var hit: Array = ex.targetsAnomalies.call(s, item) if ex.has("targetsAnomalies") else []
|
||||
var guarded = null
|
||||
for r in hit:
|
||||
if r.player == item.player:
|
||||
continue
|
||||
var at = State.anomaly(s, r).at
|
||||
for x in Query.sources(s):
|
||||
if x.name == "False Positive" and x.at == at and x.controller == r.player:
|
||||
guarded = r
|
||||
break
|
||||
if guarded != null:
|
||||
break
|
||||
if ex.is_empty() or guarded == null:
|
||||
return
|
||||
var from = State.anomaly(s, guarded).at
|
||||
var options := [{"label": "Leave it", "value": null}]
|
||||
for play in ex.plays.call(s, item.player):
|
||||
var refs: Array = ex.targetsAnomalies.call(s, {"player": item.player, "target": play.target, "args": play.args}) if ex.has("targetsAnomalies") else []
|
||||
if refs.is_empty():
|
||||
continue
|
||||
var away := true
|
||||
for r in refs:
|
||||
if State.anomaly(s, r).at == from or State.same_ref(r, guarded):
|
||||
away = false
|
||||
if not away:
|
||||
continue
|
||||
var whom := State.anomaly_name(s, play.args.ref) if play.args.get("ref") != null else State.name_of(s, play.args.get("card", -1))
|
||||
options.append({"label": "Redirect to %s on %s" % [whom, Util.js(play.target)], "value": {"index": data.index, "target": play.target, "args": play.args}})
|
||||
if options.size() == 1:
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": guarded.player,
|
||||
"kind": "False Positive:redirect",
|
||||
"prompt": "False Positive: redirect %s away from %s?" % [item.name, State.anomaly_name(s, guarded)],
|
||||
"options": options,
|
||||
"resume": {"name": "False Positive", "fn": "redirect", "data": null},
|
||||
})
|
||||
|
||||
|
||||
static func _false_positive_redirect(s: Dictionary, _data: Variant, v: Variant) -> void:
|
||||
if v == null or v.index >= s.stack.size():
|
||||
return
|
||||
var item: Dictionary = s.stack[v.index]
|
||||
item.target = v.target
|
||||
item.args = v.args
|
||||
State.fired(s, "False Positive", State.other(item.player))
|
||||
|
||||
|
||||
# Error Correction
|
||||
|
||||
static func _error_correction_turn_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
if s.active != src.controller:
|
||||
return
|
||||
var tasks := []
|
||||
for r in State.refs_in_play(s, src.controller):
|
||||
if State.anomaly(s, r).at == src.at:
|
||||
tasks.append(State.later("Error Correction", "fix", {"ref": r}))
|
||||
State.push_tasks(s, tasks)
|
||||
|
||||
|
||||
static func _error_correction_fix(s: Dictionary, data: Dictionary, _value: Variant) -> void:
|
||||
var list := _negatives(s, data.ref)
|
||||
if list.is_empty():
|
||||
return
|
||||
State.fired(s, "Error Correction", data.ref.player)
|
||||
if list.size() == 1:
|
||||
_remove_negative(s, data.ref, list[0].value)
|
||||
State.say(s, "Error Correction removes %s from %s." % [list[0].label, State.anomaly_name(s, data.ref)])
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": data.ref.player,
|
||||
"kind": "Error Correction:remove",
|
||||
"prompt": "Error Correction: remove what from %s?" % State.anomaly_name(s, data.ref),
|
||||
"options": list,
|
||||
"resume": {"name": "Error Correction", "fn": "remove", "data": {"ref": data.ref}},
|
||||
})
|
||||
|
||||
|
||||
# Garbage Collection
|
||||
|
||||
static func _garbage_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
if src.kind != "program":
|
||||
return []
|
||||
return s.locations[src.at].programs.map(func(card): return {"card": card})
|
||||
|
||||
|
||||
static func _garbage_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var card: int = item.args.card
|
||||
if State.program_location(s, card) != src.at:
|
||||
return
|
||||
State.uninstall_program(s, card)
|
||||
State.to_discard(s, card)
|
||||
State.stat(s, "programsLost", src.controller)
|
||||
State.gain_bandwidth(s, src.controller, State.def_of(s, card).bandwidth)
|
||||
State.fired(s, "Garbage Collection", src.controller)
|
||||
State.say(s, "Garbage Collection sacrifices %s for %d Gb." % [State.name_of(s, card), State.def_of(s, card).bandwidth])
|
||||
|
||||
|
||||
# Version Control
|
||||
|
||||
static func _version_captured(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.loc != src.at or src.get("virtual") != null:
|
||||
return
|
||||
var here: Array = s.locations[ev.loc].programs
|
||||
if here.is_empty():
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Version Control:save",
|
||||
"prompt": "Version Control: %s is being captured. Return which Program to your hand?" % ev.loc,
|
||||
"options": here.map(func(id): return {"label": State.name_of(s, id), "value": id}),
|
||||
"resume": {"name": "Version Control", "fn": "save", "data": null},
|
||||
})
|
||||
|
||||
|
||||
static func _version_save(s: Dictionary, _data: Variant, card: Variant) -> void:
|
||||
if State.uninstall_program(s, card) == null:
|
||||
return
|
||||
State.to_hand(s, card)
|
||||
State.fired(s, "Version Control", State.owner_of(s, card))
|
||||
State.say(s, "Version Control returns %s to %s's hand." % [State.name_of(s, card), State.player_name(State.owner_of(s, card))])
|
||||
|
||||
|
||||
# Rollback Routine
|
||||
|
||||
static func _rollback_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
if src.kind != "program":
|
||||
return []
|
||||
var out := []
|
||||
for r in State.refs_in_play(s, src.controller):
|
||||
if State.anomaly(s, r).at == src.at and _latest_penalty(s, State.anomaly(s, r)) != null:
|
||||
out.append({"ref": r})
|
||||
return out
|
||||
|
||||
|
||||
static func _rollback_resolve(s: Dictionary, item: Dictionary, src: Dictionary) -> void:
|
||||
var av := State.anomaly(s, item.args.ref)
|
||||
if av.at != src.at:
|
||||
return
|
||||
var last = _latest_penalty(s, av)
|
||||
if last == null:
|
||||
return
|
||||
av.mods = av.mods.filter(func(m): return m.seq != last.seq)
|
||||
State.fired(s, "Rollback Routine", src.controller)
|
||||
State.say(s, "Rollback Routine undoes %d Cores from %s on %s." % [last.cores, last.source, State.anomaly_name(s, item.args.ref)])
|
||||
1
engine/cards/programs.gd.uid
Normal file
1
engine/cards/programs.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://q4cltmsskkvf
|
||||
195
engine/cards/servers.gd
Normal file
195
engine/cards/servers.gd
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
class_name ServerCards
|
||||
## Servers (cards/servers.ts). A Server's ability belongs to the player who controls its location and
|
||||
## applies at that location, unless the text says otherwise.
|
||||
|
||||
|
||||
static func scripts() -> Dictionary:
|
||||
return {
|
||||
"High Bandwidth Server": {"text": "Add additional 4 Gb to resource total", "bandwidthOnPlace": 4},
|
||||
"Power Server": {"text": "Add additional 4 Gb to resource total", "bandwidthOnPlace": 4},
|
||||
"Server Farm": {
|
||||
"text": "Add 4 Gb to resource total and 2 Cores to any Anomaly",
|
||||
"bandwidthOnPlace": 4,
|
||||
"cores": _core_bonus.bind(2),
|
||||
},
|
||||
"MultiCore Server": {"text": "Add 2 Cores to any Anomalies", "cores": _core_bonus.bind(2)},
|
||||
"Cloud Compute": {"text": "Add 4 Cores to any Anomalies", "cores": _core_bonus.bind(4)},
|
||||
"Cluster Server": {"text": "Up to 2 Anomalies can defend this Server", "capacity": 2},
|
||||
"Pingable Server": {"text": "Up to 2 Anomalies can defend this Server", "capacity": 2},
|
||||
|
||||
# Reading: once per turn, at any time, make a copy of your Anomaly based here (Carbon NanoBots'
|
||||
# copy rules). The copy enters play on any location you control with room.
|
||||
"Backup Server": {
|
||||
"text": "Duplicate Anomaly based at this Server",
|
||||
"ability": {"uses": _backup_uses, "resolve": _backup_resolve},
|
||||
},
|
||||
|
||||
"Upgraded Hardware": {
|
||||
"text": "Hardware upgrades cost 2 less Gb to install",
|
||||
"costMod": _upgraded_cost,
|
||||
"onPaid": _fired_by_controller.bind("Upgraded Hardware"),
|
||||
},
|
||||
|
||||
"Network Throttle": {
|
||||
"text": "Firewalls cost 1 less Gb to install",
|
||||
"costMod": _throttle_cost,
|
||||
"onPaid": _fired_by_controller.bind("Network Throttle"),
|
||||
},
|
||||
|
||||
# Reading: when placed, pick one adjacent Server (either player's) and gain its ability for as
|
||||
# long as this card stays. A copied Bandwidth bonus is paid right away.
|
||||
"Duplicate Server": {
|
||||
"text": "Copy one adjacent Server ability",
|
||||
"onPlaced": _duplicate_placed,
|
||||
"resume": {"copy": _duplicate_copy},
|
||||
},
|
||||
|
||||
"Protected Server": {
|
||||
"text": "Add 2 Gb if defending this Server",
|
||||
"onCombatStart": _protected_combat_start,
|
||||
},
|
||||
|
||||
# Reading: applies to every draw after the opening hand, once per card drawn.
|
||||
"Callable Server": {
|
||||
"text": "When drawing a card, you may choose to place it on the bottom of the deck and draw another",
|
||||
"onDraw": _callable_draw,
|
||||
"resume": {"redraw": _callable_redraw},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
## Core bonus for the controller's Anomaly standing on this Server (attacking from it or defending it).
|
||||
static func _core_bonus(_s: Dictionary, src: Dictionary, f: Dictionary, n: int) -> int:
|
||||
return n if f.at == src.at and f.ref.player == src.controller else 0
|
||||
|
||||
|
||||
static func _fired_by_controller(s: Dictionary, src: Dictionary, _pay: Dictionary, card_name: String) -> void:
|
||||
State.fired(s, card_name, src.controller)
|
||||
|
||||
|
||||
# Backup Server
|
||||
|
||||
static func _backup_uses(s: Dictionary, src: Dictionary) -> Array:
|
||||
var p: int = src.controller
|
||||
if not Query.can_copy(s, p):
|
||||
return []
|
||||
var spots: Array = GameMap.LOCATIONS.filter(func(l): return Query.has_room(s, p, l))
|
||||
var out := []
|
||||
for r in State.refs_in_play(s, p):
|
||||
if not State.is_copy(r) and State.anomaly(s, r).at == src.at and State.anomaly(s, State.copy_of(r)).at == null:
|
||||
for to in spots:
|
||||
out.append({"ref": r, "to": to})
|
||||
return out
|
||||
|
||||
|
||||
static func _backup_resolve(s: Dictionary, item: Dictionary, _src: Dictionary) -> void:
|
||||
var r: Dictionary = item.args.ref
|
||||
var to: String = item.args.to
|
||||
if State.anomaly(s, r).at == null or State.anomaly(s, State.copy_of(r)).at != null or not Query.can_copy(s, r.player) \
|
||||
or not Query.has_room(s, r.player, to):
|
||||
return
|
||||
State.fired(s, "Backup Server", r.player)
|
||||
Flow.create_copy(s, r, to)
|
||||
|
||||
|
||||
# Upgraded Hardware, Network Throttle
|
||||
|
||||
static func _upgraded_cost(_s: Dictionary, src: Dictionary, pay: Dictionary) -> int:
|
||||
return -2 if pay.kind == "hardware" and pay.player == src.controller and pay.get("at") == src.at else 0
|
||||
|
||||
|
||||
static func _throttle_cost(_s: Dictionary, src: Dictionary, pay: Dictionary) -> int:
|
||||
if pay.kind != "firewall" or pay.player != src.controller:
|
||||
return 0
|
||||
var line: Dictionary = GameMap.LINE_BY_ID[pay.line]
|
||||
return -1 if line.a == src.at or line.b == src.at else 0
|
||||
|
||||
|
||||
# Duplicate Server
|
||||
|
||||
static func _duplicate_placed(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.card != src.id or src.get("virtual") != null:
|
||||
return
|
||||
var names := []
|
||||
for n in State.neighbors(s, src.at):
|
||||
var sv = s.locations[n].server
|
||||
if sv != null and State.name_of(s, sv) != "Duplicate Server" and not names.has(State.name_of(s, sv)):
|
||||
names.append(State.name_of(s, sv))
|
||||
if names.is_empty():
|
||||
return
|
||||
State.ask(s, {
|
||||
"player": src.controller,
|
||||
"kind": "Duplicate Server:copy",
|
||||
"prompt": "Duplicate Server on %s: copy which adjacent Server?" % src.at,
|
||||
"options": names.map(func(n): return {"label": n, "value": n}),
|
||||
"resume": {"name": "Duplicate Server", "fn": "copy", "data": {"card": src.id, "player": src.controller}},
|
||||
})
|
||||
|
||||
|
||||
static func _duplicate_copy(s: Dictionary, data: Dictionary, server_name: String) -> void:
|
||||
s.cards[data.card].copies = server_name
|
||||
var p: int = data.player
|
||||
State.fired(s, "Duplicate Server", p)
|
||||
State.say(s, "Duplicate Server copies %s." % server_name)
|
||||
var bonus: int = scripts().get(server_name, {}).get("bandwidthOnPlace", 0)
|
||||
if bonus:
|
||||
State.gain_bandwidth(s, p, bonus, "bandwidthFromCaptures")
|
||||
State.say(s, "%s gains %d Gb from the copied ability." % [State.player_name(p), bonus])
|
||||
|
||||
|
||||
# Protected Server
|
||||
|
||||
static func _protected_combat_start(s: Dictionary, src: Dictionary, _ev: Variant) -> void:
|
||||
var c: Dictionary = s.combat
|
||||
if c.loc != src.at:
|
||||
return
|
||||
var defending := false
|
||||
for d in State.defenders_at(s, c.loc):
|
||||
if d.player == src.controller:
|
||||
defending = true
|
||||
if not defending:
|
||||
return
|
||||
State.gain_bandwidth(s, src.controller, 2)
|
||||
State.fired(s, "Protected Server", src.controller)
|
||||
State.say(s, "Protected Server: %s gains 2 Gb for defending." % State.player_name(src.controller))
|
||||
|
||||
|
||||
# Callable Server
|
||||
|
||||
static func _callable_draw(s: Dictionary, src: Dictionary, ev: Dictionary) -> void:
|
||||
if ev.player != src.controller or s.players[ev.player].deck.is_empty():
|
||||
return
|
||||
var first = null
|
||||
for x in Query.sources_named(s, "Callable Server"):
|
||||
if x.controller == ev.player:
|
||||
first = x
|
||||
break
|
||||
if first == null or not Query.same_source(first, src):
|
||||
return
|
||||
if not s.players[ev.player].hand.has(ev.card):
|
||||
return
|
||||
var nm := State.name_of(s, ev.card)
|
||||
State.ask(s, {
|
||||
"player": ev.player,
|
||||
"kind": "Callable Server:redraw",
|
||||
"secret": true,
|
||||
"prompt": "Callable Server: keep %s, or put it on the bottom and draw another?" % nm,
|
||||
"options": [
|
||||
{"label": "Keep %s" % nm, "value": false},
|
||||
{"label": "Bottom %s and draw again" % nm, "value": true},
|
||||
],
|
||||
"resume": {"name": "Callable Server", "fn": "redraw", "data": {"player": ev.player, "card": ev.card}},
|
||||
})
|
||||
|
||||
|
||||
static func _callable_redraw(s: Dictionary, data: Dictionary, again: Variant) -> void:
|
||||
if not again:
|
||||
return
|
||||
var pl: Dictionary = s.players[data.player]
|
||||
if not State.remove_from(pl.hand, data.card):
|
||||
return
|
||||
pl.deck.append(data.card)
|
||||
State.fired(s, "Callable Server", data.player)
|
||||
Flow.draw_now(s, data.player)
|
||||
s.stats.cardsDrawn[data.player] -= 1
|
||||
State.say(s, "%s bottoms a card and draws again." % State.player_name(data.player))
|
||||
1
engine/cards/servers.gd.uid
Normal file
1
engine/cards/servers.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cs1kmjh8ijwvv
|
||||
106
engine/cards/util.gd
Normal file
106
engine/cards/util.gd
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
class_name CardUtil
|
||||
## Helpers shared by card scripts (cards/util.ts).
|
||||
|
||||
|
||||
## Locations where `p` has Ghost Process working, as a Dictionary used as a set.
|
||||
static func ghosts_of(s: Dictionary, p: int) -> Dictionary:
|
||||
var out := {}
|
||||
for x in Query.sources(s):
|
||||
if x.name == "Ghost Process" and x.controller == p:
|
||||
out[x.at] = true
|
||||
return out
|
||||
|
||||
|
||||
## Locations an Execution played on `target` can reach: Ghost Process adds one adjacent location.
|
||||
## Pass `ghosts` (from ghosts_of) when calling it for many targets.
|
||||
static func scope_of(s: Dictionary, p: int, target: String, ghosts: Variant = null) -> Array:
|
||||
if ghosts == null:
|
||||
ghosts = ghosts_of(s, p)
|
||||
return [target] + State.neighbors(s, target) if ghosts.has(target) else [target]
|
||||
|
||||
|
||||
static func mine(s: Dictionary, p: int, loc: String) -> Array:
|
||||
return State.at_server(s, loc).filter(func(r): return r.player == p)
|
||||
|
||||
|
||||
## Active, installed Programs on a location.
|
||||
static func programs_on(s: Dictionary, loc: String) -> Array:
|
||||
return s.locations[loc].programs.filter(func(id): return Query.program_active(s, id))
|
||||
|
||||
|
||||
static func active_hardware(s: Dictionary, ids: Array) -> Array:
|
||||
return ids.filter(func(id): return Query.hardware_active(s, id))
|
||||
|
||||
|
||||
## Places Bug counters: like Infection counters, for Bug cards. No card places them yet. ECC Memory
|
||||
## stops opponents from placing them.
|
||||
static func add_bugs(s: Dictionary, r: Dictionary, n: int, source: String, by: int) -> bool:
|
||||
if Query.bug_immune(s, r, by):
|
||||
State.say(s, "ECC Memory blocks %s's Bug counters on %s." % [source, State.anomaly_name(s, r)])
|
||||
State.fired(s, "ECC Memory", r.player)
|
||||
return false
|
||||
State.anomaly(s, r).bugs += n
|
||||
State.fired(s, source, by)
|
||||
State.say(s, "%s: %s gets %d Bug counter%s (%d total)." % [source, State.anomaly_name(s, r), n, "" if n == 1 else "s", State.anomaly(s, r).bugs])
|
||||
return true
|
||||
|
||||
|
||||
static func infect(s: Dictionary, r: Dictionary, n: int, source: String, by: int, permanent := false) -> void:
|
||||
var av := State.anomaly(s, r)
|
||||
if permanent:
|
||||
av.permanentInfection += n
|
||||
else:
|
||||
av.infection += n
|
||||
State.fired(s, source, by)
|
||||
State.say(s, "%s: %s gets %s %sInfection counter%s (%d total)." % [source, State.anomaly_name(s, r), "an" if n == 1 else str(n), "permanent " if permanent else "", "" if n == 1 else "s", av.infection + av.permanentInfection])
|
||||
|
||||
|
||||
## One option per distinct card name.
|
||||
static func card_options(s: Dictionary, ids: Array) -> Array:
|
||||
var seen := {}
|
||||
var out := []
|
||||
for id in ids:
|
||||
var nm := State.name_of(s, id)
|
||||
if seen.has(nm):
|
||||
continue
|
||||
seen[nm] = true
|
||||
out.append({"label": nm, "value": id})
|
||||
return out
|
||||
|
||||
|
||||
static func is_virus(s: Dictionary, id: int) -> bool:
|
||||
var d := State.def_of(s, id)
|
||||
return d.kind == "program" and d.type == "V"
|
||||
|
||||
|
||||
static func is_patch(s: Dictionary, id: int) -> bool:
|
||||
var d := State.def_of(s, id)
|
||||
return d.kind == "program" and d.type == "P"
|
||||
|
||||
|
||||
static func whose(p: int) -> String:
|
||||
return State.player_name(p)
|
||||
|
||||
|
||||
## Distinct non-empty subsets of up to 3 items.
|
||||
static func subsets(items: Array) -> Array:
|
||||
var out := []
|
||||
var n := mini(items.size(), 3)
|
||||
for mask in range(1, 1 << n):
|
||||
var sub := []
|
||||
for i in n:
|
||||
if mask & (1 << i):
|
||||
sub.append(items[i])
|
||||
out.append(sub)
|
||||
return out
|
||||
|
||||
|
||||
static func src_label(s: Dictionary, src: Dictionary) -> String:
|
||||
if src.kind == "anomaly":
|
||||
var d := State.def_of(s, src.id)
|
||||
return "%s (%s)" % [Util.js(d.ability.name if d.has("ability") else null), src.name]
|
||||
return src.name
|
||||
|
||||
|
||||
static func every_anomaly_in_play(s: Dictionary) -> Array:
|
||||
return State.refs_in_play(s, 0) + State.refs_in_play(s, 1)
|
||||
1
engine/cards/util.gd.uid
Normal file
1
engine/cards/util.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dgxib28v7i72s
|
||||
Loading…
Add table
Add a link
Reference in a new issue