Example #1
0
 public static void ResetGame()
 {
     ListOfPlayers.Clear();
     ListOfOrderedPlayers.Clear();
     Grid.Empty();
     Bag.EmptyTheBag();
 }
Example #2
0
        public static void DeterminePlayerOrder()
        {
            // determine the player order, and store in playerOrder[]
            ListOfOrderedPlayers.Clear(); //empty out the ordered player list so it doesn't just get added to.
            Player firstPlayer = Game.ListOfPlayers[0];
            int    mostMoves   = 0;

            foreach (Player p in Game.ListOfPlayers)
            {
                p.MaxPlaceableTiles(out int highestCount);
                Console.WriteLine($"{p} can place {highestCount} tiles");

                if (highestCount > mostMoves)
                {
                    firstPlayer = p;
                    mostMoves   = highestCount;
                }
            }

            Console.WriteLine($"{firstPlayer} goes first with {mostMoves} tiles");

            int startingPlayerIndex = Game.ListOfPlayers.IndexOf(firstPlayer);

            Game.ListOfOrderedPlayers.Add(firstPlayer);
            int currentPlayerIndex = startingPlayerIndex + 1;

            while (Game.ListOfOrderedPlayers.Count() < Game.ListOfPlayers.Count())
            {
                if (currentPlayerIndex >= Game.ListOfPlayers.Count())
                {
                    currentPlayerIndex = 0;
                    Game.ListOfOrderedPlayers.Add(Game.ListOfPlayers[currentPlayerIndex]);
                }
                else
                {
                    Game.ListOfOrderedPlayers.Add(Game.ListOfPlayers[currentPlayerIndex]);
                }
                currentPlayerIndex++;
            }

            Console.WriteLine("This playing order is as follows:");
            foreach (Player p in Game.ListOfOrderedPlayers)
            {
                Console.WriteLine(p);
            }

            Game.CurrentPlayer = firstPlayer;
        }
Example #3
0
 private static int CurrentPlayerIndex()
 {
     //Console.WriteLine($"The current player index is {ListOfOrderedPlayers.IndexOf(CurrentPlayer)}");
     return(ListOfOrderedPlayers.IndexOf(CurrentPlayer));
 }