Пример #1
0
        public void CalculateWinner(Player player)
        {
            if (CurrentWinners.Count == 0)
            {
                CurrentWinners.Add(player);
                return;
            }

            var winner = handComparer.CompareTwoHands(CurrentWinners.First(), player);

            // if we have a tie, we add the additional player to the winners list
            if (winner == 0)
            {
                CurrentWinners.Add(player);
            }
            // if the second player wins, we clear the list first, then add the player
            // this works because any existing players would have equal hands and the
            // new player's hand is better
            if (winner == 2)
            {
                CurrentWinners.Clear();
                CurrentWinners.Add(player);
            }
        }