Ejemplo n.º 1
0
        static void Main(string[] args)
        {

            int numberOfPlayers;

            NumberOfPlayers numberofplayers = new NumberOfPlayers();
            Player1 player1 = new Player1();
            Player2 player2 = new Player2();
            PlayerChooseSign signChoice = new PlayerChooseSign();
            CheckPlayerWin checkplayerwin = new CheckPlayerWin();
            UserPickNumberOfPlayers userpicknumberofplayers = new UserPickNumberOfPlayers();
            UserPickHandSign userpickhandsign = new UserPickHandSign();
            DisplayResults displayresults = new DisplayResults();
            WriteToDocument writetodocument = new WriteToDocument();
            ReadFromDocument readfromdocument = new ReadFromDocument();

            readfromdocument.writeDocumentContent();

            numberOfPlayers = userpicknumberofplayers.pickNumberOfPlayers(player1, player2, numberofplayers);

            userpickhandsign.pickHandSign(numberOfPlayers, checkplayerwin, signChoice, player1, player2);
           
            checkplayerwin.getResult();

            displayresults.DisplayWinner(player1, player2, checkplayerwin);

            checkplayerwin.SignClassOutput();

            writetodocument.writeTextToDocument(player1, player2);
        }
Ejemplo n.º 2
0
 public void DisplayWinner(Player1 player1, Player2 player2, CheckPlayerWin checkplayerwin)
 {
     switch (checkplayerwin.outcome)
     {
         case 0:
             Console.WriteLine("You have tied by throwing the same hand sign!");
             break;
         case 1:
             Console.WriteLine(player1.Player1Name + " has won!");
             player1.Winstreak++;
             player2.Winstreak = 0;
             break;
         case 2:
             Console.WriteLine(player2.Player2Name + " has won!");
             player2.Winstreak++;
             player1.Winstreak = 0;
             break;
         case 3:
             Console.WriteLine(player1.Player1Name + " has won!");
             player1.Winstreak++;
             player2.Winstreak = 0;
             break;
         case 4:
             Console.WriteLine(player2.Player2Name + " has won!");
             player2.Winstreak++;
             player1.Winstreak = 0;
             break;
     }
 }
        public int pickNumberOfPlayers (Player1 player1, Player2 player2, NumberOfPlayers numberofplayers)
            {
            int numberOfPlayers;
                bool userHasPickedValidPlayerNumber = false;
                numberOfPlayers = numberofplayers.getNumberOfPlayers();

                while (userHasPickedValidPlayerNumber == false)
                {
                switch (numberOfPlayers)
                {
                    case 2:
                        userHasPickedValidPlayerNumber = true;
                        player1.getPlayer1name();
                        player2.getPlayer2name();
                        break;
                    case 1:
                        userHasPickedValidPlayerNumber = true;
                        player1.getPlayer1name();
                        player2.Player2Name = "AI Andrew";
                        break;
                    default:
                        numberOfPlayers = numberofplayers.getNumberOfPlayers();
                        break;
                }
            }
            return numberOfPlayers;
            }
Ejemplo n.º 4
0
 public void pickHandSign(int numberOfPlayers, CheckPlayerWin checkplayerwin,PlayerChooseSign signChoice, Player1 player1, Player2 player2) {
     switch (numberOfPlayers)
     {
         case 1:
             checkplayerwin.player1sign = signChoice.getPlayerHandsign();
             checkplayerwin.player2sign = rnd.Next(5);
             break;
         case 2:
             Console.WriteLine(player1.Player1Name + " it's your turn!");
             checkplayerwin.player1sign = signChoice.getPlayerHandsign();
             Console.Clear();
             Console.WriteLine(player2.Player2Name + " it's your turn!");
             checkplayerwin.player2sign = signChoice.getPlayerHandsign();
             Console.Clear();
             break;
     }
 }
Ejemplo n.º 5
0
        public void writeTextToDocument(Player1 player1, Player2 player2)
        {
            string[] playernames = { player1.Player1Name, player2.Player2Name };

            System.IO.File.WriteAllLines(@"C:\Users\Robert\Documents\devcodecamp\RockPaperScissors\RPSplayers.txt", playernames);
        }
