mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +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) {
|
calculate(hand) {
|
||||||
return hand.reduce((a, b) => {
|
return hand.sort((a, b) => a.value - b.value).reduce((a, b) => {
|
||||||
let { value } = b;
|
let { value } = b;
|
||||||
if (value === 11 && a + value > 21) value = 1;
|
if (value === 11 && a + value > 21) value = 1;
|
||||||
return a + value;
|
return a + value;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "91.5.2",
|
"version": "91.5.3",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user