From 715667c6311e7d59c2a3d74d92a30847ab1b14e9 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 17 Sep 2018 17:00:44 +0000 Subject: [PATCH] Allow up to 6 decks, default to 1 in blackjack --- commands/games/blackjack.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/commands/games/blackjack.js b/commands/games/blackjack.js index 76fc302a..7f3c606e 100644 --- a/commands/games/blackjack.js +++ b/commands/games/blackjack.js @@ -11,16 +11,26 @@ module.exports = class BlackjackCommand extends Command { aliases: ['twenty-one', '21'], group: 'games', memberName: 'blackjack', - description: 'Play a game of blackjack.' + description: 'Play a game of blackjack.', + args: [ + { + key: 'deckCount', + label: 'amount of decks', + prompt: 'How many decks do you want to use?', + default: 1, + max: 8, + min: 1 + } + ] }); this.decks = new Map(); } - async run(msg) { + async run(msg, { deckCount }) { if (this.decks.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.'); try { - this.decks.set(msg.channel.id, this.generateDeck()); + this.decks.set(msg.channel.id, this.generateDeck(deckCount)); const dealerHand = []; this.draw(msg.channel, dealerHand); this.draw(msg.channel, dealerHand); @@ -102,9 +112,9 @@ module.exports = class BlackjackCommand extends Command { } } - generateDeck() { + generateDeck(deckCount) { const deck = []; - for (let i = 0; i < 6; i++) { + for (let i = 0; i < deckCount; i++) { for (const suit of suits) { deck.push({ value: 11,