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: var counters := State.counters_of(State.anomaly(s, r)) State.anomaly(s, r).infection += 1 State.emit_counters(s, r, counters) 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, "hand", "discarded") 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) var counters := State.counters_of(av) av.damage -= healed State.emit_counters(s, src.ref, counters) 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, "discard") 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 State.add_bandwidth(s, data.ref.player, -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 if State.has_events(s): State.emit(s, {"k": "rerolled", "ref": src.ref.duplicate(), "dice": after.duplicate()}) 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)))])