Phase 2 client: N-player HUD, lobby room, and DTO fields
Server: - PlayerStateDto: add SeatIndex, TeamIndex, IsEliminated - GameStateDto: add SeatOrder, GameMode - CreateCustomLobbyResponse / JoinCustomLobbyResponse: add MaxPlayers, GameMode, TeamCount - GameEngine.ToDto(): populate new fields from GameState / PlayerState - Handlers: return MaxPlayers, GameMode, TeamCount in lobby create/join ACKs Client: - GameScreen.tscn: add TurnOrderStrip HBoxContainer in TopBar - game_screen.gd: show TurnOrderStrip for >2 player games; _rebuild_turn_order_strip() builds per-player chips sorted by seatIndex, highlighting active/eliminated players - LobbyRoomScreen.tscn: add GameModeLabel, AdditionalPlayersContainer, unique_name on FirstTurnSection/FirstTurnBtns - lobby_room_screen.gd: show game mode + player count; _rebuild_additional_players_panel() shows occupied seats and empty waiting slots; hide first-turn buttons for 3+ players; _on_guest_joined refreshes full display instead of only updating GuestNameLabel 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:
@@ -52,6 +52,13 @@ text = "Turn 1 — Your turn"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TurnOrderStrip" type="HBoxContainer" parent="HUD/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
visible = false
|
||||
|
||||
[node name="OpponentPanel" type="HBoxContainer" parent="HUD/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(240, 48)
|
||||
|
||||
@@ -34,6 +34,8 @@ enum Mode {
|
||||
# HUD
|
||||
@onready var _phase_lbl : Label = %PhaseLabel
|
||||
@onready var _turn_lbl : Label = %TurnLabel
|
||||
@onready var _turn_order_strip : HBoxContainer = %TurnOrderStrip
|
||||
@onready var _opp_panel : HBoxContainer = %OpponentPanel
|
||||
@onready var _opp_name_lbl : Label = %OppNameLabel
|
||||
@onready var _opp_hand_lbl : Label = %OppHandLabel
|
||||
@onready var _opp_deck_lbl : Label = %OppDeckLabel
|
||||
@@ -3224,6 +3226,16 @@ func _update_hud(state: Dictionary) -> void:
|
||||
_opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0))
|
||||
_opp_deck_lbl.text = "Deck: %d" % int(opp.get("deckCount", 0))
|
||||
|
||||
# Turn order strip — visible only in N-player (>2) games.
|
||||
var all_players : Array = state.get("players", [])
|
||||
if all_players.size() > 2:
|
||||
_opp_panel.visible = false
|
||||
_turn_order_strip.visible = true
|
||||
_rebuild_turn_order_strip(state)
|
||||
else:
|
||||
_opp_panel.visible = true
|
||||
_turn_order_strip.visible = false
|
||||
|
||||
if _is_spectating:
|
||||
_draw_btn.visible = false
|
||||
_end_turn_btn.visible = false
|
||||
@@ -3246,6 +3258,47 @@ func _update_hud(state: Dictionary) -> void:
|
||||
if _mode == Mode.PLACEMENT:
|
||||
_set_mode(Mode.NONE)
|
||||
|
||||
|
||||
## Rebuild the turn-order chip strip for N-player games.
|
||||
## One chip per player sorted by seatIndex; highlights the active player,
|
||||
## dims eliminated players, and marks the local player as "You".
|
||||
func _rebuild_turn_order_strip(state: Dictionary) -> void:
|
||||
for c in _turn_order_strip.get_children():
|
||||
c.queue_free()
|
||||
|
||||
var active_id : String = str(state.get("activePlayerAccountId", ""))
|
||||
var players : Array = state.get("players", []).duplicate()
|
||||
|
||||
# Sort by seatIndex so chips appear in turn order.
|
||||
players.sort_custom(func(a: Dictionary, b: Dictionary) -> bool:
|
||||
return int(a.get("seatIndex", 0)) < int(b.get("seatIndex", 0)))
|
||||
|
||||
for p: Dictionary in players:
|
||||
var pid : String = str(p.get("accountId", ""))
|
||||
var is_me : bool = (not _is_spectating) and pid == Auth.user_id
|
||||
var is_active : bool = pid == active_id
|
||||
var eliminated : bool = bool(p.get("isEliminated", false))
|
||||
|
||||
var chip := PanelContainer.new()
|
||||
chip.custom_minimum_size = Vector2(72, 36)
|
||||
chip.self_modulate = Color(1, 1, 1, 0.3 if eliminated else (0.95 if is_active else 0.6))
|
||||
|
||||
var lbl := Label.new()
|
||||
var display : String = "You" if is_me else pid.substr(0, 8)
|
||||
lbl.text = ("★ " if is_active else "") + display + (" ✗" if eliminated else "")
|
||||
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
lbl.add_theme_font_size_override("font_size", 10)
|
||||
if is_active:
|
||||
lbl.add_theme_color_override("font_color", Color(1.0, 0.9, 0.3))
|
||||
elif eliminated:
|
||||
lbl.add_theme_color_override("font_color", Color(0.4, 0.4, 0.4))
|
||||
elif is_me:
|
||||
lbl.add_theme_color_override("font_color", Color(0.5, 1.0, 0.5))
|
||||
|
||||
chip.add_child(lbl)
|
||||
_turn_order_strip.add_child(chip)
|
||||
|
||||
# ── Discard viewer ────────────────────────────────────────────────────────────
|
||||
|
||||
func _show_own_discard() -> void:
|
||||
|
||||
Reference in New Issue
Block a user