public override bool Equals(object obj) { if ((obj == null) || !this.GetType().Equals(obj.GetType())) { return(false); } else { BracketGame g = (BracketGame)obj; return((p1 == g.p1) && (p2 == g.p2) || (p1 == g.p2) && (p2 == g.p1)); } }
/// <summary> /// places the seeded players into brackets. if it gets stuck, returns false. /// </summary> /// <param name="game"></param> /// <returns></returns> private bool TryAddGame(BracketGame game) { foreach (Bracket bracket in Brackets) { if (bracket.IsEligible(game) && !bracket.IsFull()) { bracket.AddGame(game); return(true); } } return(false); }
public List <BracketGame> Shuffle(List <BracketGame> game) { int n = game.Count; while (n > 1) { n--; int k = rng.Next(n + 1); BracketGame value = game[k]; game[k] = game[n]; game[n] = value; } return(game); }
public void AddGame(BracketGame game) { Games.Add(game); Players.Add(game.p1); Players.Add(game.p2); }
public bool IsEligible(BracketGame bracket) { return(!(Players.Contains(bracket.p1) || Players.Contains(bracket.p2))); }
public bool IsSeeded(BracketGame bracket) { return(Games.Contains(bracket)); }