M1: Match state machine

Match (src/sim/match.gd) runs a server's matches back to back: lobby,
countdown, drop, play and results, then a fresh island and the lobby again.
It is stepped once per server tick and has no scene-tree or clock dependency.

- MatchRules holds max and min players, team size, the lobby, countdown and
  results timers (defaults in Tuning.MATCH_*) and whether bots fill empty
  places.
- Participants are server-chosen handles. Joining during a match waits for
  the next; leaving during the drop or play places the leaver as eliminated.
- Placements, winners (last team standing) and events for phase changes,
  joins, leaves, places, match start and end.
- Match 0 uses the server's seed; later matches derive their seed from it and
  their index. The next match's Simulation is built when the lobby opens.
- ServerLoop now drives a Match (immediate rules by default, so the smoke
  match is unchanged: same state hash), rebuilds bots each match, and counts
  server ticks across matches. The headless server logs match events.

Tests: test_match (13) covers every transition, leaving in each phase, an
empty lobby, an empty match, teams, late joiners, and ten consecutive matches
that each start identical to a freshly built simulation. A ServerLoop test
checks the server goes back to the lobby and starts the next match.

Closes #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 20:24:00 -05:00
co-authored by Claude Opus 5.5
parent 0013a81658
commit c6f3c19004
11 changed files with 649 additions and 23 deletions
+9
View File
@@ -16,6 +16,15 @@ const DUO_TEAMS: int = 12
const DUO_TEAM_SIZE: int = 2
const REVIVE_SECONDS: float = 6.0
# Match flow, in seconds. See Match and MatchRules, which can override each one.
## The lobby counts down once this many participants have joined.
const MATCH_MIN_PLAYERS: int = 1
## With enough players, the lobby waits this long for more before counting down.
const MATCH_LOBBY_SECONDS: float = 20.0
const MATCH_COUNTDOWN_SECONDS: float = 10.0
## Results stay up this long before the server returns to the lobby.
const MATCH_RESULTS_SECONDS: float = 15.0
# Player
const PLAYER_MAX_HEALTH: int = 100
const PLAYER_MAX_ARMOR: int = 100