Fix nil crash in _play_damage_animations on player concede
When a player is eliminated, the server sends archSpirit: null.
player.get("archSpirit", {}) returns null (not {}) when the key
exists but its value is null — the default only fires for missing
keys. GDScript then throws assigning null to unit: Dictionary.
Use `player.get("archSpirit") or {}` which coerces any falsy value
(null, missing key) to an empty dict before building the iteration
array.
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:
@@ -1704,7 +1704,7 @@ func _play_damage_animations(state: Dictionary) -> bool:
|
||||
var damaged_iids : Dictionary = {}
|
||||
var seen_iids : Dictionary = {}
|
||||
for player: Dictionary in state.get("players", []):
|
||||
for unit: Dictionary in ([player.get("archSpirit", {})] + player.get("field", [])):
|
||||
for unit: Dictionary in ([player.get("archSpirit") or {}] + player.get("field", [])):
|
||||
if unit.is_empty(): continue
|
||||
var iid := str(unit.get("instanceId", ""))
|
||||
var new_hp := int(unit.get("currentHealth", 0))
|
||||
@@ -3543,7 +3543,7 @@ func _on_state_updated(state: Dictionary) -> void:
|
||||
_camera_oriented = true
|
||||
var bw := float(Game.board_width())
|
||||
var bh := float(Game.board_height())
|
||||
var max_dim := max(bw, bh)
|
||||
var max_dim :Variant = max(bw, bh)
|
||||
# Auto-scale camera distance: larger boards need more distance to see the whole layout.
|
||||
_cam_distance = clampf(max(max_dim, 10.0) * 1.5, 12.0, 30.0)
|
||||
# Pivot shifts the look-at point toward the local player so their row stays
|
||||
|
||||
Reference in New Issue
Block a user