feat(tournaments): create specific tournament types dynamically

This commit is contained in:
2025-12-30 23:58:08 -05:00
Unverified
parent fff0343559
commit 16a5eef659
2 changed files with 9 additions and 20 deletions

View File

@@ -10,11 +10,10 @@ pub struct Server {
pub tournament: WrappedTournament,
pub waiting_timeout: Arc<RwLock<u64>>,
pub demo_mode: bool,
pub tournament_type: String,
}
impl Server {
pub fn new(admin_password: String, demo_mode: bool, tournament_type: String) -> Server {
pub fn new(admin_password: String, demo_mode: bool) -> Server {
Server {
clients: Arc::new(RwLock::new(HashMap::new())),
usernames: Arc::new(RwLock::new(HashMap::new())),
@@ -25,7 +24,6 @@ impl Server {
tournament: Arc::new(RwLock::new(None)),
waiting_timeout: Arc::new(RwLock::new(5000)),
demo_mode,
tournament_type,
}
}
@@ -512,6 +510,7 @@ impl Server {
&self,
tx: UnboundedSender<Message>,
addr: SocketAddr,
tournament_type: String,
) -> Result<(), anyhow::Error> {
if !self.auth_check(addr).await {
return Err(anyhow::anyhow!("ERROR:INVALID:AUTH"));
@@ -535,7 +534,7 @@ impl Server {
drop(clients_guard);
let mut tourney = match self.tournament_type.as_str() {
let mut tourney = match tournament_type.as_str() {
"round_robin" => crate::tournaments::round_robin::RoundRobin::new(&ready_players),
&_ => crate::tournaments::round_robin::RoundRobin::new(&ready_players),
};