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:
@@ -54,6 +54,9 @@ signal rule_suggestion_rejected
|
||||
## Emitted when a lobby action is rejected gracefully (non-fatal), for lightweight UX toasts.
|
||||
signal lobby_notice(message: String)
|
||||
|
||||
## Pushed (or acked) when the host changes a seat's team assignment.
|
||||
signal team_assignment_changed(seat_teams: Dictionary)
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var lobby_id : String = ""
|
||||
@@ -67,6 +70,8 @@ var first_turn_pref : String = "random"
|
||||
var max_players : int = 2
|
||||
var game_mode : String = "FFA"
|
||||
var team_count : int = 1
|
||||
## Seat index → team index overrides. Empty = use default (seat % team_count).
|
||||
var seat_teams : Dictionary = {}
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -87,6 +92,7 @@ func clear_state() -> void:
|
||||
max_players = 2
|
||||
game_mode = "FFA"
|
||||
team_count = 1
|
||||
seat_teams = {}
|
||||
|
||||
# ── Public actions ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -152,6 +158,13 @@ func join(lid: String, deck_id: String, password: String,
|
||||
lobby["guestDisplayName"] = str(d.get("guestDisplayName", ""))
|
||||
lobby["hasGuest"] = true
|
||||
lobby["additionalPlayers"] = d.get("additionalPlayers", [])
|
||||
# Apply team assignments from join response if present.
|
||||
var raw_st := d.get("seatTeams", null)
|
||||
if raw_st != null:
|
||||
seat_teams.clear()
|
||||
for k in (raw_st as Dictionary):
|
||||
seat_teams[int(k)] = int(raw_st[k])
|
||||
lobby["seatTeams"] = seat_teams
|
||||
if on_success.is_valid(): on_success.call(d),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR join ", code, " ", msg)
|
||||
@@ -290,6 +303,23 @@ func reject_rule_suggestion() -> void:
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR reject_rule_suggestion ", code, " ", msg))
|
||||
|
||||
|
||||
## Host-only: reassign a player seat to a different team.
|
||||
func reassign_team(seat_index: int, team_index: int) -> void:
|
||||
Network.request("game.custom.reassign_team",
|
||||
{ "lobbyId": lobby_id, "seatIndex": seat_index, "teamIndex": team_index },
|
||||
func(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
var raw := d.get("seatTeams", {}) as Dictionary
|
||||
seat_teams.clear()
|
||||
for k in raw:
|
||||
seat_teams[int(k)] = int(raw[k])
|
||||
lobby["seatTeams"] = seat_teams
|
||||
team_assignment_changed.emit(seat_teams),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR reassign_team ", code, " ", msg))
|
||||
|
||||
|
||||
# ── Private ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_server_push(type: String, payload: Variant) -> void:
|
||||
@@ -381,3 +411,12 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
|
||||
"game.custom.lobby.rule_suggestion.rejected":
|
||||
rule_suggestion_rejected.emit()
|
||||
|
||||
"game.custom.lobby.team_reassigned":
|
||||
var d := payload as Dictionary
|
||||
var raw := d.get("seatTeams", {}) as Dictionary
|
||||
seat_teams.clear()
|
||||
for k in raw:
|
||||
seat_teams[int(k)] = int(raw[k])
|
||||
lobby["seatTeams"] = seat_teams
|
||||
team_assignment_changed.emit(seat_teams)
|
||||
|
||||
@@ -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