示例#1
0
        private bool HavePlayedTogether(PlayerSwissPairing player1, PlayerSwissPairing player2)
        {
            var pairingsWithPlayer1 = _event.Rounds
                                      .SelectMany(r => r.Pairings)
                                      .Where(pairing => pairing.Players.Any(player => player.Id == player1.Player.Id));

            if (pairingsWithPlayer1.Any(pairing => pairing.Players.Any(player => player.Id == player2.Player.Id)))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        private PlayerSwissPairing GetNextOpposingPlayer(PlayerSwissPairing player, Round nextRound, PlayerSwissPairing[] playerSwissPairingArray)
        {
            var playersOrderedByNbWins = playerSwissPairingArray
                                         .Where(p => !p.IsPaired && p.Player.Id != player.Player.Id)
                                         .OrderByDescending(p => p.NbWins)
                                         .ToArray();


            if (playersOrderedByNbWins.Length == 0)
            {
                return(null);
            }

            for (int i = 0; i < playersOrderedByNbWins.Length; i++)
            {
                if (!HavePlayedTogether(player, playersOrderedByNbWins[i]))
                {
                    return(playersOrderedByNbWins[i]);
                }
            }

            return(null);
        }