600 lines
22 KiB
GDScript3
600 lines
22 KiB
GDScript3
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, "worn", "destroyed")
|
|
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, "hand", "discarded")
|
|
|
|
|
|
# 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, "worn" if wearer != null else "play")
|
|
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)
|
|
var counters := State.counters_of(av)
|
|
av.infection = 0
|
|
av.permanentInfection = 0
|
|
State.emit_counters(s, r, counters)
|
|
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, "play")
|
|
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])
|