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:
dingo
2026-03-25 23:57:36 -04:00
co-authored by Claude Happy
parent a023d6ff94
commit f700fd5de6
19 changed files with 1196 additions and 88 deletions
@@ -44,8 +44,12 @@ internal abstract class GameHandlerBase
.SingleOrDefaultAsync(ct)
?? throw new GameException("SESSION_NOT_FOUND");
if (session.PlayerOneAccountId.ToString() != actorId &&
session.PlayerTwoAccountId.ToString() != actorId)
bool isKnownPlayer = session.PlayerOneAccountId.ToString() == actorId ||
session.PlayerTwoAccountId.ToString() == actorId ||
(session.AdditionalPlayersJson != null &&
session.AdditionalPlayersJson.Contains(actorId));
if (!isKnownPlayer)
throw new GameException("NOT_IN_SESSION");
if (session.Status != GameSessionStatus.Active)