Esempio n. 1
0
        public void SelectFirstPlayer()
        {
            // Each player rolls the dice
            // Whoever gets highest roll goes first
            // If two or more players both roll same same highest roll, they roll again
            // Until just one player got the highest roll

            narrator.SaySelectingFirstPlayer();
            Player[] candidates = players;

            while (candidates.Length > 1)
            {
                int           highestRoll           = 0;
                List <Player> highestRollingPlayers = new List <Player>();

                foreach (Player player in candidates)
                {
                    int roll = dice.Roll();
                    narrator.SayRoll(player, roll);

                    if (roll > highestRoll)
                    {
                        highestRoll = roll;
                        highestRollingPlayers.Clear();
                        highestRollingPlayers.Add(player);
                    }
                    else if (roll == highestRoll)
                    {
                        highestRollingPlayers.Add(player);
                    }
                }

                candidates = highestRollingPlayers.ToArray();
            }

            // We only have one candidate remaining, so they are the single highest rolling player
            // and will be the player to go first
            currentPlayer = candidates[0];
            narrator.SayFirstPlayer(currentPlayer);
        }