Rename pending match to match config and add match state (#51)
Reviewed-on: #51 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #51.
This commit is contained in:
@@ -3,7 +3,7 @@ use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
fighter::FighterId,
|
||||
match_loading::{MatchPlayer, PendingMatch},
|
||||
match_loading::{MatchConfig, MatchPlayer, MatchRules},
|
||||
stage::manifest::StageId,
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ impl MenuMatchConfig {
|
||||
!has_unselected_fighter
|
||||
}
|
||||
|
||||
pub fn to_pending_match(&self) -> Result<PendingMatch, MenuMatchConfigErrors> {
|
||||
pub fn to_match_config(&self) -> Result<MatchConfig, MenuMatchConfigErrors> {
|
||||
let mut match_players = vec![];
|
||||
|
||||
let stage = self.stage.ok_or(MenuMatchConfigErrors::StageNotSelected)?;
|
||||
@@ -78,9 +78,28 @@ impl MenuMatchConfig {
|
||||
});
|
||||
}
|
||||
|
||||
Ok(PendingMatch {
|
||||
Ok(MatchConfig {
|
||||
players: match_players,
|
||||
stage,
|
||||
rules: MatchRules::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn menu_config_uses_default_match_rules() {
|
||||
let menu = MenuMatchConfig {
|
||||
stage: Some(StageId::TestStage),
|
||||
players: vec![MenuMatchPlayerSlot {
|
||||
slot: 0,
|
||||
fighter: Some(FighterId::TestFighter),
|
||||
}],
|
||||
};
|
||||
|
||||
assert_eq!(menu.to_match_config().unwrap().rules, MatchRules::default());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user