Exemplo n.º 1
0
        public void Decide_the_winner_based_on_round_results()
        {
            player1.RevealHand().Returns(Hand.Paper);
            player2.RevealHand().Returns(Hand.Scissors);

            GameResult result = game.Play(player1, player2);

            result.WinningPlayer.ShouldBe(player2);
        }
Exemplo n.º 2
0
        public async Task PlayAsync(string actor, string mention = null)
        {
            if (Context.Message.Content.Contains("|"))
            {
                actor = actor.Replace("|", "");
            }

            RpsPlayData playData = CreatePlayData(Context.Message.Author.Id, actor, Context.Message.Author.Mention,
                                                  Context.Message.Author.Username, Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl());

            RpsPlayData?mentionData = null;

            if (mention != null && Context.Message.MentionedUsers.Count > 0)
            {
                var mentionUser = Context.Message.MentionedUsers.ElementAt(0);
                mentionData = CreatePlayData(mentionUser.Id, actor, mentionUser.Mention, mentionUser.Username,
                                             mentionUser.GetAvatarUrl() ?? mentionUser.GetDefaultAvatarUrl());
            }

            var result = _rps.Play(playData, mentionData);

            if (result.Description.Contains("Wrong input"))
            {
                await SendMessage(result.Description);
            }
            else
            {
                await _client.GetGuild(Context.Guild.Id).GetTextChannel(Context.Channel.Id)
                .DeleteMessageAsync(Context.Message);
                await SendMessage(result);
            }
        }
Exemplo n.º 3
0
        public static void Main()
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Green;
            RockPaperScissors game = new RockPaperScissors();

            Console.WriteLine("Would you like to play rock-paper-scissors?");
            string userPlay = Console.ReadLine();

            if (userPlay == "yes")
            {
                game.Play();
            }
            else
            {
                Console.WriteLine("ok f**k off");
            }
        }
Exemplo n.º 4
0
        public void PlayVsBot_Test_Win()
        {
            RpsPlayData player = CreatePlayer("r");

            _rps.Play(player, null, RpsActors.Scissors);
            RpsUserData user = (RpsUserData)_fileSystem.Load().ElementAt(0);

            Equal(user, 345678912, 1, 1, 1, ratio: 100, currentStreak: 1, rockChosen: 1, coins: 1);

            DeleteFile(player.GuildId + ".xml");
        }
Exemplo n.º 5
0
        public void TestWinCondition_IncorrectInput()
        {
            RockPaperScissors rps = new RockPaperScissors();

            Assert.AreEqual(Listof_Results.badChoices, rps.Play((Listof_Choices)(-34), (Listof_Choices)56));
        }
Exemplo n.º 6
0
        public void TestWinCondition_Inputpaperscissors_ReturnPlayer2()
        {
            RockPaperScissors rps = new RockPaperScissors();

            Assert.AreEqual(Listof_Results.player1, rps.Play(Listof_Choices.scissors, Listof_Choices.paper));
        }
Exemplo n.º 7
0
        public void TestTieCondition_InputRockRock_ReturnTie()
        {
            RockPaperScissors rps = new RockPaperScissors();

            Assert.AreEqual(Listof_Results.tie, rps.Play(Listof_Choices.rock, Listof_Choices.rock));
        }