Client multiplayer: N-player targeting, placement zones, lobby creation, outcomes

Server:
- BoardDto: add StartingZones (seat → coord list) so client knows valid placement tiles
- GameEngine.ToBoardDto: serialize StartingZones into the DTO

Client – Game.gd:
- get_enemy_players(): returns all players not on the local player's team
- get_all_enemy_units(): flat list of field + archSpirit from all enemies
- game_over signal: adds player_outcomes: Array parameter
- game.over push: extracts playerOutcomes array and passes to signal

Client – game_screen.gd:
- _valid_placement_tiles(): uses board.startingZones[seatIndex] when available; falls back to legacy row logic
- _valid_attack_target_coords/ids: use Game.get_all_enemy_units() instead of single opponent
- ability target picker: uses get_all_enemy_units() for enemy units
- player-panel builder (zone abilities): iterates get_enemy_players() for N-player
- _on_game_over: shows per-player rank deltas from playerOutcomes when present

Client – CustomLobby.gd:
- State: max_players, game_mode, team_count fields (cleared on clear_state)
- create(): accepts p_max_players, p_game_mode, p_team_count params; sends to server
- join(): stores max_players/game_mode/team_count from server response
- game.custom.started: calls clear_state() before emitting game_starting

Client – FreePlayScreen:
- Create dialog: MaxPlayersSpinner (2-10), GameModeOption (FFA/Teams/MultiTeam), TeamCountRow (hidden for FFA)
- GameModeOption.item_selected toggles team_count_row visibility
- _on_create_confirmed: passes max_players, game_mode, team_count to CustomLobby.create()

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 06:12:14 -04:00
co-authored by Claude Happy
parent 74af9aa4bd
commit 9d4302cc6c
7 changed files with 192 additions and 52 deletions
+31 -9
View File
@@ -60,6 +60,9 @@ var is_host : bool = false
var i_am_ready : bool = false
var partner_ready : bool = false
var first_turn_pref: String = "random"
var max_players : int = 2
var game_mode : String = "FFA"
var team_count : int = 1
# ── Lifecycle ─────────────────────────────────────────────────────────────────
@@ -76,18 +79,29 @@ func clear_state() -> void:
i_am_ready = false
partner_ready = false
first_turn_pref = "random"
max_players = 2
game_mode = "FFA"
team_count = 1
# ── Public actions ────────────────────────────────────────────────────────────
## Create a new lobby. On success, lobby_id and is_host are set; navigate to LobbyRoomScreen.
func create(lobby_name: String, deck_id: String, password: String,
rules_override: Dictionary, on_success: Callable = Callable(),
rules_override: Dictionary,
p_max_players: int = 2, p_game_mode: String = "FFA", p_team_count: int = 1,
on_success: Callable = Callable(),
on_error: Callable = Callable()) -> void:
clear_state()
my_deck_id = deck_id
max_players = p_max_players
game_mode = p_game_mode
team_count = p_team_count
var payload := {
"lobbyName": lobby_name,
"deckId": deck_id,
"lobbyName": lobby_name,
"deckId": deck_id,
"maxPlayers": p_max_players,
"gameMode": p_game_mode,
"teamCount": p_team_count,
}
if password != "":
payload["password"] = password
@@ -96,9 +110,13 @@ func create(lobby_name: String, deck_id: String, password: String,
Network.request("game.custom.create", payload,
func(_t: String, p: Variant) -> void:
var d := p as Dictionary
lobby_id = str(d.get("lobbyId", ""))
lobby = d
is_host = true
lobby_id = str(d.get("lobbyId", ""))
lobby = d
is_host = true
# Extract server-confirmed values (server may adjust/clamp).
max_players = int(d.get("maxPlayers", p_max_players))
game_mode = str(d.get("gameMode", p_game_mode))
team_count = int(d.get("teamCount", p_team_count))
if on_success.is_valid(): on_success.call(d),
func(code: String, msg: String) -> void:
print("[CustomLobby] ERR create ", code, " ", msg)
@@ -117,9 +135,12 @@ func join(lid: String, deck_id: String, password: String,
Network.request("game.custom.join", payload,
func(_t: String, p: Variant) -> void:
var d := p as Dictionary
lobby_id = str(d.get("lobbyId", ""))
lobby = d
is_host = false
lobby_id = str(d.get("lobbyId", ""))
lobby = d
is_host = false
max_players = int(d.get("maxPlayers", 2))
game_mode = str(d.get("gameMode", "FFA"))
team_count = int(d.get("teamCount", 1))
# Ensure the lobby dict has the fields _refresh_display needs.
lobby["guestAccountId"] = str(d.get("guestAccountId", ""))
lobby["guestDisplayName"] = str(d.get("guestDisplayName", ""))
@@ -296,6 +317,7 @@ func _on_server_push(type: String, payload: Variant) -> void:
Game.session_id = sid
Game.opponent_name = oname
Game.state = {}
clear_state()
game_starting.emit(sid, opp, oname)
"game.custom.preset.vote_requested":