feat(ability-prompts): wire all 8 pending pick types end-to-end
Server:
- GameMessages.cs: add push DTOs for CostGroupPick, ActionGroupPick,
BranchPick, TargetPick, TilePick, PlayerPick, RevealChoicePick
- GameHandlerBase.PushStateToPlayersAsync: push all 8 pending types
(including existing CostPick which was missing its push) to the
chooser player after every state update and on reconnect
Client:
- Game.gd: add 8 signals, 8 send functions, 8 push routes matching
game.ability.{cost,cost_group,action_group,branch,target,tile,player,
reveal_choice}_pick_request
- game_screen.gd: add handlers for all 8 types:
- cost_pick: hand-card selection panel with confirm
- cost_group_pick / action_group_pick: option-button panels
- branch_pick: same UI as local ChooseOne but sends game.branch_pick
- target_pick: reuses ABILITY_TARGET mode, flag routes to game.target_pick
- tile_pick: highlights valid tiles, click sends game.tile_pick
- player_pick: player-button panel from server-supplied validPlayerIds
- reveal_choice_pick: click-to-order card list, sends game.reveal_choice_pick
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:
@@ -196,6 +196,23 @@ var _player_panel : Control = null
|
||||
var _is_triggered_target : bool = false # true when targeting for a server-paused trigger
|
||||
var _triggered_request_id : String = "" # requestId to echo back in the response
|
||||
|
||||
# Server-driven ability pause prompts (non-triggered)
|
||||
var _pending_req_id : String = "" # shared request ID for any active server prompt
|
||||
var _pending_source_id : String = "" # source unit instance ID
|
||||
var _pending_prompt_panel : Control = null # choice-panel for cost_group / action_group / branch / player / reveal
|
||||
var _is_target_pick : bool = false # PendingTargetPick: reuses ABILITY_TARGET mode
|
||||
var _is_tile_pick : bool = false # PendingTilePick: shows tile highlights
|
||||
var _tile_pick_max_range : int = 0
|
||||
var _tile_pick_require_empty : bool = false
|
||||
var _tile_pick_require_occupied : bool = false
|
||||
# For PendingCostPick: accumulated selections
|
||||
var _cost_pick_selected : Array[String] = []
|
||||
var _cost_pick_amount : int = 1
|
||||
# For PendingRevealChoicePick: ordered indices collected so far
|
||||
var _reveal_ordered_indices : Array = []
|
||||
var _reveal_total_cards : int = 0
|
||||
var _reveal_required_count : int = 1
|
||||
|
||||
# Tile detail drawer (right-side slide-in panel)
|
||||
var _tile_drawer : PanelContainer = null
|
||||
var _tile_drawer_open : bool = false
|
||||
@@ -349,6 +366,14 @@ func _ready() -> void:
|
||||
Settings.settings_changed.connect(_sync_cam_ctrl_panel)
|
||||
_create_tile_drawer()
|
||||
Game.triggered_target_request.connect(_on_triggered_target_request)
|
||||
Game.cost_pick_request.connect(_on_cost_pick_request)
|
||||
Game.cost_group_pick_request.connect(_on_cost_group_pick_request)
|
||||
Game.action_group_pick_request.connect(_on_action_group_pick_request)
|
||||
Game.branch_pick_request.connect(_on_branch_pick_request)
|
||||
Game.target_pick_request.connect(_on_target_pick_request)
|
||||
Game.tile_pick_request.connect(_on_tile_pick_request)
|
||||
Game.player_pick_request.connect(_on_player_pick_request)
|
||||
Game.reveal_choice_pick_request.connect(_on_reveal_choice_pick_request)
|
||||
HighlightConfig.texture_loaded.connect(_on_highlight_texture_loaded)
|
||||
|
||||
# Chat overlay — add to viewport root so it renders above everything.
|
||||
@@ -397,6 +422,22 @@ func _exit_tree() -> void:
|
||||
Game.game_activity.disconnect(_on_game_activity)
|
||||
if Game.triggered_target_request.is_connected(_on_triggered_target_request):
|
||||
Game.triggered_target_request.disconnect(_on_triggered_target_request)
|
||||
if Game.cost_pick_request.is_connected(_on_cost_pick_request):
|
||||
Game.cost_pick_request.disconnect(_on_cost_pick_request)
|
||||
if Game.cost_group_pick_request.is_connected(_on_cost_group_pick_request):
|
||||
Game.cost_group_pick_request.disconnect(_on_cost_group_pick_request)
|
||||
if Game.action_group_pick_request.is_connected(_on_action_group_pick_request):
|
||||
Game.action_group_pick_request.disconnect(_on_action_group_pick_request)
|
||||
if Game.branch_pick_request.is_connected(_on_branch_pick_request):
|
||||
Game.branch_pick_request.disconnect(_on_branch_pick_request)
|
||||
if Game.target_pick_request.is_connected(_on_target_pick_request):
|
||||
Game.target_pick_request.disconnect(_on_target_pick_request)
|
||||
if Game.tile_pick_request.is_connected(_on_tile_pick_request):
|
||||
Game.tile_pick_request.disconnect(_on_tile_pick_request)
|
||||
if Game.player_pick_request.is_connected(_on_player_pick_request):
|
||||
Game.player_pick_request.disconnect(_on_player_pick_request)
|
||||
if Game.reveal_choice_pick_request.is_connected(_on_reveal_choice_pick_request):
|
||||
Game.reveal_choice_pick_request.disconnect(_on_reveal_choice_pick_request)
|
||||
if Settings.settings_changed.is_connected(_on_skybox_setting_changed):
|
||||
Settings.settings_changed.disconnect(_on_skybox_setting_changed)
|
||||
_reset_unit_hover_glow()
|
||||
@@ -3551,6 +3592,16 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
_confirm_sacrifice(unit_id, unit.get("name", "this spirit"))
|
||||
|
||||
Mode.ABILITY_TARGET:
|
||||
# Server-driven tile pick — send directly and exit.
|
||||
if _is_tile_pick and coord.x >= 0:
|
||||
_is_tile_pick = false
|
||||
var rid := _pending_req_id
|
||||
_pending_req_id = ""
|
||||
_set_mode(Mode.NONE)
|
||||
_clear_highlights()
|
||||
Game.send_tile_pick_response(rid, coord.x, coord.y)
|
||||
return
|
||||
|
||||
# Collect the clicked board target; advance only when N targets have been gathered.
|
||||
var _collected := false
|
||||
if not unit_id.is_empty():
|
||||
@@ -4294,6 +4345,11 @@ func _send_ability() -> void:
|
||||
var rid := _triggered_request_id
|
||||
_triggered_request_id = ""
|
||||
Game.send_triggered_target_response(rid, _ability_targets)
|
||||
elif _is_target_pick:
|
||||
_is_target_pick = false
|
||||
var rid := _pending_req_id
|
||||
_pending_req_id = ""
|
||||
Game.send_target_pick_response(rid, _ability_targets)
|
||||
elif not _ability_card_id.is_empty():
|
||||
Game.send_play_card_with_targets(_ability_card_id, _ability_targets)
|
||||
else:
|
||||
@@ -4342,6 +4398,428 @@ func _on_triggered_target_request(req: Dictionary) -> void:
|
||||
_start_ability_targeting()
|
||||
|
||||
|
||||
## ── Server-driven ability-pause prompt handlers ─────────────────────────────
|
||||
|
||||
func _hide_pending_prompt_panel() -> void:
|
||||
if is_instance_valid(_pending_prompt_panel):
|
||||
_pending_prompt_panel.queue_free()
|
||||
_pending_prompt_panel = null
|
||||
|
||||
|
||||
## PendingCostPick — player selects N cards/units to satisfy an interactive cost.
|
||||
func _on_cost_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
_cost_pick_selected.clear()
|
||||
_cost_pick_amount = int(req.get("amount", 1))
|
||||
var cost_type : String = str(req.get("costType", ""))
|
||||
var pick_mode : String = str(req.get("pickMode", "SelfPick"))
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
panel.position = Vector2(8, 160)
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 6)
|
||||
vbox.custom_minimum_size = Vector2(200, 0)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Cost: %s (select %d)" % [cost_type, _cost_pick_amount]
|
||||
title.add_theme_font_size_override("font_size", 13)
|
||||
title.add_theme_color_override("font_color", Color(1.0, 0.75, 0.2))
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
# List hand cards (most interactive costs are hand discards).
|
||||
var my_player := Game.get_my_player()
|
||||
var hand : Array = my_player.get("hand", []) as Array if my_player is Dictionary else []
|
||||
if hand.is_empty():
|
||||
var lbl := Label.new(); lbl.text = "(hand empty)"
|
||||
lbl.add_theme_font_size_override("font_size", 11)
|
||||
vbox.add_child(lbl)
|
||||
else:
|
||||
for card in hand:
|
||||
var card_d : Dictionary = card as Dictionary
|
||||
var iid : String = str(card_d.get("instanceId", ""))
|
||||
var name_ : String = str(card_d.get("name", iid))
|
||||
var btn := Button.new()
|
||||
btn.text = name_
|
||||
btn.add_theme_font_size_override("font_size", 11)
|
||||
var cap_iid : String = iid
|
||||
btn.pressed.connect(func() -> void:
|
||||
if not cap_iid in _cost_pick_selected:
|
||||
_cost_pick_selected.append(cap_iid)
|
||||
btn.modulate = Color(0.4, 1.0, 0.4)
|
||||
if _cost_pick_selected.size() >= _cost_pick_amount:
|
||||
_finish_cost_pick())
|
||||
vbox.add_child(btn)
|
||||
|
||||
# Confirm button for pick_mode variants that allow fewer than max.
|
||||
if pick_mode == "SelfPick":
|
||||
var confirm := Button.new()
|
||||
confirm.text = "Confirm"
|
||||
confirm.add_theme_font_size_override("font_size", 12)
|
||||
confirm.pressed.connect(_finish_cost_pick)
|
||||
vbox.add_child(confirm)
|
||||
|
||||
panel.add_child(vbox)
|
||||
_hud.add_child(panel)
|
||||
_pending_prompt_panel = panel
|
||||
|
||||
|
||||
func _finish_cost_pick() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id
|
||||
_pending_req_id = ""
|
||||
Game.send_cost_pick_response(rid, _cost_pick_selected)
|
||||
_cost_pick_selected.clear()
|
||||
|
||||
|
||||
## PendingCostGroupPick — chooser picks which OR/XOR cost option to pay.
|
||||
func _on_cost_group_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var group_raw = JSON.parse_string(str(req.get("costGroupJson", "{}")))
|
||||
var group : Dictionary = group_raw as Dictionary if group_raw is Dictionary else {}
|
||||
var entries : Array = group.get("entries", []) as Array
|
||||
var groups : Array = group.get("groups", []) as Array
|
||||
var logic : String = str(group.get("logicOp", "OR"))
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
panel.position = Vector2(8, 160)
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 8)
|
||||
vbox.custom_minimum_size = Vector2(200, 0)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Choose Cost (%s):" % logic
|
||||
title.add_theme_font_size_override("font_size", 13)
|
||||
title.add_theme_color_override("font_color", Color(1.0, 0.75, 0.2))
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
var option_idx := 0
|
||||
for entry in entries:
|
||||
var entry_d : Dictionary = entry as Dictionary
|
||||
var label : String = str(entry_d.get("typeStr", "Option %d" % (option_idx + 1)))
|
||||
var btn := Button.new(); btn.text = label
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
btn.pressed.connect(func() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_cost_group_pick_response(rid, cap_idx))
|
||||
vbox.add_child(btn)
|
||||
option_idx += 1
|
||||
for grp in groups:
|
||||
var grp_d : Dictionary = grp as Dictionary
|
||||
var lop : String = str(grp_d.get("logicOp", "OR"))
|
||||
var btn := Button.new(); btn.text = "Group (%s)" % lop
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
btn.pressed.connect(func() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_cost_group_pick_response(rid, cap_idx))
|
||||
vbox.add_child(btn)
|
||||
option_idx += 1
|
||||
|
||||
panel.add_child(vbox)
|
||||
_hud.add_child(panel)
|
||||
_pending_prompt_panel = panel
|
||||
|
||||
|
||||
## PendingActionGroupPick — chooser picks which OR/XOR action branch to execute.
|
||||
func _on_action_group_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var group_raw = JSON.parse_string(str(req.get("actionGroupJson", "{}")))
|
||||
var group : Dictionary = group_raw as Dictionary if group_raw is Dictionary else {}
|
||||
var actions : Array = group.get("actions", []) as Array
|
||||
var subgrps : Array = group.get("groups", []) as Array
|
||||
var logic : String = str(group.get("logicOp", "OR"))
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
panel.position = Vector2(8, 160)
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 8)
|
||||
vbox.custom_minimum_size = Vector2(200, 0)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Choose Action (%s):" % logic
|
||||
title.add_theme_font_size_override("font_size", 13)
|
||||
title.add_theme_color_override("font_color", Color(0.4, 0.8, 1.0))
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
var option_idx := 0
|
||||
for act in actions:
|
||||
var act_d : Dictionary = act as Dictionary
|
||||
var label : String = str(act_d.get("label", "Action %d" % (option_idx + 1)))
|
||||
if label.is_empty():
|
||||
var tgt : Dictionary = act_d.get("target", {}) as Dictionary
|
||||
label = "%s %s" % [tgt.get("ownership", ""), tgt.get("targetType", "")]
|
||||
label = label.strip_edges()
|
||||
if label.is_empty(): label = "Action %d" % (option_idx + 1)
|
||||
var btn := Button.new(); btn.text = label
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
btn.pressed.connect(func() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_action_group_pick_response(rid, cap_idx))
|
||||
vbox.add_child(btn)
|
||||
option_idx += 1
|
||||
for grp in subgrps:
|
||||
var grp_d : Dictionary = grp as Dictionary
|
||||
var lop : String = str(grp_d.get("logicOp", "OR"))
|
||||
var btn := Button.new(); btn.text = "Group (%s)" % lop
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = option_idx
|
||||
btn.pressed.connect(func() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_action_group_pick_response(rid, cap_idx))
|
||||
vbox.add_child(btn)
|
||||
option_idx += 1
|
||||
|
||||
panel.add_child(vbox)
|
||||
_hud.add_child(panel)
|
||||
_pending_prompt_panel = panel
|
||||
|
||||
|
||||
## PendingBranchPick — server-driven ChooseOne for Opponent/Ally chooser.
|
||||
func _on_branch_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var branches_raw = JSON.parse_string(str(req.get("branchesJson", "[]")))
|
||||
var branches : Array = branches_raw as Array if branches_raw is Array else []
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
panel.position = Vector2(8, 120)
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 8)
|
||||
vbox.custom_minimum_size = Vector2(190, 0)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Choose One:"
|
||||
title.add_theme_font_size_override("font_size", 13)
|
||||
title.add_theme_color_override("font_color", Color(1.0, 0.9, 0.3))
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
for i in branches.size():
|
||||
var branch : Dictionary = branches[i] as Dictionary
|
||||
var label : String = str(branch.get("label", "Option %d" % (i + 1)))
|
||||
var btn := Button.new(); btn.text = label
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx : int = i
|
||||
btn.pressed.connect(func() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_branch_pick_response(rid, cap_idx))
|
||||
vbox.add_child(btn)
|
||||
|
||||
panel.add_child(vbox)
|
||||
_hud.add_child(panel)
|
||||
_pending_prompt_panel = panel
|
||||
|
||||
|
||||
## PendingTargetPick — opponent/ally must select targets for a paused action.
|
||||
## Reuses the existing ABILITY_TARGET board mode; _is_target_pick flag routes the send.
|
||||
func _on_target_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_is_target_pick = true
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
_ability_unit_id = _pending_source_id
|
||||
_ability_idx = -1
|
||||
_ability_card_id = ""
|
||||
_ability_target_conditions = []
|
||||
|
||||
var action_json : String = str(req.get("actionJson", "{}"))
|
||||
var action_raw = JSON.parse_string(action_json)
|
||||
if action_raw is Dictionary:
|
||||
_ability_def = [_normalize_keys(action_raw)]
|
||||
elif action_raw is Array:
|
||||
_ability_def = _normalize_keys(action_raw) as Array
|
||||
else:
|
||||
_ability_def = []
|
||||
|
||||
var range_json : String = str(req.get("rangeJson", ""))
|
||||
if not range_json.is_empty() and range_json != "null":
|
||||
var r = JSON.parse_string(range_json)
|
||||
_ability_range = _normalize_keys(r) as Dictionary if r is Dictionary else {}
|
||||
else:
|
||||
_ability_range = {}
|
||||
|
||||
_ability_targets = []
|
||||
_ability_cur_action_idx = 0
|
||||
_ability_target_n = 1
|
||||
_ability_target_up_to = false
|
||||
_ability_targets_this_action = 0
|
||||
_start_ability_targeting()
|
||||
|
||||
|
||||
## PendingTilePick — player selects a tile satisfying given constraints.
|
||||
func _on_tile_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_is_tile_pick = true
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
_tile_pick_max_range = int(req.get("maxRange", 0))
|
||||
_tile_pick_require_empty = bool(req.get("requireEmpty", false))
|
||||
_tile_pick_require_occupied = bool(req.get("requireOccupied", false))
|
||||
_ability_unit_id = _pending_source_id
|
||||
|
||||
# Highlight valid tiles.
|
||||
_set_mode(Mode.ABILITY_TARGET)
|
||||
_clear_highlights()
|
||||
var bw := Game.board_width(); var bh := Game.board_height()
|
||||
var src_pos : Dictionary = {}
|
||||
if not _pending_source_id.is_empty():
|
||||
var src_unit := Game.get_unit_by_id(_pending_source_id)
|
||||
if src_unit is Dictionary: src_pos = src_unit.get("position", {}) as Dictionary
|
||||
var occupant_ownership : String = str(req.get("occupantOwnership", "Any"))
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if _tile_pick_max_range > 0 and not src_pos.is_empty():
|
||||
var dist := _board_distance(tx, ty, int(src_pos.get("x", 0)), int(src_pos.get("y", 0)))
|
||||
if dist > _tile_pick_max_range: continue
|
||||
var tile := Game.get_tile(tx, ty)
|
||||
if tile.is_empty(): continue
|
||||
var occ_id : String = str(tile.get("occupantId", ""))
|
||||
if _tile_pick_require_empty and not occ_id.is_empty(): continue
|
||||
if _tile_pick_require_occupied and occ_id.is_empty(): continue
|
||||
if _tile_pick_require_occupied and not occ_id.is_empty() and occupant_ownership != "Any":
|
||||
var occ_owner : String = str(tile.get("occupantOwner", ""))
|
||||
var my_id : String = Auth.user_id
|
||||
if occupant_ownership == "Self" and occ_owner != my_id: continue
|
||||
if occupant_ownership == "Enemy" and occ_owner == my_id: continue
|
||||
_add_highlight(tx, ty, "ability")
|
||||
|
||||
|
||||
## PendingPlayerPick — chooser selects a player from a specific valid-player list.
|
||||
func _on_player_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
|
||||
var valid_ids_raw = req.get("validPlayerIds")
|
||||
var valid_ids : Array = valid_ids_raw as Array if valid_ids_raw is Array else []
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
panel.position = Vector2(8, 180)
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 8)
|
||||
vbox.custom_minimum_size = Vector2(160, 0)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Choose Player:"
|
||||
title.add_theme_font_size_override("font_size", 13)
|
||||
title.add_theme_color_override("font_color", Color(0.7, 0.8, 1.0))
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
for pid_raw in valid_ids:
|
||||
var pid : String = str(pid_raw)
|
||||
var pname : String = Game.get_display_name(pid)
|
||||
if pname.is_empty(): pname = pid.substr(0, 8)
|
||||
var btn := Button.new(); btn.text = pname
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_pid : String = pid
|
||||
btn.pressed.connect(func() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_player_pick_response(rid, cap_pid))
|
||||
vbox.add_child(btn)
|
||||
|
||||
panel.add_child(vbox)
|
||||
_hud.add_child(panel)
|
||||
_pending_prompt_panel = panel
|
||||
|
||||
|
||||
## PendingRevealChoicePick — chooser orders revealed cards (e.g. StackDeck).
|
||||
func _on_reveal_choice_pick_request(req: Dictionary) -> void:
|
||||
if _mode != Mode.NONE:
|
||||
_set_mode(Mode.NONE)
|
||||
_pending_req_id = str(req.get("requestId", ""))
|
||||
_pending_source_id = str(req.get("sourceInstanceId", ""))
|
||||
_reveal_required_count = int(req.get("count", 1))
|
||||
_reveal_ordered_indices.clear()
|
||||
|
||||
var cards_raw = JSON.parse_string(str(req.get("revealedCardsJson", "[]")))
|
||||
var cards : Array = cards_raw as Array if cards_raw is Array else []
|
||||
_reveal_total_cards = cards.size()
|
||||
|
||||
_hide_pending_prompt_panel()
|
||||
var panel := PanelContainer.new()
|
||||
panel.position = Vector2(8, 100)
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 6)
|
||||
vbox.custom_minimum_size = Vector2(210, 0)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Order top %d card(s):" % _reveal_required_count
|
||||
title.add_theme_font_size_override("font_size", 13)
|
||||
title.add_theme_color_override("font_color", Color(0.6, 1.0, 0.8))
|
||||
vbox.add_child(title)
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
# Each card becomes a button; clicking adds its 0-based index to the ordering.
|
||||
for i in cards.size():
|
||||
var card_d : Dictionary = cards[i] as Dictionary
|
||||
var name_ : String = str(card_d.get("name", "Card %d" % (i + 1)))
|
||||
var btn := Button.new(); btn.text = "%d. %s" % [i + 1, name_]
|
||||
btn.add_theme_font_size_override("font_size", 11)
|
||||
var cap_i : int = i
|
||||
var cap_btn : Button = btn
|
||||
btn.pressed.connect(func() -> void:
|
||||
if cap_i in _reveal_ordered_indices: return
|
||||
_reveal_ordered_indices.append(cap_i)
|
||||
cap_btn.modulate = Color(0.4, 1.0, 0.5)
|
||||
cap_btn.text = "#%d %s" % [_reveal_ordered_indices.size(), name_]
|
||||
if _reveal_ordered_indices.size() >= _reveal_required_count:
|
||||
_finish_reveal_pick())
|
||||
vbox.add_child(btn)
|
||||
|
||||
# Confirm button for edge cases.
|
||||
var confirm := Button.new()
|
||||
confirm.text = "Confirm Order"
|
||||
confirm.add_theme_font_size_override("font_size", 12)
|
||||
confirm.pressed.connect(_finish_reveal_pick)
|
||||
vbox.add_child(HSeparator.new())
|
||||
vbox.add_child(confirm)
|
||||
|
||||
panel.add_child(vbox)
|
||||
_hud.add_child(panel)
|
||||
_pending_prompt_panel = panel
|
||||
|
||||
|
||||
func _finish_reveal_pick() -> void:
|
||||
_hide_pending_prompt_panel()
|
||||
var rid := _pending_req_id; _pending_req_id = ""
|
||||
Game.send_reveal_choice_pick_response(rid, _reveal_ordered_indices)
|
||||
_reveal_ordered_indices.clear()
|
||||
|
||||
|
||||
## Brief top-centre banner indicating a triggered ability needs player input.
|
||||
func _show_triggered_banner(ability_name: String) -> void:
|
||||
var lbl := Label.new()
|
||||
|
||||
Reference in New Issue
Block a user