Add Decagonal board shape, team reassignment, and multiplayer considerations
- BoardShapeGenerator: add MakeDecagonal() for 7-10 players (10-armed radial, 11x11 arena, 21x21 total); AutoShape now routes 7-10 to Decagonal - CustomLobby: add TeamAssignmentsJson (seat -> team override map) - GameMessages: add ReassignTeamRequest/Response, LobbyTeamAssignmentChangedPush, SeatTeams field on JoinCustomLobbyResponse - GameReassignTeamHandler: new game.custom.reassign_team handler (host-only); pushes team_reassigned to all participants including additional players - EF migration: AddTeamAssignmentsToLobby (applied to pg-forge-01) - Client CustomLobby.gd: seat_teams state, reassign_team() action, push handler - lobby_room_screen.gd: _rebuild_team_controls() renders host-only [<] Tx [>] cycle buttons per seat in team modes; _team_label() reads seat_teams overrides - OVERALL.md: add Considerations for Later (fog of war, asymmetric teams, ranked ELO) 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:
@@ -49,6 +49,7 @@ const RULES_DIALOG = preload("res://scenes/free_play/components/RulesEditorDialo
|
||||
|
||||
var _first_turn_pref : String = "random"
|
||||
var _current_rules : Dictionary = {}
|
||||
var _team_panel : VBoxContainer = null # dynamically added team-controls section
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -72,6 +73,7 @@ func _exit_tree() -> void:
|
||||
CustomLobby.rule_suggestion_received.disconnect(_on_rule_suggestion_received)
|
||||
CustomLobby.rule_suggestion_rejected.disconnect(_on_rule_suggestion_rejected)
|
||||
CustomLobby.lobby_notice.disconnect(_on_lobby_notice)
|
||||
CustomLobby.team_assignment_changed.disconnect(_on_team_assignment_changed)
|
||||
|
||||
# ── Setup ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -137,6 +139,7 @@ func _connect_signals() -> void:
|
||||
CustomLobby.rule_suggestion_received.connect(_on_rule_suggestion_received)
|
||||
CustomLobby.rule_suggestion_rejected.connect(_on_rule_suggestion_rejected)
|
||||
CustomLobby.lobby_notice.connect(_on_lobby_notice)
|
||||
CustomLobby.team_assignment_changed.connect(_on_team_assignment_changed)
|
||||
|
||||
# ── Refresh ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -173,6 +176,9 @@ func _refresh_display() -> void:
|
||||
# Additional players (3+) from lobby dict.
|
||||
_rebuild_additional_players_panel(lobby, max_players)
|
||||
|
||||
# Team assignment controls (host-only, team modes only).
|
||||
_rebuild_team_controls(lobby, max_players, game_mode, team_count)
|
||||
|
||||
# Hide first-turn buttons for lobbies with more than 2 players (seat order is the turn order).
|
||||
var show_first_turn : bool = max_players <= 2
|
||||
_first_turn_section.visible = show_first_turn
|
||||
@@ -230,7 +236,11 @@ func _rebuild_additional_players_panel(lobby: Dictionary, max_players: int) -> v
|
||||
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
|
||||
var tidx : int
|
||||
if CustomLobby.seat_teams.has(seat_index):
|
||||
tidx = int(CustomLobby.seat_teams[seat_index])
|
||||
else:
|
||||
tidx = seat_index % team_count
|
||||
return " [T%d]" % tidx
|
||||
|
||||
|
||||
@@ -249,6 +259,98 @@ func _make_player_slot_row(label_text: String, is_ready: bool) -> HBoxContainer:
|
||||
return hbox
|
||||
|
||||
|
||||
## Rebuild the host-only team assignment panel (shown only in team game modes).
|
||||
## Each row: "[Seat N: <name>] [<] T0 [>]"
|
||||
func _rebuild_team_controls(lobby: Dictionary, max_players: int,
|
||||
game_mode: String, team_count: int) -> void:
|
||||
# Remove old panel if present.
|
||||
if _team_panel != null and is_instance_valid(_team_panel):
|
||||
_team_panel.queue_free()
|
||||
_team_panel = null
|
||||
|
||||
# Only show for host in non-FFA team games.
|
||||
if not CustomLobby.is_host or game_mode == "FFA" or team_count <= 1:
|
||||
return
|
||||
|
||||
var panel := VBoxContainer.new()
|
||||
panel.add_theme_constant_override("separation", 4)
|
||||
|
||||
var header := Label.new()
|
||||
header.text = "— Team Assignments —"
|
||||
header.add_theme_font_size_override("font_size", 12)
|
||||
header.modulate = Color(0.7, 0.7, 0.7)
|
||||
panel.add_child(header)
|
||||
|
||||
# Seat names: host = 0, guest = 1, additional = 2+
|
||||
var host_name : String = str(lobby.get("hostDisplayName", "Host"))
|
||||
var guest_name : String = str(lobby.get("guestDisplayName", "Guest"))
|
||||
var addl : Array = lobby.get("additionalPlayers", []) as Array
|
||||
|
||||
for seat_index in range(max_players):
|
||||
var seat_name : String
|
||||
if seat_index == 0:
|
||||
seat_name = host_name
|
||||
elif seat_index == 1:
|
||||
seat_name = guest_name
|
||||
else:
|
||||
var ap_idx : int = seat_index - 2
|
||||
if ap_idx < addl.size():
|
||||
var ap := addl[ap_idx] as Dictionary
|
||||
seat_name = str(ap.get("displayName", "Player %d" % (seat_index + 1)))
|
||||
else:
|
||||
seat_name = "Seat %d" % (seat_index + 1)
|
||||
|
||||
var current_team : int
|
||||
if CustomLobby.seat_teams.has(seat_index):
|
||||
current_team = int(CustomLobby.seat_teams[seat_index])
|
||||
else:
|
||||
current_team = seat_index % team_count
|
||||
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 6)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = "Seat %d (%s):" % [seat_index + 1, seat_name]
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.add_theme_font_size_override("font_size", 12)
|
||||
|
||||
var prev_btn := Button.new()
|
||||
prev_btn.text = "<"
|
||||
prev_btn.custom_minimum_size = Vector2(24, 24)
|
||||
|
||||
var team_lbl := Label.new()
|
||||
team_lbl.text = "T%d" % current_team
|
||||
team_lbl.add_theme_font_size_override("font_size", 12)
|
||||
team_lbl.custom_minimum_size = Vector2(28, 0)
|
||||
team_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
|
||||
var next_btn := Button.new()
|
||||
next_btn.text = ">"
|
||||
next_btn.custom_minimum_size = Vector2(24, 24)
|
||||
|
||||
# Capture values for the closures.
|
||||
var captured_seat : int = seat_index
|
||||
var captured_tc : int = team_count
|
||||
prev_btn.pressed.connect(func():
|
||||
var t : int = int(CustomLobby.seat_teams.get(captured_seat, captured_seat % captured_tc))
|
||||
CustomLobby.reassign_team(captured_seat, (t - 1 + captured_tc) % captured_tc))
|
||||
next_btn.pressed.connect(func():
|
||||
var t : int = int(CustomLobby.seat_teams.get(captured_seat, captured_seat % captured_tc))
|
||||
CustomLobby.reassign_team(captured_seat, (t + 1) % captured_tc))
|
||||
|
||||
row.add_child(name_lbl)
|
||||
row.add_child(prev_btn)
|
||||
row.add_child(team_lbl)
|
||||
row.add_child(next_btn)
|
||||
panel.add_child(row)
|
||||
|
||||
# Insert panel after the additional players container.
|
||||
var parent := additional_players_container.get_parent()
|
||||
if parent != null:
|
||||
parent.add_child(panel)
|
||||
_team_panel = panel
|
||||
|
||||
|
||||
func _update_ready_indicators(host_ready: bool, guest_ready: bool) -> void:
|
||||
host_ready_indicator.text = "✓ READY" if host_ready else "Not ready"
|
||||
host_ready_indicator.modulate = Color(0.2, 0.9, 0.3) if host_ready else Color(0.6, 0.6, 0.6)
|
||||
@@ -363,6 +465,10 @@ func _on_lobby_notice(message: String) -> void:
|
||||
_show_toast(message)
|
||||
|
||||
|
||||
func _on_team_assignment_changed(_seat_teams: Dictionary) -> void:
|
||||
_refresh_display()
|
||||
|
||||
|
||||
func _on_suggestion_accept_pressed() -> void:
|
||||
suggestion_banner.visible = false
|
||||
CustomLobby.accept_rule_suggestion()
|
||||
|
||||
Reference in New Issue
Block a user