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:
@@ -20,7 +20,8 @@ signal state_updated(state: Dictionary)
|
||||
|
||||
## Emitted when the game ends.
|
||||
signal game_over(winner_account_id: String, win_condition: String,
|
||||
winner_rank_delta: int, loser_rank_delta: int)
|
||||
winner_rank_delta: int, loser_rank_delta: int,
|
||||
player_outcomes: Array)
|
||||
|
||||
## Emitted when the server abandons an Initializing session (e.g. server restart).
|
||||
signal session_abandoned(reason: String)
|
||||
@@ -147,6 +148,28 @@ func get_opponent_field() -> Array:
|
||||
return get_opponent().get("field", [])
|
||||
|
||||
|
||||
## Returns all enemy PlayerStateDto dicts (players not on the same team as the local player).
|
||||
func get_enemy_players() -> Array:
|
||||
var my_team : int = int(get_my_player().get("teamIndex", -1))
|
||||
var result : Array = []
|
||||
for p: Dictionary in state.get("players", []):
|
||||
var pid : String = str(p.get("accountId", ""))
|
||||
if pid == Auth.user_id: continue
|
||||
if int(p.get("teamIndex", -2)) != my_team:
|
||||
result.append(p)
|
||||
return result
|
||||
|
||||
|
||||
## Returns all units (field + archSpirit) belonging to enemy players, as a flat Array.
|
||||
func get_all_enemy_units() -> Array:
|
||||
var units : Array = []
|
||||
for p: Dictionary in get_enemy_players():
|
||||
units.append_array(p.get("field", []))
|
||||
var arch : Dictionary = p.get("archSpirit", {})
|
||||
if not arch.is_empty(): units.append(arch)
|
||||
return units
|
||||
|
||||
|
||||
## Returns a TileDto dict by coord, or {}.
|
||||
func get_tile(x: int, y: int) -> Dictionary:
|
||||
for t: Dictionary in get_tiles():
|
||||
@@ -546,13 +569,14 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
_apply_delta(delta)
|
||||
|
||||
"game.over":
|
||||
var d := payload as Dictionary
|
||||
var winner : String = str(d.get("winnerAccountId", ""))
|
||||
var wc : String = str(d.get("winCondition", ""))
|
||||
var wd : int = int(d.get("winnerRankDelta", 0))
|
||||
var ld : int = int(d.get("loserRankDelta", 0))
|
||||
var d := payload as Dictionary
|
||||
var winner : String = str(d.get("winnerAccountId", ""))
|
||||
var wc : String = str(d.get("winCondition", ""))
|
||||
var wd : int = int(d.get("winnerRankDelta", 0))
|
||||
var ld : int = int(d.get("loserRankDelta", 0))
|
||||
var outcomes : Array = d.get("playerOutcomes", []) as Array
|
||||
state = {} # Clear stale state so a new GameScreen calls send_ready() on the next match
|
||||
game_over.emit(winner, wc, wd, ld)
|
||||
game_over.emit(winner, wc, wd, ld, outcomes)
|
||||
|
||||
"game.session_abandoned":
|
||||
var d := payload as Dictionary
|
||||
|
||||
Reference in New Issue
Block a user