Phase 3 & 4: Team colors, player_eliminated push, board shapes, lobby team UI

Phase 3 – Team modes:
- GameState: TeamColors dictionary (int → hex color string) populated from palette
- GameMessages: PlayerEliminatedPush, PlayerOutcomeDto, extended GameOverPush
- GameHandlerBase: FinalizeMultiPlayerGameAsync (pairwise ELO), BroadcastPlayerEliminatedAsync, GetAllPlayerIds for N-player push
- GameAttackHandler: snapshot pre-attack elimination state; use FinalizeMultiPlayerGameAsync; push PlayerEliminatedPush for mid-game knockouts
- game_screen.gd: turn order strip chips carry team-color left border from state.teamColors
- lobby_room_screen.gd: _team_label() helper; team badges on host/guest/additional slots

Phase 4 – Board shape library:
- BoardShapeGenerator: AutoShape() picks shape by player count; adds Triangular (3p), RadialStar (5p, 5-arm star), HexRing (6p, hex perimeter zones); CoordsInRect helper
- GameLobbyReadyHandler: auto-selects board shape at game start; passes BoardShape+PlayerCount into rules snapshot

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:
dingo
2026-03-26 05:50:55 -04:00
co-authored by Claude Happy
parent 00bf788ac8
commit 356e1a50e3
9 changed files with 462 additions and 43 deletions
@@ -153,14 +153,16 @@ func _refresh_display() -> void:
game_mode_label.text = "Mode: %s (%d players)" % [mode_label, max_players]
game_mode_label.visible = max_players > 2 or game_mode != "FFA"
# Host slot
host_name_label.text = "Host: %s" % str(lobby.get("hostDisplayName", Auth.display_name))
# Host slot — show team badge when not FFA.
var team_suffix_0 : String = _team_label(game_mode, 0, team_count)
host_name_label.text = "Host: %s%s" % [str(lobby.get("hostDisplayName", Auth.display_name)), team_suffix_0]
host_deck_label.text = "Deck: (selected)"
# Guest slot
var team_suffix_1 : String = _team_label(game_mode, 1, team_count)
var has_guest : bool = lobby.get("hasGuest", false) or lobby.get("guestAccountId", "") != ""
if has_guest:
guest_name_label.text = "Guest: %s" % str(lobby.get("guestDisplayName", "Guest"))
guest_name_label.text = "Guest: %s%s" % [str(lobby.get("guestDisplayName", "Guest")), team_suffix_1]
guest_deck_label.text = "Deck: (selected)"
else:
guest_name_label.text = "Waiting for guest…"
@@ -191,6 +193,9 @@ func _rebuild_additional_players_panel(lobby: Dictionary, max_players: int) -> v
additional_players_container.visible = false
return
var gm : String = str(lobby.get("gameMode", "FFA"))
var tc : int = int(lobby.get("teamCount", 1))
# The lobby dict may contain additionalPlayers array (from server push or join response).
var addl : Array = lobby.get("additionalPlayers", []) as Array
if addl.is_empty():
@@ -200,18 +205,31 @@ func _rebuild_additional_players_panel(lobby: Dictionary, max_players: int) -> v
var has_guest : bool = lobby.get("hasGuest", false) or str(lobby.get("guestAccountId", "")) != ""
var taken_slots : int = (1 if has_host else 0) + (1 if has_guest else 0)
for i in range(max_players - taken_slots):
var row := _make_player_slot_row("Seat %d: Waiting…" % (taken_slots + i + 1), false)
var seat_n : int = taken_slots + i
var tsuf : String = _team_label(gm, seat_n, tc)
var row := _make_player_slot_row("Seat %d: Waiting…%s" % [seat_n + 1, tsuf], false)
additional_players_container.add_child(row)
else:
for entry: Dictionary in addl:
for i2: int in addl.size():
var entry : Dictionary = addl[i2] as Dictionary
var aname : String = str(entry.get("displayName", str(entry.get("accountId", "Player")).substr(0, 8)))
var ready : bool = bool(entry.get("isReady", false))
var row := _make_player_slot_row("Player: %s" % aname, ready)
var seat_n2 : int = i2 + 2
var tsuf2 : String = _team_label(gm, seat_n2, tc)
var row := _make_player_slot_row("Player: %s%s" % [aname, tsuf2], ready)
additional_players_container.add_child(row)
additional_players_container.visible = true
## Returns a short team label like " [T0]" when in a team mode, else "".
func _team_label(game_mode: String, seat_index: int, team_count: int) -> String:
if game_mode == "FFA" or team_count <= 1:
return ""
var tidx : int = seat_index % team_count
return " [T%d]" % tidx
func _make_player_slot_row(label_text: String, is_ready: bool) -> HBoxContainer:
var hbox := HBoxContainer.new()
hbox.add_theme_constant_override("separation", 8)
@@ -3266,8 +3266,9 @@ 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()
var active_id : String = str(state.get("activePlayerAccountId", ""))
var players : Array = state.get("players", []).duplicate()
var team_colors : Dictionary = state.get("teamColors", {})
# Sort by seatIndex so chips appear in turn order.
players.sort_custom(func(a: Dictionary, b: Dictionary) -> bool:
@@ -3278,11 +3279,23 @@ func _rebuild_turn_order_strip(state: Dictionary) -> void:
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 team_idx : int = int(p.get("teamIndex", -1))
var hex_str : String = str(team_colors.get(str(team_idx), ""))
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))
# Team-color left border via StyleBoxFlat.
var style := StyleBoxFlat.new()
style.bg_color = Color(0.12, 0.12, 0.14, 0.85)
style.border_width_left = 3
if not hex_str.is_empty():
style.border_color = Color.html("#" + hex_str)
else:
style.border_color = Color(0.4, 0.4, 0.4)
chip.add_theme_stylebox_override("panel", style)
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 "")