diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 0e31f01..f66cfed 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -4458,6 +4458,13 @@ func _rebuild_hand(hand: Array) -> void: _refresh_hand_selection() return + _cached_hand_iids = new_iids + + # Spectators have no playable hand — just clear any stale widgets and stop. + if _is_spectating: + _apply_display_hand([]) + return + # Detect brand-new cards (not in previous server hand, not already queued). var pending_iids : Array[String] = [] for c: Dictionary in _pending_popup_cards: @@ -4470,11 +4477,12 @@ func _rebuild_hand(hand: Array) -> void: if iid not in _cached_hand_iids and iid not in pending_iids: brand_new.append(card) - _cached_hand_iids = new_iids - - # Drop pending popups for cards that left the hand. - _pending_popup_cards = _pending_popup_cards.filter( - func(c: Dictionary) -> bool: return c.get("instanceId", "") in new_iids) + # Drop pending popups for cards that left the hand (avoid typed-array filter). + var kept : Array[Dictionary] = [] + for c: Dictionary in _pending_popup_cards: + if c.get("instanceId", "") in new_iids: + kept.append(c) + _pending_popup_cards = kept # Queue brand-new cards for popup; exclude them from the live hand display. for card: Dictionary in brand_new: @@ -4485,9 +4493,10 @@ func _rebuild_hand(hand: Array) -> void: popup_iids.append(c.get("instanceId", "") as String) # Build the display hand (everything except cards waiting in popup queue). - var display_hand : Array = hand.filter( - func(c: Variant) -> bool: - return (c as Dictionary).get("instanceId", "") not in popup_iids) + var display_hand : Array[Dictionary] = [] + for card: Dictionary in hand: + if card.get("instanceId", "") not in popup_iids: + display_hand.append(card) _apply_display_hand(display_hand) @@ -5300,8 +5309,7 @@ func _on_state_updated(state: Dictionary) -> void: " my_player_found=", not Game.get_my_player().is_empty(), " hand_size=", hand.size(), " my_id=", Auth.user_id.substr(0,8)) - if not _is_spectating: - _rebuild_hand(hand) + _rebuild_hand(hand) _update_hud(state) # ── Update position/HP tracking now so the next state update is correct ───