Beispiel #1
0
        public static void RunRockPaperScissors(int count, PlayerUser user)
        {
            List <Player> opponents = new List <Player>
            {
                new PlayerRock(),
                new PlayerRandom(),
            };
            int opponentIndex = Validator.ChooseOpponent("Choose your opponent: ", opponents);

            user.Roshambo = user.GenerateRoshambo();
            Methods.PrintRoshambo(opponentIndex, opponents, user);
            Methods.CompareRoshambo(opponents, user, opponentIndex);
            Console.WriteLine($"You have played {count} game of Rock Paper Scissors!");
            Console.WriteLine($"You have:\n{user.Wins} Wins\n{user.Losses} Losses\n{user.Ties} Ties");
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            PlayerUser user = new PlayerUser();

            Console.WriteLine("Welcome to Rock Paper Scissors!\n");
            string name = Validator.GetName("What is your name? ");

            user.Name = name;
            int count = 0;

            bool playAgain = true;

            while (playAgain)
            {
                count++;
                RoshamboApp.RunRockPaperScissors(count, user);
                playAgain = Validator.PlayAgain("Would you like to play again? yes or no");
            }
        }
Beispiel #3
0
 public static void CompareRoshambo(List <Player> list, PlayerUser user, int opponentIndex)
 {
     Console.WriteLine("");
     if (list[opponentIndex].Roshambo == user.Roshambo)
     {
         Console.WriteLine("Draw!");
         user.Ties++;
     }
     else if (list[opponentIndex].Roshambo == Roshambo.rock && user.Roshambo == Roshambo.paper)  //rock 0 paper 1
     {
         Console.WriteLine($"{user.Name} wins!");
         user.Wins++;
     }
     else if (list[opponentIndex].Roshambo == Roshambo.rock && user.Roshambo == Roshambo.scissors) //rock 0 scissors 2
     {
         Console.WriteLine($"{list[opponentIndex].Name} wins!");
         user.Losses++;
     }
     else if (list[opponentIndex].Roshambo == Roshambo.paper && user.Roshambo == Roshambo.rock) //paper 1 rock 0
     {
         Console.WriteLine($"{list[opponentIndex].Roshambo} wins!");
         user.Losses++;
     }
     else if (list[opponentIndex].Roshambo == Roshambo.paper && user.Roshambo == Roshambo.scissors) //paper 1 scissors 2
     {
         Console.WriteLine($"{user.Name} wins!");
         user.Wins++;
     }
     else if (list[opponentIndex].Roshambo == Roshambo.scissors && user.Roshambo == Roshambo.rock)//scissors 2 rock 0
     {
         Console.WriteLine($"{user.Name} wins!");
         user.Wins++;
     }
     else if (list[opponentIndex].Roshambo == Roshambo.scissors && user.Roshambo == Roshambo.paper) //scissors 2 paper 1
     {
         Console.WriteLine($"{list[opponentIndex].Name} wins!");
         user.Losses++;
     }
     Console.WriteLine("");
 }
Beispiel #4
0
 public static void PrintRoshambo(int opponentIndex, List <Player> list1, PlayerUser user)
 {
     Console.WriteLine($"{list1[opponentIndex].Name}: {Enum.GetName(typeof(Roshambo),(list1[opponentIndex].Roshambo))}");
     Console.WriteLine($"{user.Name}: {Enum.GetName(typeof(Roshambo), (user.Roshambo))}");
 }