Esempio n. 1
0
    public void WinCondition(string input1, string input2, string expected)
    {
        var    game   = new RockPaperScissors();
        string result = game.winCondition(input1, input2);

        Assert.That(result, Is.EqualTo(expected));
    }
Esempio n. 2
0
    public void ValidEntry(string input, bool expected)
    {
        var  game   = new RockPaperScissors();
        bool result = game.validEntry(input);

        Assert.That(result, Is.EqualTo(expected));
    }
Esempio n. 3
0
    private void Awake()
    {
        var parameter = new GameParameter();

        parameter.Players = new GameParameter.Player[]
        {
            new GameParameter.Player()
            {
                IsEnemy = false,
                Brain   = new Task1.Solution()
            },
            new GameParameter.Player()
            {
                IsEnemy = true,
                Brain   = new EnemyBrain()
            },
        };

        _proceedTurnButton.onClick.AddListener(() =>
        {
            var game = new RockPaperScissors(parameter);
            if (!game.CheckFinished())
            {
                game.ProceedTurn();
                var environment = game.GetCurrentEnvironment();

                var builder = new StringBuilder();
                builder.AppendLine($"ゲーム結果: {(game.IsWon ? "勝ち" : "負け")}");
                builder.AppendLine($"自分の手: {GetJapaneseHandName(environment.Players[0].Hand)}");
                builder.AppendLine($"相手の手: {GetJapaneseHandName(environment.Players[1].Hand)}");

                _gameLogText.text = builder.ToString();
            }
        });
    }
Esempio n. 4
0
        public void T09PPaperCPaper()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("paper");
            rps.cpuChoice = "paper";
            Assert.True(rps.GetResult() == "tie");
        }
Esempio n. 5
0
 private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     engine = new RockPaperScissors();
     engine.numberOfPlayers = initialNumberOfPlayers;
     engine.InitializePlayers(engine.numberOfPlayers - 1);
     roundNumber = 0;
     console.Clear();
 }
Esempio n. 6
0
        public void T07PRockCPaper()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("rock");
            rps.cpuChoice = "paper";
            Assert.True(rps.GetResult() == "lose");
        }
Esempio n. 7
0
        public void T08PPaperCRock()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("paper");
            rps.cpuChoice = "rock";
            Assert.True(rps.GetResult() == "win");
        }
Esempio n. 8
0
        public void T05PRockCScissors()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("rock");
            rps.cpuChoice = "scissors";
            Assert.True(rps.GetResult() == "win");
        }
Esempio n. 9
0
        public void T06PRockCRock()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("rock");
            rps.cpuChoice = "rock";
            Assert.True(rps.GetResult() == "tie");
        }
Esempio n. 10
0
        public void T12ScissorsCPaper()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("scissors");
            rps.cpuChoice = "paper";
            Assert.True(rps.GetResult() == "win");
        }
Esempio n. 11
0
        public void T13PScissorsCScissors()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("scissors");
            rps.cpuChoice = "scissors";
            Assert.True(rps.GetResult() == "tie");
        }
Esempio n. 12
0
        public void SetUp()
        {
            gameRound = new GameRound();
            game      = new RockPaperScissors(gameRound);

            player1 = Substitute.For <IPlayer>();
            player2 = Substitute.For <IPlayer>();
        }
Esempio n. 13
0
        public void T11PScissorsCRock()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("scissors");
            rps.cpuChoice = "rock";
            Assert.True(rps.GetResult() == "lose");
        }
Esempio n. 14
0
        public void T10PPaperCScissors()
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.MakeChoice("paper");
            rps.cpuChoice = "scissors";
            Assert.True(rps.GetResult() == "lose");
        }
Esempio n. 15
0
        public void ReturnsRockPaperScissorsTie()
        {
            var expectedGameResult = GameResult.Tied;

            var rockPaperScissors = new RockPaperScissors();
            var actualGameResult  = rockPaperScissors.GetGameResult(Throw.Paper, Throw.Paper);

            Assert.AreEqual(expectedGameResult, actualGameResult);
        }
Esempio n. 16
0
        public void PaperBeatsRock()
        {
            var expectedGameResult = GameResult.Won;

            var rockPaperScissors = new RockPaperScissors();
            var actualGameResult  = rockPaperScissors.GetGameResult(Throw.Paper, Throw.Rock);

            Assert.AreEqual(expectedGameResult, actualGameResult);
        }
