Exemplo n.º 1
0
        public void HandleClaimsWithAnyOperatorAndVariableIncludeWilds(string claimText, Operator expectedOperator, int expectedQuantity, int expectedPips, bool expectedIncludeWilds)
        {
            var parsedClaim = ClaimParser.Parse(claimText);

            parsedClaim.Operator.ShouldBe(expectedOperator);
            parsedClaim.Quantity.ShouldBe(expectedQuantity);
            parsedClaim.Pips.ShouldBe(expectedPips);
            parsedClaim.IncludeWilds.ShouldBe(expectedIncludeWilds);
        }
        public void TestParseClaim(string input, Claim expected)
        {
            var actual = ClaimParser.Parse(input);

            Assert.Equal(expected.id, actual.id);
            Assert.Equal(expected.x, actual.x);
            Assert.Equal(expected.y, actual.y);
            Assert.Equal(expected.width, actual.width);
            Assert.Equal(expected.height, actual.height);
        }
Exemplo n.º 3
0
        public void ItShouldWork()
        {
            // arrange
            string input = "#1 @ 2,3: 4x5";

            // act
            ClaimDto result = ClaimParser.Parse(input);

            // assert
            Assert.AreEqual(1, result.Id);
            Assert.AreEqual(2, result.LeftEdgePosition);
            Assert.AreEqual(3, result.TopEdgePosition);
            Assert.AreEqual(4, result.Width);
            Assert.AreEqual(5, result.Height);
        }
Exemplo n.º 4
0
 public void ThrowExceptionWhenInvalidClaimGiven(string claimText)
 {
     Should.Throw <ArgumentException>(() => ClaimParser.Parse(claimText), ClaimExceptionMessages.InvalidClaimFormat);
 }
Exemplo n.º 5
0
        public async Task ClaimDiceAsync([Remainder] string claimText)
        {
            //await SendMessageAsync("I thought you wanted to be on the nice list?");
            return;

            if (claimText.Contains("help"))
            {
                await ClaimHelpAsync();

                return;
            }

            claimText = claimText.Replace("❤️", "<3");

            var game = await GetGameAsync(GameState.InProgress);

            var gamePlayer = game.GamePlayers
                             .Where(x => x.NumberOfDice > 0)
                             .Where(x => x.Player.Username == Context.User.Username)
                             .SingleOrDefault();

            if (gamePlayer == null)
            {
                return;
            }

            // make sure claim calls from previous rounds don't carry over if called too late
            if (Context.Message.Timestamp.ToLocalTime() < game.CurrentRound.DateStarted)
            {
                return;
            }

            if (!(game.CurrentRound is StandardRound))
            {
                await SendMessageAsync("Sorry, claims are only currently supported in standard rounds.");

                return;
            }

            Claim claim;

            try
            {
                claim = ClaimParser.Parse(claimText);

                DeleteCommandFromDiscord(Context.Message.Id);

                var message = await SendMessageAsync($":loudspeaker: {gamePlayer.Player.Nickname} claims " +
                                                     $"{claim.Operator.ToReadableString()} `{claim.Quantity}` x {claim.Pips.GetEmoji()}{(claim.IncludeWilds ? "" : " (no wilds)")} ...");

                Thread.Sleep(2000);

                var isClaimValid = ClaimValidator.Validate(claim, gamePlayer.Dice);

                var validationMessage = isClaimValid ? ":white_check_mark: It's Legit!" : ":x: Nope!";

                await message.ModifyAsync(msg => msg.Content = $"{message.Content} {validationMessage}");
            }
            catch (ArgumentException)
            {
                await SendMessageAsync($"Sorry, your claim doesn't jive. Try `!claim help` for help.");
            }
        }