Fix: Spirit tile highlights (null channel range), Ruin immediate play, deselect tween
- Spirit tile null safety: dict.get(key, default) only uses the default when the key is absent. Server sends nullable ints as JSON null, so the key EXISTS but the value is null. GDScript returns null which coerces to 0 on a typed int, collapsing min_r/max_r to 0 and producing zero valid tiles. Fixed by reading channel range as Variant and substituting the default (1/2) when null. - Channel range source: read from arch (ArchSpirit), not the Spirit card — the ArchSpirit defines how far away from itself it can channel Spirits. - Ruin: auto-placed by server. Clicking a Ruin card now immediately calls send_play_card without entering CARD_FROM_HAND mode or requiring a tile click. Added Ruin to the board-click immediate-play guard as well. - Deselect previous: before entering a new CARD_FROM_HAND selection, explicitly call _set_mode(NONE) when already in CARD_FROM_HAND or TERRAMORPHA_SELECT. This guarantees _refresh_hand_selection fires a deselect tween on the old card before the new card's select tween begins. 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:
@@ -523,13 +523,20 @@ func _valid_play_tiles(card: Dictionary) -> Array:
|
||||
var arch_pos : Dictionary = arch.get("position", {})
|
||||
|
||||
match card_type:
|
||||
"Spirit", "Ruin":
|
||||
"Spirit":
|
||||
if arch_pos.is_empty(): return results
|
||||
var ax : int = arch_pos.get("x", 0)
|
||||
var ay : int = arch_pos.get("y", 0)
|
||||
# Channel range comes from the card being played, not the ArchSpirit.
|
||||
var min_r : int = card.get("minChannelRange", 1)
|
||||
var max_r : int = card.get("maxChannelRange", 2)
|
||||
var ax : int = arch_pos.get("x", 0)
|
||||
var ay : int = arch_pos.get("y", 0)
|
||||
# Channel range is a property of the ArchSpirit.
|
||||
# dict.get(key, default) only uses the default when the key is ABSENT.
|
||||
# The server sends nullable ints (e.g. "minChannelRange": null), so the
|
||||
# key EXISTS but its value is null — GDScript returns null, which silently
|
||||
# coerces to 0 on a typed int variable, collapsing the range to nothing.
|
||||
# Read as Variant first, then substitute the default explicitly.
|
||||
var raw_min = arch.get("minChannelRange")
|
||||
var raw_max = arch.get("maxChannelRange")
|
||||
var min_r : int = 1 if raw_min == null else int(raw_min)
|
||||
var max_r : int = 2 if raw_max == null else int(raw_max)
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
var dist : int = abs(tx - ax) + abs(ty - ay)
|
||||
@@ -542,8 +549,8 @@ func _valid_play_tiles(card: Dictionary) -> Array:
|
||||
for ty in range(bh):
|
||||
results.append(Vector2i(tx, ty))
|
||||
|
||||
"Repentance", "Instinct":
|
||||
pass # No tile target, play directly.
|
||||
"Repentance", "Instinct", "Ruin":
|
||||
pass # No tile target — played directly (server handles placement).
|
||||
|
||||
return results
|
||||
|
||||
@@ -694,7 +701,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
if card.is_empty():
|
||||
_set_mode(Mode.NONE); return
|
||||
var card_type : String = card.get("cardType", "")
|
||||
if card_type in ["Repentance", "Instinct"]:
|
||||
if card_type in ["Repentance", "Instinct", "Ruin"]:
|
||||
Game.send_play_card(_sel_card_id, 0, 0)
|
||||
_set_mode(Mode.NONE); return
|
||||
if coord.x < 0:
|
||||
@@ -1043,11 +1050,21 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
_highlight_tiles(_valid_play_tiles(card), HI_GREEN)
|
||||
return
|
||||
|
||||
# Deselect if already selected.
|
||||
# Ruin — server auto-places it; channel immediately on click.
|
||||
if card.get("cardType", "") == "Ruin":
|
||||
Game.send_play_card(iid, 0, 0)
|
||||
return
|
||||
|
||||
# Deselect if same card clicked again.
|
||||
if _mode == Mode.CARD_FROM_HAND and _sel_card_id == iid:
|
||||
_set_mode(Mode.NONE); return
|
||||
|
||||
# Normal Spirit/Ruin/Repentance/Instinct.
|
||||
# If switching cards (or coming from TERRAMORPHA_SELECT), explicitly reset
|
||||
# so the previous card's scale-up tween is released before entering the new mode.
|
||||
if _mode in [Mode.CARD_FROM_HAND, Mode.TERRAMORPHA_SELECT]:
|
||||
_set_mode(Mode.NONE)
|
||||
|
||||
# Normal Spirit / Repentance / Instinct.
|
||||
_sel_card_id = iid
|
||||
_set_mode(Mode.CARD_FROM_HAND)
|
||||
_clear_highlights()
|
||||
|
||||
Reference in New Issue
Block a user