From f1f2718598af1a7e1aaefa34555ece89bf32ff23 Mon Sep 17 00:00:00 2001 From: Kevin <46859125+403-Fruit@users.noreply.github.com> Date: Sat, 4 Mar 2023 19:46:14 -1000 Subject: [PATCH] Blackjack game: fix bug counting more than one ace Take into account how many aces there are before using 11 as the value for an ace --- applications/plugins/blackjack/common/card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/plugins/blackjack/common/card.c b/applications/plugins/blackjack/common/card.c index 199135bb5a..88228fda44 100644 --- a/applications/plugins/blackjack/common/card.c +++ b/applications/plugins/blackjack/common/card.c @@ -173,7 +173,7 @@ uint8_t hand_count(const Card* cards, uint8_t count) { } for(uint8_t i = 0; i < aceCount; i++) { - if((score + 11) <= 21) + if((score + 11 + (aceCount - 1)) <= 21) score += 11; else score++; @@ -350,4 +350,4 @@ void add_hand_region(Hand* to, Hand* from) { add_to_hand(to, from->cards[i]); } } -} \ No newline at end of file +}