Ejemplo n.º 6
0
 public void SetChoiceForPlayer2(Choice choice)
 {
     Player2.SetChoice(choice);
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var john = new Player1(0);
            var dana = new Player2(0);
            var josie = new Player3(0);
            var theGame = new Game();

            for(int i = 0; i < 100; i++)
            {
                var rnd = new Random();
                int value = rnd.Next(7);

                switch (value)
                {
                    case 1:
                        Console.WriteLine("Round " + i + " " + john.Act() + " VS " + dana.Act() + "  -----> WINNER: " + (theGame.Fight(john, dana)).Act());
                        break;
                    case 2:
                        Console.WriteLine("Round " + i + " " + john.Act() + " VS " + josie.Act() + "  -----> WINNER: " + (theGame.Fight(john, josie)).Act());
                        break;
                    default:
                        Console.WriteLine("Round " + i + " " + dana.Act() + " VS " + josie.Act() + "  -----> WINNER: " + (theGame.Fight(dana, josie)).Act());
                        break;
                }

            }

            Console.WriteLine("Rock Number of Wins = " + john.NumOfWins);
            int rockWins = john.NumOfWins;
            Console.WriteLine("Paper Number of Wins = " + dana.NumOfWins);
            int paperWins = dana.NumOfWins;
            Console.WriteLine("Scissors Number of Wins = " + josie.NumOfWins);
            int scissorsWins = josie.NumOfWins;

            if(rockWins > paperWins && rockWins > scissorsWins)
            {
                Console.WriteLine("Rock Wins with total of: " + john.NumOfWins);
            }
            else if (paperWins > rockWins && paperWins > scissorsWins)
            {
                Console.WriteLine("Paper Wins with total of: " + dana.NumOfWins);
            }
            else
            {
                Console.WriteLine("Scissors Wins with total of: " + josie.NumOfWins);
            }

            Console.Read();
        }
Ejemplo n.º 8
0
        public void RunApp()
        {
            Console.WriteLine("Enter your name");
            string name = Console.ReadLine();

            Console.WriteLine("Would you like to play against player 1 or player 2(enter 1 for player 1, 2 for player 2): ");
            int userChoice;

            userChoice = IsValidIntEntered(Console.ReadLine());
            char loopBreaker;
            int  userPlayerWins = 0;
            int  compPlayerWins = 0;


            do
            {
                if (userChoice == 1)
                {
                    Console.WriteLine("Rock, Paper, Scissors: (1 = rock, 2 = paper, 3 = scissors)");
                    string     choice     = Console.ReadLine();
                    UserPlayer user       = new UserPlayer(name, choice);
                    Player1    compPlayer = new Player1();

                    if (user.RoshamboValue == Roshambo.rock)
                    {
                        Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                        Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");

                        Console.WriteLine("Neither player wins draw");
                    }
                    else if (user.RoshamboValue == Roshambo.paper)
                    {
                        Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                        Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                        Console.WriteLine($"{user.Name} wins");
                        userPlayerWins++;
                    }
                    else
                    {
                        Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                        Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                        Console.WriteLine($"{compPlayer.Name} wins");
                        compPlayerWins++;
                    }

                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Rock, Paper, Scissors: (1 = rock, 2 = paper, 3 = scissors)");
                    string     choice       = Console.ReadLine();
                    UserPlayer user         = new UserPlayer(name, choice);
                    Player2    compPlayer   = new Player2();
                    Player3    playerResult = new Player3();
                    compPlayer.RoshamboValue = playerResult.RoshamboChoice(compPlayer);
                    if (user.RoshamboValue == Roshambo.rock)
                    {
                        if (compPlayer.RoshamboValue == Roshambo.rock)
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine("Its a tie!");
                        }
                        else if (compPlayer.RoshamboValue == Roshambo.paper)
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine("Player 2 wins!");
                            compPlayerWins++;
                        }
                        else
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine($"{user.Name} wins!");
                            userPlayerWins++;
                        }
                    }
                    else if (user.RoshamboValue == Roshambo.paper)
                    {
                        if (compPlayer.RoshamboValue == Roshambo.rock)
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine($"{user.Name} wins!");
                            userPlayerWins++;
                        }
                        else if (compPlayer.RoshamboValue == Roshambo.paper)
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine("Its a tie!");
                        }
                        else
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine("Player 2 wins!");
                            compPlayerWins++;
                        }
                    }
                    else
                    {
                        if (compPlayer.RoshamboValue == Roshambo.rock)
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine("Player 2 wins!");
                            compPlayerWins++;
                        }
                        else if (compPlayer.RoshamboValue == Roshambo.paper)
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine($"{user.Name} wins!");
                            userPlayerWins++;
                        }
                        else
                        {
                            Console.WriteLine($"{user.Name}: {user.RoshamboValue}");
                            Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}");
                            Console.WriteLine("Its a tie!");
                        }
                    }
                }
                Console.WriteLine("Do you wish to continue(enter y/n): "); //ask user to if they want to continue
                loopBreaker = IsValidLoopBreaker(Console.ReadLine());      //storing answer and if it's valid input
                Console.ReadLine();
            } while (loopBreaker == 'y');

            Console.WriteLine($"{name} won {userPlayerWins} games");
            Console.WriteLine($"{name} lost {compPlayerWins} games");
        }
Ejemplo n.º 9
0
 public abstract Roshambo RoshamboChoice(Player2 Player);