mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Fix blackjack ace calculation breaking if ace isn't last card
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user