/// <summary> /// Check to make sure a specified player only sees another opponent no more than once in tournament /// </summary> /// <param name="player">the player index number</param> /// <param name="Games">>List of Games in a tournament</param> /// <returns>returns true if no opponent is only seen zero or one time</returns> public static Task <bool> CheckSameOpponent(int player, List <Game> Games) { return(Task.Run(() => { var rinks = new Rink[Games.Count]; foreach (var game in Games) { rinks[game.GameNumber] = game.Rinks.Find(x => x.Players.Any(y => y == player)); } var opponents = new List <int>(); foreach (var rink in rinks) { foreach (var opponent in rink.Players) { if (opponent != player) { if (opponents.Contains(opponent)) { return false; } opponents.Add(opponent); } } } return true; })); }
/// <summary> /// Add a rink to game /// </summary> /// <param name="rink">a Rink object</param> public void Add(Rink rink) { Rinks.Add(rink); }