Implement multiplayer extension: 2-10 players FFA/Team/Multi-Team
Core engine: - Add SeatIndex, TeamIndex, IsEliminated to PlayerState - Add SeatOrder, GameMode to GameState with helpers: ActiveSeats(), GetNextActiveSeat(), GetEnemyIds(), AreAllies() - Add StartingZones to Board for per-seat placement validation - Add BoardShape, PlayerCount to GameRules - New BoardShapeGenerator: Rectangle (up to 4 seats) + Cross shapes - N-player Initialize() overload; old 2-player overload delegates to it - EndTurn uses GetNextActiveSeat() instead of hardcoded GetOpponentId() - Attack finds target across all enemy players; EliminatePlayer() helper allows multi-player elimination without immediate game over - PlaceArchSpirit validates via StartingZones (legacy row fallback preserved) - AbilitySystem.Own() uses AreAllies() for team-aware ownership checks Database: - GameSession: +player_count, +game_mode, +additional_players_json - CustomLobby: +game_mode, +team_count, +additional_players_json - EF migration: AddMultiplayerSlots (applied) Handlers: - GameCreateCustomLobbyHandler: honours MaxPlayers/GameMode/TeamCount from request - GameJoinCustomLobbyHandler: multi-slot join up to MaxPlayers - GameLobbyReadyHandler: N-player all-ready check; seats/team assignment by mode - GameReadyHandler: builds N-player list from AdditionalPlayersJson - GameHandlerBase.LoadActiveSessionAsync: recognises additional players Client: - Game.gd: get_opponents() returns all non-local players; get_opponent() kept as backward-compat alias returning first opponent 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:
@@ -94,12 +94,19 @@ func get_my_player() -> Dictionary:
|
||||
return _player_by_id(Auth.user_id)
|
||||
|
||||
|
||||
## Returns the PlayerStateDto dict for the opponent, or {}.
|
||||
func get_opponent() -> Dictionary:
|
||||
## Returns all opponent PlayerStateDto dicts (non-local, non-eliminated players).
|
||||
func get_opponents() -> Array:
|
||||
var result: Array = []
|
||||
for p: Dictionary in state.get("players", []):
|
||||
if str(p.get("accountId", "")) != Auth.user_id:
|
||||
return p
|
||||
return {}
|
||||
result.append(p)
|
||||
return result
|
||||
|
||||
|
||||
## Returns the PlayerStateDto dict for the (first) opponent — backward-compat alias.
|
||||
func get_opponent() -> Dictionary:
|
||||
var opps := get_opponents()
|
||||
return opps[0] if not opps.is_empty() else {}
|
||||
|
||||
|
||||
## Returns true when it is the local player's turn.
|
||||
|
||||
Reference in New Issue
Block a user