From 60238cbc438c0c6afbbb566b16b819f00afa4637 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 18 Sep 2018 22:39:08 +0000 Subject: [PATCH] Fix blackjack ace calculation breaking if ace isn't last card --- commands/games/blackjack.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/games/blackjack.js b/commands/games/blackjack.js index dfff851c..04cee15a 100644 --- a/commands/games/blackjack.js +++ b/commands/games/blackjack.js @@ -147,7 +147,7 @@ module.exports = class BlackjackCommand extends Command { } calculate(hand) { - return hand.reduce((a, b) => { + return hand.sort((a, b) => a.value - b.value).reduce((a, b) => { let { value } = b; if (value === 11 && a + value > 21) value = 1; return a + value; diff --git a/package.json b/package.json index b56917a2..f63235a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "91.5.2", + "version": "91.5.3", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {