feat(phase6-AB): Ruin client preflight check and channel confirmation dialog
Phase 6-B — Preflight check in _channel_ruin(): Iterate board tiles before sending play_card; skip any tile that already has a ruinId (non-null, non-empty) or that doesn't match the card's affinity. If zero valid tiles exist, show an AcceptDialog "No valid tile available for this Ruin." and abort the send. Phase 6-A — Confirmation dialog in _confirm_channel_ruin(): After passing preflight, show ConfirmationDialog "Channel Ruin / Ruin placement is random. Continue?" with Channel / Cancel buttons. Only calls Game.send_play_card on explicit confirm. Replaces the previous immediate Game.send_play_card(iid, 0, 0) on click. Follows the existing _confirm_ascend / _confirm_transition dialog pattern. 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:
@@ -3761,6 +3761,50 @@ func _confirm_transition(card: Dictionary) -> void:
|
||||
dlg.canceled.connect(func() -> void: dlg.queue_free())
|
||||
|
||||
|
||||
## 6-B: Preflight check — at least one valid no-ruin tile must exist.
|
||||
## If valid, shows the Channel Ruin confirmation dialog (6-A).
|
||||
func _channel_ruin(card: Dictionary) -> void:
|
||||
var card_affinity : String = card.get("affinity", "")
|
||||
var board : Dictionary = Game.get_board()
|
||||
var has_valid : bool = false
|
||||
for tile: Dictionary in board.get("tiles", []):
|
||||
var ruin_id_v : Variant = tile.get("ruinId", null)
|
||||
var ruin_id : String = "" if ruin_id_v == null else str(ruin_id_v)
|
||||
if not ruin_id.is_empty() and ruin_id != "null":
|
||||
continue # tile already holds a Ruin
|
||||
if card_affinity != "" and not _tile_matches_channel_affinity(tile, card_affinity):
|
||||
continue # wrong affinity
|
||||
has_valid = true
|
||||
break
|
||||
|
||||
if not has_valid:
|
||||
var dlg := AcceptDialog.new()
|
||||
dlg.title = "Cannot Channel Ruin"
|
||||
dlg.dialog_text = "No valid tile available for this Ruin."
|
||||
dlg.min_size = Vector2(280, 90)
|
||||
add_child(dlg)
|
||||
dlg.popup_centered()
|
||||
dlg.confirmed.connect(func() -> void: dlg.queue_free())
|
||||
return
|
||||
|
||||
_confirm_channel_ruin(card)
|
||||
|
||||
|
||||
## 6-A: Confirmation dialog before channeling a Ruin.
|
||||
func _confirm_channel_ruin(card: Dictionary) -> void:
|
||||
var dlg := ConfirmationDialog.new()
|
||||
dlg.title = "Channel Ruin"
|
||||
dlg.dialog_text = "Ruin placement is random.\nContinue?"
|
||||
dlg.ok_button_text = "Channel"
|
||||
dlg.min_size = Vector2(280, 90)
|
||||
add_child(dlg)
|
||||
dlg.popup_centered()
|
||||
dlg.confirmed.connect(func() -> void:
|
||||
Game.send_play_card(card.get("instanceId", ""), 0, 0)
|
||||
dlg.queue_free())
|
||||
dlg.canceled.connect(func() -> void: dlg.queue_free())
|
||||
|
||||
|
||||
func _get_my_arch_tier() -> int:
|
||||
var arch : Dictionary = _safe_arch(Game.get_my_player())
|
||||
return int(arch.get("tier", 1))
|
||||
@@ -4472,9 +4516,9 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
_highlight_tiles(_valid_play_tiles(card), "movement")
|
||||
return
|
||||
|
||||
# Ruin — server auto-places it; channel immediately on click.
|
||||
# Ruin — preflight check then confirm before channeling.
|
||||
if card.get("cardType", "") == "Ruin":
|
||||
Game.send_play_card(iid, 0, 0)
|
||||
_channel_ruin(card)
|
||||
return
|
||||
|
||||
# Repentance / Instinct — may have an active ability requiring unit target selection.
|
||||
|
||||
Reference in New Issue
Block a user