diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 7ef8954..3770863 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -61,6 +61,9 @@ enum Mode { @onready var _go_menu_btn : Button = %GOMainMenuBtn @onready var _hud : CanvasLayer = $HUD +var count : int = 0 +var _last_click_frame : int = -1 +var _last_click_iid : String = "" # ── Affinity colors ─────────────────────────────────────────────────────────── const AFFINITY_COLORS : Dictionary = { @@ -1038,6 +1041,17 @@ func _hide_ability_panel() -> void: # ── Hand card ArchSpirit routing ────────────────────────────────────────────── func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void: + # Dedup: the same physical click can arrive twice if a stale queue_freed widget + # still overlaps the live one (see _rebuild_hand). Ignore the second call in + # the same engine frame for the same card instance. + var cf := Engine.get_process_frames() + if cf == _last_click_frame and _last_click_iid == iid: + print("[HandClick] dedup suppressed iid=", iid.substr(0,8)) + return + _last_click_frame = cf + _last_click_iid = iid + print("Clicked x times: ", count) + count += 1 if not Game.is_my_turn(): return var card := _find_hand_card(iid) @@ -1091,7 +1105,14 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void: # ── Hand display ────────────────────────────────────────────────────────────── func _rebuild_hand(hand: Array) -> void: - for c in _hand_cards.get_children(): c.queue_free() + # Use remove_child + queue_free (not queue_free alone) so stale widgets are + # immediately pulled from the GUI tree. queue_free() alone keeps the node in + # get_children() and receiving input events until end-of-frame; if two state + # updates arrive in the same frame we'd have two overlapping CardWidgets at the + # same position → two card_pressed emissions → double _on_hand_card_clicked. + for c in _hand_cards.get_children(): + _hand_cards.remove_child(c) + c.queue_free() for card: Dictionary in hand: _hand_cards.add_child(_make_hand_card(card))