Beispiel #1
0
        static void Main(string[] args)
        {
            UserPlayer user = new UserPlayer();

            Prompts.SayHello();
            Prompts.GetUserName(user);

            bool whichOppenent = RoshamboApp.AskForOppenent();

            if (whichOppenent == true)
            {
                MatchupVsOpponent1.DecideWinner(user);
            }


            else
            {
                MatchupVsOppenent2.DecideWinner(user);
            }
        }
        public static void DecideWinner(UserPlayer user)
        {
            int userWinTally     = 0;
            int computerWinTally = 0;

            bool loop = true;

            while (loop)
            {
                //Rock - 1, Paper - 2, Scissors - 3

                Opponent2 opponent2 = new Opponent2("");         //Opponent 1 Instance

                int result  = (int)user.GenerateRoshambo();      //Returns User's Enum, and casts into an interger
                int result2 = (int)opponent2.GenerateRoshambo(); //Returns Opponent's 1 Enum (Rock), and casts into an interger

                #region RPS Outcomes

                if (result == 1 && result2 == 2)
                {
                    Console.Clear();
                    Console.WriteLine("\tPaper covers rock");
                    Console.WriteLine("\t" + opponent2.Name + " beats " + user.Name);
                    computerWinTally++;
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 1 && result2 == 3)
                {
                    Console.Clear();
                    Console.WriteLine("\tRock beats scissors");
                    Console.WriteLine("\t" + user.Name + " beats " + opponent2.Name);
                    userWinTally++;
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }
                else if (result == 1 && result2 == 1)
                {
                    Console.Clear();
                    Console.WriteLine("\tDraw");
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 2 && result2 == 1)
                {
                    Console.Clear();
                    Console.WriteLine("\tPaper covers rock");
                    Console.WriteLine("\t" + user.Name + " beats " + opponent2.Name);
                    userWinTally++;
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 2 && result2 == 2)
                {
                    Console.Clear();
                    Console.WriteLine("\tDraw");
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 2 && result2 == 3)
                {
                    Console.Clear();
                    Console.WriteLine("\tScissors cuts paper");
                    Console.WriteLine("\t" + opponent2.Name + " beats " + user.Name);
                    computerWinTally++;
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 3 && result2 == 1)
                {
                    Console.Clear();
                    Console.WriteLine("\tRock beats scissors");
                    Console.WriteLine("\t" + opponent2.Name + " beats " + user.Name);
                    computerWinTally++;
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 3 && result2 == 2)
                {
                    Console.Clear();
                    Console.WriteLine("\tScissors cuts paper");
                    Console.WriteLine("\t" + user.Name + " beats " + opponent2.Name);
                    userWinTally++;
                    Console.WriteLine("\tYou are " + userWinTally + " and " + computerWinTally + " against " + opponent2.Name);
                }

                else if (result == 3 && result2 == 3)
                {
                    Console.Clear();
                    Console.WriteLine("\tDraw");
                }
                #endregion

                bool playAgain = Prompts.AskToPlayAgain();
                if (playAgain == true)
                {
                    loop = true;
                }

                else
                {
                    Console.WriteLine("Have a good day!");
                    System.Environment.Exit(1);
                }
            }
        }