Example #1
0
        public Task DrawAsync(CommandContext ctx,
                              [Description("desc-draw-amount")] int amount = 1)
        {
            Deck deck = CardDecksService.GetDeckForChannel(ctx.Channel.Id);

            if (amount is < 1 or > 10)
            {
                throw new InvalidCommandUsageException(ctx, "cmd-err-deck-amount", 1, 10);
            }

            IReadOnlyList <Card> drawn = deck.DrawCards(amount);

            if (!drawn.Any())
            {
                throw new CommandFailedException(ctx, "cmd-err-deck-empty");
            }

            return(ctx.ImpInfoAsync(this.ModuleColor, Emojis.Dice, "fmt-deck-draw", drawn.JoinWith(" ")));
        }
Example #2
0
        public Task DrawAsync(CommandContext ctx,
                              [Description("Amount (in range [1, 10]).")] int amount = 1)
        {
            Deck deck = CardDecksService.GetDeckInChannel(ctx.Channel.Id);

            if (deck is null)
            {
                throw new CommandFailedException($"No deck to deal from. Use command {Formatter.InlineCode("deck")} to open a new deck.");
            }

            if (amount < 1 || amount > 10)
            {
                throw new InvalidCommandUsageException("Amount of cards to draw must be in range [1, 10].");
            }

            IReadOnlyList <Card> drawn = deck.DrawCards(amount);

            if (!drawn.Any())
            {
                throw new CommandFailedException($"Current deck doesn't have enough cards. Use command {Formatter.InlineCode("deck reset")} to open a new deck.");
            }

            return(this.InformAsync(ctx, $"{ctx.User.Mention} drew {string.Join(" ", drawn)}", ":ticket:"));
        }
Example #3
0
 public Task ResetDeckAsync(CommandContext ctx)
 {
     CardDecksService.ResetDeckInChannel(ctx.Channel.Id);
     return(this.InformAsync(ctx, StaticDiscordEmoji.CardSuits[0], "A new shuffled deck is opened in this channel!"));
 }
Example #4
0
 public Task ResetDeckAsync(CommandContext ctx)
 {
     CardDecksService.ResetDeckForChannel(ctx.Channel.Id);
     return(ctx.InfoAsync(this.ModuleColor));
 }