예제 #1
0
        public void DecideWhoGoesFirst()
        {
            Console.WriteLine("\nNow let's flip a coin to see who goes first!");

            string inputStr;

            do
            {
                Console.Write("Would you like heads or tails? (h/t)  ");
                inputStr = Console.ReadLine().ToLower();
            } while (inputStr != "h" && inputStr != "t");


            //Add pause for suspense
            Console.Write("Coin flip");
            for (int i = 0; i < 4; i++)
            {
                System.Threading.Thread.Sleep(500);
                Console.Write(" . ");
            }

            if (new Random().Next(2) == 0)
            {
                Console.WriteLine(" --> HEADS");
                if (inputStr == "h")
                {
                    this.userGoesFirst = true;
                }
                if (inputStr == "t")
                {
                    this.userGoesFirst = false;
                }
            }
            else
            {
                Console.WriteLine(" --> TAILS");
                if (inputStr == "h")
                {
                    this.userGoesFirst = false;
                }
                if (inputStr == "t")
                {
                    this.userGoesFirst = true;
                }
            }

            logic.SetUserGoesFirst(this.userGoesFirst);

            if (this.userGoesFirst)
            {
                Console.WriteLine("You will go first.");
            }
            if (!this.userGoesFirst)
            {
                Console.WriteLine("Computer will go first");
            }

            Console.WriteLine("\nType [ENTER] to start the game.");
            Console.ReadLine();
            Console.WriteLine("\n \n------------ GAME BEGIN -----------");
            if (!userGoesFirst)
            {
                ComputerMove();
            }
        }