Exemple #1
0
        /// <summary>
        /// Called when the game is over. Prints out all turns of the winner.
        /// </summary>
        /// <param name="game"></param>
        private static void GameOver(GameModel game)
        {
            Graphics.GameHeader();
            Console.WriteLine();
            Graphics.PrintInGreen(false, " The game is over! Winner is: ");
            Graphics.PrintInGreen(true, $"{game.Winner.Name}.");
            Console.WriteLine();
            Console.WriteLine($" {game.Winner.Name}'s turns are as follows:");
            Console.WriteLine();
            int i = 1; // Turn counter.

            // Print out all turns of the winner.
            foreach (var turn in game.Winner.Turns)
            {
                Console.WriteLine($" Round {i}");
                turn.PrintTurn();
                i++; // Add 1 to counter.
            }
            Console.WriteLine();
            Console.WriteLine($" That adds up to the winning score {game.WinningScore} and this game is over.");
            Console.WriteLine(" Thank you for playing!");
            Console.WriteLine();
            Graphics.PrintInGreen(true, " Press Enter to continue to Main Menu.");
            Console.ReadLine();
            MenuHandling.MainMenu();
        }
Exemple #2
0
        /// <summary>
        /// The creation of a new game.
        /// </summary>
        public static void NewGame()
        {
            GameModel g = new GameModel(MenuHandling.GameName(), MenuHandling.GameWinningScore()); // Create new game.

            Program.ActiveGame = g;                                                                // Set the game as active game.

            // Time to add players to the game.
            var addPlayer = true;

            do
            {
                PlayerModel p = new PlayerModel(MenuHandling.PlayerName(), MenuHandling.PlayerSkill(), MenuHandling.PlayerHuman());
                g.AddPlayer(p);

                // String to print human or computer depending on bool human.
                string type;
                if (p.Human)
                {
                    type = "HUMAN";
                }
                else
                {
                    type = "COMPUTER";
                }

                // Confirmation of new player
                Graphics.Header();
                Graphics.PrintInBlue(true, $" Added {type} controlled player {p.Name} with a skill level of {p.SkillLevel}.");
                Console.WriteLine();
                Graphics.PrintInGreen(true, " Add another player? y/n"); // Do the user want to add another player?

                // Check if user wants to add another player
                var keyPressed = Console.ReadKey();

                // If user presses Y, loop condition is not changed and loop goes around again.
                if (keyPressed.Key == ConsoleKey.Y)
                {
                    continue;
                }
                else
                {
                    addPlayer = false;  // The user do not want another player, break out of loop and continue.
                }
            } while (addPlayer);

            // Print all added players.
            Graphics.Header();
            Graphics.PrintInGreen(true, " Players added to this game: ");
            foreach (var player in g.PlayerList)
            {
                Console.WriteLine(player.ToString());
            }
            Console.WriteLine();
            Graphics.PrintInGreen(true, " To start the game press enter. ");
            Console.ReadLine();

            // Time to play!!! -------------------------------------------------------------------------
            Game(g);
        }
Exemple #3
0
        }                                                // Keeps track of the game.

        static void Main(string[] args)
        {
            MenuHandling.MainMenu(); // Start with main menu.
        }