public static void revealWinner(Game game) { var winner = game.getWinner(); if (winner == 1) Console.WriteLine (game.playerOne.name + " wins!"); else if (winner == 2) Console.WriteLine (game.playerTwo.name + " wins!"); else Console.WriteLine ("It's a draw!"); }
static void Main(string[] args) { Console.WriteLine("Rock, Paper, Scissors..."); Game newGame = new Game(); string input = ""; Player p1 = new HumanPlayer("Player 1"); Player p2 = new ComputerPlayer("Player 2"); do { newGame.PlayRound(p1, p2); Console.WriteLine("Press Enter to play again or (Q) to quit."); input = Console.ReadLine(); } while (input.ToUpper() != "Q"); }
static void Main(string[] args) { Console.WriteLine("Welcome to Rock, Paper, Scissors Extended!"); var game = new Game(); game.CreatePlayers(); game.Play(); Console.ReadLine(); }
public static void startComputerGame() { var computerPlayerOne = new Player ("COMPUTER REGGIE"); var computerPlayerTwo = new Player ("COMPUTER BERNARD"); var game = new Game (computerPlayerOne, computerPlayerTwo); game.playerOne.throwGesture(); playerTurn (game.playerOne); playerTurn (game.playerTwo); revealWinner (game); playAgain (); }
public static void startOnePlayerGame() { Console.WriteLine ("Enter your name:"); var player = new Player (Console.ReadLine ()); var computerPlayer = new Player (); var game = new Game (player, computerPlayer); Console.WriteLine ("Choose rock, paper or scissors"); game.playerOne.throwGesture(Console.ReadLine ()); Console.WriteLine (game.playerOne.name + " chooses " + game.playerOne.gesture); playerTurn (game.playerTwo); revealWinner (game); playAgain (); }
public static void Main(string[] args) { Game game = new Game(); string type = game.startGame.start(); bool tie = false; while (!tie) { if (type == "1") { string humanResult = game.humanInput.humanChoice(); string aiResult = game.aiInput.getCompChoice(); tie = game.winCheck.winCheckerAI(humanResult, aiResult); string outcome = game.results.resultCheckAI(humanResult, aiResult); game.write.writeTextToDocument(outcome); game.read.readTextFromDocument(); } else if (type == "2") { string humanResult = game.humanInput.humanChoice(); Console.Clear(); string humanResultTwo = game.humanInputTwo.humanChoiceTwo(); tie = game.winCheck.winCheckerH2H(humanResult, humanResultTwo); string outcome = game.results.resultCheckH2H(humanResult, humanResultTwo); game.write.writeTextToDocument(outcome); game.read.readTextFromDocument(); } else if (type == "3") { game.startGame.start(); } } }
static void Main(string[] args) { Console.WriteLine("Rock, Paper, Scissors..."); Game newGame = new Game(); string input = ""; Player p1 = new ComputerPlayer("Player 1"); Player p2 = new ComputerPlayer("Player 2"); do { newGame.PlayRound(p1,p2); Console.WriteLine("Would you like to play again? (enter \"Q\" to Quit)"); input = Console.ReadLine(); } while (input.ToUpper() != "Q"); }
public static void PlayGames(int numOfRounds) { Random choice = new Random(); Game newGame = new Game(); Player playerOne; Player playerTwo; //Console.WriteLine(newGame.TheFight(playerOne, playerTwo)); //Console.WriteLine("Player {0} uses {1}", playerOne.PlayerNum, playerOne.Act()); //Console.WriteLine("Player {0} uses {1}", playerTwo.PlayerNum, playerTwo.Act()); int playerOneWins = 0; int playerTwoWins = 0; int ties = 0; string result; int rounds = numOfRounds; for (var i = 0; i < rounds; i++) { playerOne = new Player(1, choice.Next(3)); playerTwo = new Player(2, choice.Next(3)); result = newGame.TheFight(playerOne, playerTwo); if (result[7] == '1') { playerOneWins++; } else if (result[7] == '2') { playerTwoWins++; } else { ties++; } } Console.WriteLine("Ties {0}", ties); Console.WriteLine("Player One Wins {0}", playerOneWins); Console.WriteLine("Player Two Wins {0}", playerTwoWins); Console.WriteLine("/////////////////////"); if (ties > playerOneWins && ties > playerTwoWins) { Console.WriteLine("The Ties have it."); } else if (playerOneWins > playerTwoWins) { Console.WriteLine("Player One Wins with " + playerOneWins + " rounds!"); } else { Console.WriteLine("Player Two Wins with " + playerTwoWins + " rounds!"); } }
public void TestPaperMethod(Choice choice, Result expected) { MatchResult result = null; Game testGame = new Game(); switch (choice) { case Choice.Paper: result = testGame.PlayRound(new AlwaysPaper(), new AlwaysPaper()); break; case Choice.Rock: result = testGame.PlayRound(new AlwaysPaper(), new AlwaysRock()); break; default: result = testGame.PlayRound(new AlwaysPaper(), new AlwaysScissors()); break; } Assert.AreEqual(expected, result.Match_Result); }
public HomeModule() { Get["/"] = _ => View ["index.cshtml"]; Post["/"] = _ => { string player1 = Game.GetPlayer1(); string player2; if (Request.Form["player2"] == "Random") { player2 = Game.GetAI(); } else { player2 = Request.Form["player2"]; } Game newGame = new Game(player1, player2); return View["index.cshtml", newGame.ReturnWinner()]; }; Post["/player2"] = _ => { Game newGame = new Game(Request.Form["player1"], ""); return View["player2.cshtml"]; }; }
public void ReturnWinner_RockVsPaper_true() { Game newGame = new Game("Rock","Paper"); Assert.Equal("Player 2", newGame.ReturnWinner()); }
public void ReturnWinner_PaperVsScissors_true() { Game newGame = new Game("Paper","Scissors"); Assert.Equal("Player 2", newGame.ReturnWinner()); }
public void ReturnWinner_PaperVsRock_true() { Game newGame = new Game("Paper","Rock"); Assert.Equal("Player 1", newGame.ReturnWinner()); }
public void ReturnWinner_PaperVsPaper_true() { Game newGame = new Game("Paper","Paper"); Assert.Equal("Draw", newGame.ReturnWinner()); }
public void TestRockPaperScissorReturnWinner() { Game newGame = new Game("Rock","Scissors"); Assert.Equal("Player 1", newGame.ReturnWinner()); }
public void ReturnWinner_ScissorsVsRock_true() { Game newGame = new Game("Scissors","Rock"); Assert.Equal("Player 2", newGame.ReturnWinner()); }
private void SinglePlayerGame() { PlayerOneMenu(); AiPlayer(); onePlayerGame = CreateGame(playerOne, playerTwoAI); onePlayerGame.PlayGame(); GameOverMenu(); }
public void BeforeEachTest() { _game = new Game(); }
private void TwoPlayerGame() { PlayerOneMenu(); PlayerTwoMenu(); twoPlayerGame = CreateGame(playerOne, playerTwo); twoPlayerGame.PlayGame(); GameOverMenu(); }
private Game CreateGame(Player one, Player two) { Game newGame = new Game(one, two); return newGame; }
public void ReturnWinner_RockVsRock_true() { Game newGame = new Game("Rock","Rock"); Assert.Equal("Draw", newGame.ReturnWinner()); }
public void ReturnWinner_ScissorsVsPaper_true() { Game newGame = new Game("Scissors","Paper"); Assert.Equal("Player 1", newGame.ReturnWinner()); }
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(); }
public void ReturnWinner_ScissorsVsScissors_true() { Game newGame = new Game("Scissors","Scissors"); Assert.Equal("Draw", newGame.ReturnWinner()); }
static void Main(string[] args) { var game = new Game(); var scissors = new PlayerScissors().Act(); var rock = new PlayerRock().Act(); var paper = new PlayerPaper().Act(); var gameArray = new string[] { scissors, rock, paper }; var rnd = new Random(); //Random is a class, not method //var x = rnd.Next(gameArray.Length); //var x2 = gameArray[x]; //Thread.Sleep(3000); //var y = rnd.Next(gameArray.Length); //var y2 = gameArray[y]; var counterOne = 0; var counterTwo = 0; var counterTie = 0; for (int i = 0; i < 100; i++) { var x = rnd.Next(gameArray.Length); var x2 = gameArray[x]; var y = rnd.Next(gameArray.Length); var y2 = gameArray[y]; game.Fight(x2, y2); if (game.Fight(x2, y2) == "Player1") { counterOne++; } else if(game.Fight(x2, y2) == "Player2"){ counterTwo++; } else { counterTie++; } } Debug.Assert(game.Fight(scissors, paper) == "Player1"); Debug.Assert(game.Fight(rock, scissors) == "Player1"); Debug.Assert(game.Fight(paper, scissors) == "Player2"); if (counterOne > counterTwo) { Console.WriteLine("Player One won " + counterOne + " times! They win!"); Console.WriteLine("Player Two won " + counterTwo + " times! They lose."); Console.WriteLine("There were " + counterTie + " ties."); } else { Console.WriteLine("Player Two won " + counterTwo + " times! They win!"); Console.WriteLine("Player One won " + counterOne + " times! They lose."); Console.WriteLine("There were " + counterTie + " ties."); } Console.ReadLine(); }
public FileWriter(Game game) { playerOne = game.PlayerOne; playerTwo = game.PlayerTwo; }
private static void Main(string[] args) { int _playerType1; int _playerType2; string _name1; string _name2; string numberOfPlayers = ""; Console.WriteLine("Welcome to Rock, Paper, Scissors...(Lizard, Spock)\n"); Game newGame = new Game(); string input = ""; string gameChoice = ""; do { Console.WriteLine("Which version do you want to play? (1) Rock, Paper, Scissors or (2) Rock, Paper, Scissors, Lizard, Spock. Enter 1 or 2."); gameChoice = Console.ReadLine(); if (gameChoice != "1" && gameChoice != "2") { Console.WriteLine("That is not a valid choice."); } } while (gameChoice != "1" && gameChoice != "2"); if (gameChoice == "1") { Console.Clear(); Console.WriteLine("OK. We will play the regular version of Rock, Paper, Scissors."); Console.WriteLine(); do { Console.WriteLine( "Do you want to play (1) against the computer or (2) against another human player? Enter 1 or 2."); numberOfPlayers = Console.ReadLine(); if (numberOfPlayers != "1" && numberOfPlayers != "2") { Console.WriteLine("That is not a valid choice."); } } while (numberOfPlayers != "1" && numberOfPlayers != "2"); if (numberOfPlayers == "1") { _playerType1 = 1; _playerType2 = 2; } else { _playerType1 = 1; _playerType2 = 1; } _name1 = PlayerNamer(1); _name2 = PlayerNamer(2); Console.Clear(); do { newGame.PlayRound(PlayerCreator(_playerType1, _name1), PlayerCreator(_playerType2, _name2)); Console.WriteLine("\nWould you like to play again? (enter \"Q\" to Quit):"); input = Console.ReadLine(); } while (input.ToUpper() != "Q"); } else //Run Rock, Paper, Scissors, Lizard, Spock { Console.Clear(); Console.WriteLine("OK. We will play Rock, Paper, Scissors, Lizard, Spock ( ͡° ͜ʖ ͡°)"); Console.WriteLine(); do { Console.WriteLine( "Do you want to play (1) against the computer or (2) against another human player/spock? Enter 1 or 2."); numberOfPlayers = Console.ReadLine(); if (numberOfPlayers != "1" && numberOfPlayers != "2") { Console.WriteLine("That is not a valid choice."); } } while (numberOfPlayers != "1" && numberOfPlayers != "2"); if (numberOfPlayers == "1") { _playerType1 = 3; _playerType2 = 4; } else { _playerType1 = 3; _playerType2 = 3; } _name1 = PlayerNamer(1); _name2 = PlayerNamer(2); Console.Clear(); do { newGame.PlayLizardSpock(PlayerCreator(_playerType1, _name1), PlayerCreator(_playerType2, _name2)); Console.WriteLine("\nWould you like to play again? (enter \"Q\" to Quit):"); input = Console.ReadLine(); } while (input.ToUpper() != "Q"); ////IComparables version of the Game //do //{ // //newGame.PlayLizardSpockICom(new HumanPlayerICom("Player 1"), new ComputerPlayerICom("Computa Playa 2")); // Console.Write("Would you like to play again? (enter \"Q\" to Quit): "); // input = Console.ReadLine(); //} while (input.ToUpper() != "Q"); } }