Esempio n. 17
0
        public void Constructor_StoresUserChoice_UserChoice()
        {
            string            userChoice = "paper";
            RockPaperScissors round      = new RockPaperScissors(userChoice);

            string result = round.UserChoice;

            Assert.AreEqual(result, userChoice);
        }
Esempio n. 18
0
        public void RockPaperScissorsShouldDraw(RPS player1, RPS player2, RPS player3)
        {
            // Arrange-> See data rows

            // Act
            var result = RockPaperScissors.PlayWith3Players(player1, player2, player3);

            // Assert
            Assert.IsTrue(result.Contains("Draw"));
        }
Esempio n. 19
0
        private static void displayResult(RockPaperScissors rps)
        {
            Console.WriteLine("Player Gesture: {0}, Bot Gesture: {1}", rps.Player1Gesture, rps.Player2Gesture);
            Console.WriteLine("Game Result: {0}!", rps.Player1Result);

            Console.WriteLine("Game Count: {0}", rps.GameCount);
            Console.WriteLine("Player One Score: {0}, Player Two Score: {1}", rps.Player1Score, rps.Player2Score);

            Console.Read();
        }
Esempio n. 20
0
        public void RockPaperScissors_WinCheck_Draw()
        {
            // Arrange
            RockPaperScissors newPlay = new RockPaperScissors();
            // Act
            string result = newPlay.WinCheck("R", "R");

            // Assert
            Assert.AreEqual("Draw! Play again.", result);
        }
Esempio n. 21
0
 /**
  * This is the main method wher the game is started from. The game is in an infinate loop
  * allowing the user to play as many rounds as he wants.
  */
 public static void Main()
 {
     RockPaperScissors game = new RockPaperScissors();
     while (true)
     {
         Console.WriteLine("Press enter to start a game... ");
         Console.ReadLine();
         game.playGame();
     }
 }
        public void ShotgunShouldThrow(RPS player1, RPS player2)
        {
            // Arrange -> see data rows.

            // Act
            var result = RockPaperScissors.PlayWith2Players(player1, player2);

            // Assert -> unhappy path testing :(
            Assert.Fail();
        }
Esempio n. 23
0
        public void RockPaperScissors_WinCheck_Player1()
        {
            //Arrange
            RockPaperScissors newPlay = new RockPaperScissors();
            // Act
            string result = newPlay.WinCheck("R", "S");

            // Assert
            Assert.AreEqual("Player 1 Wins!", result);
        }
        public void ScissorsShouldWinPaper(RPS player1, RPS player2, string winner)
        {
            // Arrange -> See data rows.

            // Act
            var result = RockPaperScissors.PlayWith2Players(player1, player2);

            // Assert
            Assert.IsTrue(result.Contains(winner));
        }
        public void SameShouldDraw(RPS choise)
        {
            // Arrange -> See data rows.

            // Act
            var result = RockPaperScissors.PlayWith2Players(choise, choise);

            // Assert
            Assert.IsTrue(result.Contains("Draw"));
        }
Esempio n. 26
0
    public void WinConditionDifferentRules(string input1, string input2, string expected)
    {
        var game = new RockPaperScissors();

        game.Rules = new List <Func <string, string, string> >
        {
            (weapon1, weapon2) => (weapon1 == "Rock" && weapon2 == "Spock") ? "Player2 Wins" : string.Empty,
            (weapon1, weapon2) => (weapon1 == "Lizard" && weapon2 == "Paper") ? "Player1 Wins" : string.Empty
        };
    }
        public void Test_Richard_winner()
        {
            // arrange
            var tournament = new Tournament {
                new List <Move>
                {
                    new Move {
                        MoveType = "P", Player = "Armando"
                    },
                    new Move {
                        MoveType = "S", Player = "Dave"
                    }
                },

                new List <Move>
                {
                    new Move {
                        MoveType = "R", Player = "Richard"
                    },
                    new Move {
                        MoveType = "S", Player = "Michael"
                    }
                },

                new List <Move>
                {
                    new Move {
                        MoveType = "S", Player = "Allen"
                    },
                    new Move {
                        MoveType = "P", Player = "Omer"
                    }
                },

                new List <Move>
                {
                    new Move {
                        MoveType = "R", Player = "David E"
                    },
                    new Move {
                        MoveType = "P", Player = "Richard X"
                    }
                }
            };

            // act
            var rps    = new RockPaperScissors();
            var winner = rps.Rps_tournament_winner(tournament);

            // assert
            Assert.IsNotNull(winner);
            Assert.AreEqual(winner.Player, "Richard");
            Assert.AreEqual(winner.MoveType, "R");
        }
