static void CreatePlayers()
        {
            //========================================================== Creates players
            Classes.Player playerOne = new Classes.Player();
            Classes.Player playerTwo = new Classes.Player();


            Console.WriteLine("Enter a player name");
            string input = Console.ReadLine();

            playerOne.Name   = input;
            playerOne.IsTurn = true;
            playerOne.Marker = "X";

            Console.WriteLine("Enter another player name");
            string input2 = Console.ReadLine();

            playerTwo.Name   = input2;
            playerTwo.IsTurn = false;
            playerTwo.Marker = "0";

            Classes.Game currentGame = new Classes.Game(playerOne, playerTwo);

            playerArray[0] = playerOne;
            playerArray[1] = playerTwo;

            Console.WriteLine($"Your players are: {playerOne.Name}, {playerTwo.Name}");
        }
Exemple #2
0
        /// <summary>
        /// This method plays the game.
        /// </summary>
        static void PlayGame()
        {
            // DONE: Setup your game here. Create an introduction.
            // Create your players, and instantiate your Game class.
            // output to the console the winner

            Console.WriteLine("Player One Enter A Name");
            string playerOneName = Console.ReadLine();

            Console.WriteLine("Player Two Enter A Name");
            string playerTwoName = Console.ReadLine();

            Classes.Player playerOne = new Classes.Player();
            playerOne.Marker = "X";
            playerOne.Name   = playerOneName;
            playerOne.IsTurn = true;

            Classes.Player playerTwo = new Classes.Player();
            playerTwo.Marker = "O";
            playerTwo.Name   = playerTwoName;
            playerTwo.IsTurn = false;

            Classes.Game theGame = new Classes.Game(playerOne, playerTwo);

            Classes.Player winner = theGame.Play();

            Console.WriteLine($"{winner.Name} is the winner!");
        }
        static void StartGame()
        {
            Classes.Game newGame = new Classes.Game(playerArray[0], playerArray[1]);
            newGame.Play();

            // TODO: Setup your game. Create a new method that creates your players and instantiates the game class. Call that method in your Main method.
            // You are requesting a Winner to be returned, Determine who the winner is output the celebratory message to the correct player. If it's a draw, tell them that there is no winner.
        }
        static void PlayGame()
        {
            do
            {
                Console.Clear();
                Console.WriteLine("Let's Play Tic-Tac-Toe");
                Console.WriteLine("Player 1: What is your name?");
                Classes.Player playerOne = new Classes.Player()
                {
                    Name   = Console.ReadLine(),
                    IsTurn = true,
                    Marker = "X"
                };

                Console.WriteLine("Player 2: What is your name?");
                Classes.Player playerTwo = new Classes.Player()
                {
                    Name   = Console.ReadLine(),
                    IsTurn = true,
                    Marker = "O"
                };

                Classes.Game   game   = new Classes.Game(playerOne, playerTwo);
                Classes.Player winner = game.Play();

                if (winner is null)
                {
                    Console.WriteLine("Draw!!");
                }
                else
                {
                    Console.WriteLine($"{winner.Name} is the winner!?!");
                }

                Console.WriteLine("Play Again?");
                Console.WriteLine("Enter yes to play again, anything else will exit.");
            } while (Console.ReadLine().ToLower() == "yes");
        }
Exemple #5
0
        /// <summary>
        ///     Greeting, player/game setup, play initiation, and win report.
        /// </summary>
        static void PlayGame()
        {
            //////////////////
            Console.ForegroundColor = ConsoleColor.Gray;
            string appName    = "TickTackToe";
            string appVersion = "1.0.0";
            string appAuthor  = "Jason Burns";


            Console.ForegroundColor = ConsoleColor.White;
            string title = @"
 _______ _____ _____   _______       _____   _______ ____  ______ 
|__   __|_   _/ ____| |__   __|/\   / ____| |__   __/ __ \|  ____|
   | |    | || |         | |  /  \ | |         | | | |  | | |__   
   | |    | || |         | | / /\ \| |         | | | |  | |  __|  
   | |   _| || |____     | |/ ____ \ |____     | | | |__| | |____ 
   |_|  |_____\_____|    |_/_/    \_\_____|    |_|  \____/|______|
                ";

            int color = 0;

            for (int i = 0; i < 7; i++)
            {
                if (color == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (color == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                }
                if (color == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                if (color == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (color == 4)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                }
                if (color == 5)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                Console.WriteLine("{0}: Version {1} by {2}", appName, appVersion, appAuthor);
                Console.Write(title);
                color++;
                Thread.Sleep(400);
                Console.Clear();
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();

            Console.WriteLine("Player one enter name: ");
            string p1 = Console.ReadLine();

            Classes.Player player1 = new Classes.Player
            {
                Name   = p1,
                Marker = "X",
                IsTurn = true
            };

            Console.WriteLine("Player one enter name: ");
            string p2 = Console.ReadLine();

            Classes.Player player2 = new Classes.Player
            {
                Name   = p2,
                Marker = "O",
                IsTurn = false
            };

            Console.Clear();
            Console.WriteLine("FIGHT!");

            Classes.Game game = new Classes.Game(player1, player2);

            Classes.Player winner = game.Play();

            if (!(winner is null))
            {
                Console.WriteLine($"{winner.Name} wins!");
            }