Add the ability to pause singleplayer matches (#68)
CI / build-and-test (push) Successful in 1m54s
CI / production-build (push) Successful in 11m11s

Reviewed-on: #68
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #68.
This commit is contained in:
2026-09-26 16:25:36 +00:00
committed by EIREXE
parent 94e292026e
commit 90412fa80d
4 changed files with 131 additions and 7 deletions
+17
View File
@@ -42,6 +42,15 @@ pub enum SessionConfigError {
}
impl SessionConfig {
/// Returns whether this match has more than one remote participant.
pub fn is_multiplayer(&self) -> bool {
self.players.len() > 1
|| self
.players
.iter()
.any(|player| matches!(player, PlayerConnection::Remote(_)))
}
pub fn from_args(args: &Args, player_count: usize) -> Result<Self, SessionConfigError> {
if player_count == 0 {
return Err(SessionConfigError::NoPlayers);
@@ -196,6 +205,13 @@ mod tests {
config.players,
[PlayerConnection::Local, PlayerConnection::Local]
);
assert!(config.is_multiplayer());
}
#[test]
fn single_local_player_is_not_multiplayer() {
let config = SessionConfig::from_args(&args(&["game", "--players", "1"]), 1).unwrap();
assert!(!config.is_multiplayer());
}
#[test]
@@ -207,6 +223,7 @@ mod tests {
.unwrap();
assert!(matches!(config.players[0], PlayerConnection::Local));
assert!(matches!(config.players[1], PlayerConnection::Remote(_)));
assert!(config.is_multiplayer());
}
#[test]