feat: knockout brackets

This commit is contained in:
2026-03-26 12:52:49 -04:00
Unverified
parent 12c5c675e2
commit 15ffa880f7
5 changed files with 460 additions and 80 deletions

View File

@@ -4,17 +4,26 @@ use crate::server::Server;
pub mod round_robin;
pub use round_robin::RoundRobin;
pub mod knockout_bracket;
pub use knockout_bracket::KnockoutBracket;
#[async_trait]
pub trait Tournament {
fn new(ready_players: &[String]) -> Self
async fn new(ready_players: &[String], server: &Server) -> Self
where
Self: Sized;
async fn next(&mut self, server: &Server);
async fn start(&mut self, server: &Server);
async fn cancel(&mut self, server: &Server);
fn inform_winner(&mut self, winner: String, is_tie: bool);
async fn inform_winner(
&mut self,
winner: String,
match_id: u32,
player1: String,
player2: String,
);
fn contains_player(&self, username: String) -> bool;
fn is_completed(&self) -> bool;
fn get_players(&self) -> Vec<String>;
fn get_type(&self) -> String;
}