Esempio n. 28
0
        public void GetGameResult_ReturnsDrawForSameChoices_Draw()
        {
            string            userChoice = "paper";
            RockPaperScissors round      = new RockPaperScissors(userChoice);

            round.ComputerChoice = "paper";

            string result = round.GetGameResult();

            Assert.AreEqual(result, "draw");
        }
Esempio n. 29
0
        public void GetGameResult_ReturnsWinForScissorsVPaper_Win()
        {
            string            userChoice = "scissors";
            RockPaperScissors round      = new RockPaperScissors(userChoice);

            round.ComputerChoice = "paper";

            string result = round.GetGameResult();

            Assert.AreEqual(result, "win");
        }
Esempio n. 30
0
        public void GetGameResult_ReturnsLossForPaperVScissors_Loss()
        {
            string            userChoice = "paper";
            RockPaperScissors round      = new RockPaperScissors(userChoice);

            round.ComputerChoice = "scissors";

            string result = round.GetGameResult();

            Assert.AreEqual(result, "loss");
        }
Esempio n. 31
0
        public ActionResult IndexPost()
        {
            string function        = Request.Form["function"];
            string inputPalindrome = Request.Form["palindromeinputString"];
            string inputFR         = Request.Form["inputFR"];
            string find            = Request.Form["findFR"];
            string replace         = Request.Form["replaceFR"];
            string rpsPlayerOne    = Request.Form["rpsPlayerOne"];
            string rpsPlayerTwo    = Request.Form["rpsPlayerTwo"];
            string anagramField    = Request.Form["anagram"];
            string inputScrabble   = Request.Form["scrabble"];

            if (function == "palindromes")
            {
                Palindrome newModel = new Palindrome(inputPalindrome);
                return(View("Index", newModel));
            }
            else if (function == "fr")
            {
                FindAndReplace newModel = new FindAndReplace(inputFR, find, replace);
                // Console.WriteLine("RPSAI");
                return(View("Index", newModel));
            }
            else if (function == "rpsai")
            {
                RockPaperScissors newModel = new RockPaperScissors(rpsPlayerOne, "");
                newModel.AIPlay();
                // Console.WriteLine("RPS");
                return(View("Index", newModel));
            }
            else if (function == "rps")
            {
                RockPaperScissors newModel = new RockPaperScissors(rpsPlayerOne, rpsPlayerTwo);
                // Console.WriteLine("Palindrome");
                return(View("Index", newModel));
            }
            else if (function == "anagram")
            {
                Anagram newModel = new Anagram(anagramField);
                // Console.WriteLine("Anagram");
                return(View("Index", newModel));
            }
            else if (function == "scrabble")
            {
                Scrabble newModel = new Scrabble(inputScrabble);
                // Console.WriteLine("Scrabble");
                return(View("Index", newModel));
            }
            else
            {
            }
            return(View("Index"));
        }
Esempio n. 32
0
 public void WinCondition(string input1, string input2, string expected)
 {
     var game = new RockPaperScissors ();
     string result = game.winCondition (input1, input2);
     Assert.That (result, Is.EqualTo(expected));
 }
Esempio n. 33
0
 public void WinConditionDifferentRules(string input1, string input2, string expected)
 {
     var game = new RockPaperScissors ();
     game.Rules = new List<Func<string, string, string>>
     {
         (weapon1, weapon2) => (weapon1 == "Rock" && weapon2 == "Spock") ? "Player2 Wins" : string.Empty,
         (weapon1, weapon2) => (weapon1 == "Lizard" && weapon2 == "Paper") ? "Player1 Wins" : string.Empty
     };
 }
Esempio n. 34
0
 public void ValidEntry(string input, bool expected)
 {
     var game = new RockPaperScissors ();
     bool result = game.validEntry (input);
     Assert.That (result, Is.EqualTo(expected));
 }