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))