This commit is contained in:
Forrest 2026-10-01 23:01:56 -04:00
parent 0cba7f5ee0
commit 32ed347b58
172 changed files with 5464 additions and 582 deletions

View file

@ -28,6 +28,7 @@ static func draw_now(s: Dictionary, p: int) -> Variant:
var card: int = pl.deck.pop_front()
pl.hand.append(card)
State.stat(s, "cardsDrawn", p)
State.emit(s, {"k": "drew", "p": p, "card": card})
return card
@ -49,16 +50,21 @@ static func _clear_status(av: Dictionary) -> void:
av.damage = 0
## A copy leaves play. It has no Hardware of its own.
static func remove_copy(s: Dictionary, r: Dictionary) -> void:
## A copy leaves play. It has no Hardware of its own. `recalled` is false when a defeat already
## told the events.
static func remove_copy(s: Dictionary, r: Dictionary, recalled := true) -> void:
var cp := State.anomaly(s, r)
if cp.at == null:
return
State.say(s, "%s is removed." % State.anomaly_name(s, r), {"tag": "move", "player": r.player, "ref": r})
var counters := State.counters_of(cp)
if recalled:
State.emit_moved(s, r, cp.at, null)
_clear_status(cp)
cp.permanentInfection = 0
cp.at = null
cp.faceUp = false
State.emit_counters(s, r, counters)
drop_from_combat(s, r)
@ -70,11 +76,11 @@ static func retire_anomaly(s: Dictionary, r: Dictionary) -> void:
if not av.hardware.is_empty():
State.stat(s, "hardwareLost", r.player, av.hardware.size())
for hw in av.hardware:
State.to_discard(s, hw)
State.to_discard(s, hw, "worn", "retired")
var from := " from %s" % av.at if av.at else ""
State.say(s, "%s retires %s%s." % [State.player_name(r.player), State.anomaly_name(s, r), from], {"tag": "card", "player": r.player, "ref": r})
drop_from_combat(s, r)
State.to_discard(s, av.card)
State.to_discard(s, av.card, "slot", "retired")
State.stat(s, "anomaliesRetired", r.player)
@ -84,18 +90,22 @@ static func knock_out(s: Dictionary, r: Dictionary, loc: String, role: String, k
var av := State.anomaly(s, r)
if av.at == null:
return
if State.has_events(s):
State.emit(s, {"k": "destroyed", "ref": r.duplicate(), "loc": av.at})
if State.is_copy(r):
remove_copy(s, r)
remove_copy(s, r, false)
else:
if not keep_hardware and not av.hardware.is_empty():
var names := ", ".join(av.hardware.map(func(h): return State.name_of(s, h)))
State.say(s, "%s loses %s." % [State.player_name(r.player), names], {"tag": "combat", "player": r.player, "ref": r, "loc": loc})
State.stat(s, "hardwareLost", r.player, av.hardware.size())
for hw in av.hardware:
State.to_discard(s, hw)
State.to_discard(s, hw, "worn", "destroyed")
av.hardware = []
var counters := State.counters_of(av)
_clear_status(av)
av.at = null
State.emit_counters(s, r, counters)
State.say(s, "%s returns to its slot." % State.anomaly_name(s, r), {"tag": "combat", "player": r.player, "ref": r, "loc": loc})
remove_copy(s, State.copy_of(r))
State.stat(s, "anomaliesDestroyed", r.player)
@ -112,9 +122,12 @@ static func recall_anomaly(s: Dictionary, r: Dictionary) -> void:
var healed: int = av.damage
var healing := ", healing %d damage" % healed if healed else ""
State.say(s, "%s recalls %s from %s to its slot%s." % [State.player_name(r.player), State.anomaly_name(s, r), av.at, healing], {"tag": "move", "player": r.player, "ref": r, "loc": av.at})
var counters := State.counters_of(av)
State.emit_moved(s, r, av.at, null)
_clear_status(av)
av.at = null
av.placed = true
State.emit_counters(s, r, counters)
remove_copy(s, State.copy_of(r))
State.stat(s, "recalls", r.player)
@ -123,6 +136,8 @@ static func recall_anomaly(s: Dictionary, r: Dictionary) -> void:
static func create_copy(s: Dictionary, original: Dictionary, to: String) -> void:
var r := State.copy_of(original)
var cp := State.anomaly(s, r)
var was = cp.at
var counters := State.counters_of(cp)
cp.merge({
"card": State.anomaly(s, original).card,
"faceUp": true,
@ -141,6 +156,8 @@ static func create_copy(s: Dictionary, original: Dictionary, to: String) -> void
"breachedTurn": 0,
"createdTurn": s.turn,
}, true)
State.emit_moved(s, r, was, to)
State.emit_counters(s, r, counters)
State.say(s, "%s creates %s on %s." % [State.player_name(r.player), State.anomaly_name(s, r), to], {"tag": "card", "player": r.player, "ref": r, "loc": to})
@ -148,6 +165,7 @@ static func create_copy(s: Dictionary, original: Dictionary, to: String) -> void
static func move_anomaly(s: Dictionary, r: Dictionary, to: String) -> void:
var av := State.anomaly(s, r)
State.say(s, "%s moves %s → %s." % [State.anomaly_name(s, r), av.at, to], {"tag": "move", "player": r.player, "ref": r, "loc": to})
State.emit_moved(s, r, av.at, to)
av.at = to
@ -225,6 +243,8 @@ static func _roll_all(s: Dictionary, c: Dictionary) -> void:
break
c.ties += 1
c.rolled = true
if State.has_events(s):
State.emit(s, {"k": "rolled", "loc": c.loc, "dice": c.dice.duplicate(true)})
# ---------------------------------------------------------------------------------------------
@ -241,6 +261,8 @@ static func damage_anomaly(s: Dictionary, r: Dictionary, n: int) -> bool:
if av.at == null or n <= 0:
return false
av.damage += n
if State.has_events(s):
State.emit(s, {"k": "damaged", "ref": r.duplicate(), "amount": n, "loc": av.at})
var dead: bool = av.damage >= Query.health_of(s, r)
var how := " and is destroyed" if dead else " (%s)" % health_text(s, r)
State.say(s, "%s takes %d damage%s." % [State.anomaly_name(s, r), n, how], {"tag": "combat", "player": r.player, "ref": r, "amount": n, "loc": av.at})
@ -327,6 +349,7 @@ static func sync_dice(s: Dictionary, c: Dictionary) -> void:
for r in State.fighters_of(c):
var key := State.ref_key(r)
var dice: Array = c.dice.get(key, [])
var before := dice.duplicate() if State.has_events(s) else []
var want := Query.cores_of(s, Query.fighter_of(s, r))
while dice.size() < want:
dice.append(State.roll_die(s))
@ -334,6 +357,8 @@ static func sync_dice(s: Dictionary, c: Dictionary) -> void:
dice.sort()
dice.resize(want)
c.dice[key] = dice
if State.has_events(s) and dice != before:
State.emit(s, {"k": "rerolled", "ref": r.duplicate(), "dice": dice.duplicate()})
## Current dice totals {atk, def}, after syncing to Core changes.
@ -407,6 +432,9 @@ static func _run_stage(s: Dictionary, c: Dictionary, stage: String) -> void:
var hp := func(r): return ", %s" % health_text(s, r) if s.rules.health.on else ""
var defs := " and ".join(c.defenders.map(func(d): return "%s%s" % [State.anomaly_name(s, d), hp.call(d)]))
State.say(s, "Combat at %s: %s (%d Cores, from %s%s) vs %s (%d Cores)." % [c.loc, State.anomaly_name(s, c.attacker), sides.atk, c.origin, hp.call(c.attacker), defs, sides.def], {"tag": "combat", "player": c.attacker.player, "loc": c.loc, "ref": c.attacker})
if State.has_events(s):
State.emit(s, {"k": "combat", "id": c.id, "loc": c.loc, "attacker": c.attacker.duplicate(),
"defenders": c.defenders.map(func(d): return d.duplicate()), "kind": c.kind})
Query.emit(s, "onCombatStart", null)
return
if stage == "roll":
@ -497,16 +525,22 @@ static func capture_main(s: Dictionary, r: Dictionary, loc: String, how: String)
if State.anomaly(s, r).at == null or State.controls(s, p, loc):
return
var previous = L.owner
State.emit_moved(s, r, State.anomaly(s, r).at, loc)
if State.has_events(s):
State.emit(s, {"k": "captured", "loc": loc, "p": p, "from": previous})
if L.server != null:
State.reset_card(s, L.server)
s.players[s.cards[L.server].owner].serverPile.append(L.server)
State.emit_pile(s, L.server, "serverPile", "play")
if previous != null and not L.programs.is_empty():
State.stat(s, "programsLost", previous, L.programs.size())
for prog in L.programs:
State.to_discard(s, prog)
State.to_discard(s, prog, "play", "captured")
L.programs = []
L.owner = p
L.server = me.serverPile.pop_front() if not me.serverPile.is_empty() else null
if L.server != null:
State.emit_install(s, L.server, "loc:" + loc)
State.anomaly(s, r).at = loc
var level := GameMap.level_for(p, loc)
@ -528,6 +562,7 @@ static func capture_main(s: Dictionary, r: Dictionary, loc: String, how: String)
if i < level and not av.faceUp:
av.faceUp = true
av.unlockedTurn = s.turn
State.emit(s, {"k": "flipped", "ref": State.ref(p, i + 1)})
State.say(s, "%s unlocks Anomaly %d: %s." % [State.player_name(p), i + 1, State.name_of(s, av.card)], {"tag": "capture", "player": p, "loc": loc})
if State.grid_count(s, p) >= s.rules.winLocations:
s.over = true