1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Use elimination config from file instead of hardcoded #30

This commit is contained in:
NG (Graham)
2025-07-22 22:39:38 -04:00
parent fd11b8746b
commit a904423a83
5 changed files with 23 additions and 9 deletions

View File

@@ -1,13 +1,15 @@
pub struct GameMatches {
matches: std::collections::HashMap<String, tokio::sync::mpsc::Sender<super::GameMessage>>,
routing: std::collections::HashMap<i32, String>, // user id to game guid
mode_configs: oj_rc_core::data::game_mode::GameModeConfigs,
}
impl GameMatches {
pub fn new() -> Self {
pub fn new(conf: &oj_rc_core::persist::config::ConfigImpl) -> Self {
Self {
matches: std::collections::HashMap::new(),
routing: std::collections::HashMap::new(),
mode_configs: <oj_rc_core::persist::config::ConfigImpl as oj_rc_core::ConfigProvider<()>>::gamemodes(conf),
}
}
@@ -19,7 +21,10 @@ impl GameMatches {
async fn start_new_match_engine(&self, _user: &Box<dyn oj_rc_core::persist::user::MultiplayerUser + Send + Sync + 'static>, guid: &str) -> tokio::sync::mpsc::Sender<super::GameMessage> {
// TODO figure out gamemode and act accordingly
let engine = super::GenericGamemodeEngine::new(guid.to_owned(), super::modes::EliminationLogic::new());
let engine = super::GenericGamemodeEngine::new(
guid.to_owned(),
super::modes::EliminationLogic::new(&self.mode_configs.elimination)
);
engine.spawn()
}