|
group2 0.1.0
CSE 125 Group 2
|
Manages match flow: lobby → countdown → in-progress → finished → lobby. More...
#include <MatchController.hpp>
Public Member Functions | |
| void | update (float deltaTime, Registry ®istry, Server &server) |
| Advance the match state machine by one tick. | |
| MatchPhase | getCurrentPhase () |
| Return the current match phase. | |
| void | hostStartedMatch (std::span< const ClientId > expectedPlayers) |
| Start the host-authorized countdown if the match is still in the lobby phase. | |
| void | setSkipLobby (bool v) |
| Enable or disable developer-mode lobby bypass. | |
| int | getWinnerId () |
| Return the winner's client ID, or -1 if no winner yet. | |
| bool | setMatchConfig (const MatchConfig &cfg) |
| bool | setKillsToWin (int killsToWin) |
| bool | setMaxPlayers (int maxPlayers) |
| MatchConfig | getMatchConfig () const |
| void | beginWarmup (std::span< const ClientId > expectedPlayers) |
| void | markGameplayReady (ClientId clientId) |
| void | removeExpectedPlayer (ClientId clientId) |
| bool | allExpectedPlayersReady () const |
Private Member Functions | |
| void | broadcastMatchState (Server &server) |
| Send the current match phase, countdown, and winner to all clients. | |
| bool | validateKillsToWin (int killsToWin) |
| bool | validateMaxPlayers (int maxPlayers) |
| bool | validatePowerupTiming (float initialSpawnDelaySeconds, float respawnCooldownSeconds) |
| void | broadcastMatchConfig (Server &server) |
Private Attributes | |
| MatchPhase | currentPhase = MatchPhase::LOBBY |
| Current phase of the match. | |
| float | countdownTimer = 0.0f |
| Seconds remaining in the current timed phase. | |
| int | winnerId = -1 |
| Client ID of the winner (-1 if none). | |
| bool | skipLobby = false |
| True to auto-promote lobby to countdown. | |
| std::unordered_map< ClientId, bool > | playerReadyStatus |
| Tracks each player's ready status in the lobby. | |
| MatchConfig | config |
| Configuration for current match (e.g. kill threshold to win). | |
| MatchPhase | lastBroadcastPhase = MatchPhase::LOBBY |
| int | lastBroadcastWinnerId = -1 |
| float | lastBroadcastCountdown = -1.0f |
| int | ticksSinceBroadcast = 0 |
Static Private Attributes | |
| static constexpr float | k_warmupDuration |
| Max time to wait for players to load/spawn before starting after host start. | |
| static constexpr float | k_countdownDuration = 5.0f |
| Seconds for the pre-match countdown. | |
| static constexpr float | k_finishedDuration = 5.0f |
| Seconds to show the in-game result banner before post-match. | |
Manages match flow: lobby → countdown → in-progress → finished → lobby.
Transitions between phases based on host starts, timers, and kill thresholds. Broadcasts match state to all clients every tick.
|
nodiscard |
| void MatchController::beginWarmup | ( | std::span< const ClientId > | expectedPlayers | ) |
|
private |
|
private |
Send the current match phase, countdown, and winner to all clients.
PR-4: skip the actual broadcast when nothing observable has changed since the last send.
| server | Network server for broadcasting. |
| MatchPhase MatchController::getCurrentPhase | ( | ) |
Return the current match phase.
|
nodiscard |
| int MatchController::getWinnerId | ( | ) |
Return the winner's client ID, or -1 if no winner yet.
| void MatchController::hostStartedMatch | ( | std::span< const ClientId > | expectedPlayers | ) |
Start the host-authorized countdown if the match is still in the lobby phase.
| void MatchController::markGameplayReady | ( | ClientId | clientId | ) |
| void MatchController::removeExpectedPlayer | ( | ClientId | clientId | ) |
| bool MatchController::setKillsToWin | ( | int | killsToWin | ) |
| bool MatchController::setMatchConfig | ( | const MatchConfig & | cfg | ) |
| bool MatchController::setMaxPlayers | ( | int | maxPlayers | ) |
| void MatchController::setSkipLobby | ( | bool | v | ) |
Enable or disable developer-mode lobby bypass.
Advance the match state machine by one tick.
| deltaTime | Fixed physics delta time in seconds. |
| registry | The ECS registry (for win condition checks). |
| server | Network server (for broadcasting state). |
|
private |
|
private |
|
private |
|
private |
Configuration for current match (e.g. kill threshold to win).
|
private |
Seconds remaining in the current timed phase.
|
private |
Current phase of the match.
|
staticconstexprprivate |
Seconds for the pre-match countdown.
|
staticconstexprprivate |
Seconds to show the in-game result banner before post-match.
|
staticconstexprprivate |
Max time to wait for players to load/spawn before starting after host start.
|
private |
|
private |
|
private |
|
private |
Tracks each player's ready status in the lobby.
|
private |
True to auto-promote lobby to countdown.
|
private |
|
private |
Client ID of the winner (-1 if none).