feat: add active effects inspector to tile drawer

- Track active effects with human-readable labels in AbilitySystem
  (LabelFromReversal/LabelFromTick for stat mods, status flags, DOT/HOT)
- Add ActiveEffectDto to GameStateDto and GameStateDelta; delta now
  always includes the full effects list so clients are never stale
- Add ResolveLabelFromEffectJson fallback for effects stored before the
  Label field was introduced (old game sessions show correct labels)
- Client _append_active_effect_lines helper filters activeEffects by
  targetRef and appends formatted lines to the tile drawer for spirits,
  archspirits, spirit tokens, and ruins

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-04-14 11:52:37 -04:00
co-authored by Claude Happy
parent 144ad84cac
commit b4062d8179
8 changed files with 239 additions and 6 deletions
+5
View File
@@ -551,6 +551,11 @@ func _apply_delta(delta: Dictionary) -> void:
if meta.has("activePlayerAccountId") and meta["activePlayerAccountId"] != null: state["activePlayerAccountId"] = meta["activePlayerAccountId"]
if meta.has("turnNumber") and meta["turnNumber"] != null: state["turnNumber"] = int(meta["turnNumber"])
# 10. Active effects (full replacement when changed)
var active_effects = delta.get("activeEffects")
if active_effects is Array:
state["activeEffects"] = active_effects
_state_version = int(delta.get("stateVersion", _state_version))
if debug_output:
print("[Game] delta applied ver=", _state_version,
@@ -2964,12 +2964,49 @@ func _build_unit_detail_lines(unit: Dictionary, owner_id: String,
lines.append("Ability: %s" % ability_name)
tooltips.append(ability_desc)
var unit_id: String = str(unit.get("instanceId", ""))
if not unit_id.is_empty():
_append_active_effect_lines(unit_id, lines, tooltips)
return {
"lines": lines,
"tooltips": tooltips,
}
## Appends any active effects targeting [param target_ref] (unit instanceId or ruinId)
## into the provided [param lines] and [param tooltips] arrays.
func _append_active_effect_lines(target_ref: String, lines: Array, tooltips: Array) -> void:
if target_ref.is_empty():
return
var all_effects: Variant = Game.state.get("activeEffects")
if not all_effects is Array:
return
for ae: Dictionary in (all_effects as Array):
if str(ae.get("targetRef", "")) != target_ref:
continue
var label: String = str(ae.get("label", "?"))
var source_name: String = str(ae.get("sourceName", ""))
var dur_type: String = str(ae.get("durationType", ""))
var turns: int = int(ae.get("turnsRemaining", 0))
var dur_text: String
match dur_type:
"ForNTurns": dur_text = "%d turn%s" % [turns, "s" if turns != 1 else ""]
"UntilEndOfTurn": dur_text = "until end of turn"
"UntilStartOfOwnerTurn": dur_text = "until owner's next turn"
"UntilStartOfSourceOwnerTurn": dur_text = "until source's next turn"
"WhileSourceOnBattlefield": dur_text = "while source lives"
"WhileCondition": dur_text = "conditional"
_: dur_text = dur_type.to_lower().replace("_", " ")
var line: String
if source_name.is_empty() or source_name == ae.get("sourceInstanceId", ""):
line = "[Effect] %s (%s)" % [label, dur_text]
else:
line = "[Effect] %s (%s, from %s)" % [label, dur_text, source_name]
lines.append(line)
tooltips.append("")
func _set_tile_drawer_content(tile: Dictionary) -> void:
_tile_drawer_last_tile = tile.duplicate(true)
_set_tile_drawer_button_state()
@@ -3043,7 +3080,9 @@ func _set_tile_drawer_content(tile: Dictionary) -> void:
"Ruin: %s" % ruin_id,
"Owner: %s" % Game.get_display_name(ruin_owner_id),
]
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, ruin_lines)
var ruin_tooltips : Array = ["", ""]
_append_active_effect_lines(ruin_id, ruin_lines, ruin_tooltips)
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, ruin_lines, ruin_tooltips)
else:
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, [])