Added delay before showing Bust

This commit is contained in:
David Volovskiy 2025-09-03 07:52:18 -04:00
parent 93a2a5a5ee
commit d6e4a1ad44

View File

@ -58,6 +58,7 @@ typedef enum {
BJ_TITLE_SCREEN, BJ_TITLE_SCREEN,
BJ_PLAYING, BJ_PLAYING,
BJ_DEALER_PLAYING, BJ_DEALER_PLAYING,
BJ_BUST,
BJ_RESULT, BJ_RESULT,
} game_state_t; } game_state_t;
@ -206,7 +207,7 @@ static void display_dealer_hand(void) {
display_card_at_position(card, 0); display_card_at_position(card, 0);
} }
display_score(uint8_t score, watch_position_t pos) { static void display_score(uint8_t score, watch_position_t pos) {
char buf[4]; char buf[4];
sprintf(buf, "%2d", score); sprintf(buf, "%2d", score);
watch_display_text(pos, buf); watch_display_text(pos, buf);
@ -235,7 +236,6 @@ static void display_tie(void) {
static void display_bust(void) { static void display_bust(void) {
game_state = BJ_RESULT; game_state = BJ_RESULT;
watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, "8UST ", " BUST"); watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, "8UST ", " BUST");
display_score(player.score, WATCH_POSITION_SECONDS);
} }
static void display_title(void) { static void display_title(void) {
@ -264,11 +264,10 @@ static void perform_hit(void) {
} }
give_card(&player); give_card(&player);
if (player.score > 21) { if (player.score > 21) {
display_bust(); game_state = BJ_BUST;
} else {
display_player_hand();
display_score(player.score, WATCH_POSITION_SECONDS);
} }
display_player_hand();
display_score(player.score, WATCH_POSITION_SECONDS);
} }
static void perform_stand(void) { static void perform_stand(void) {
@ -320,6 +319,8 @@ static void handle_button_presses(bool hit) {
case BJ_DEALER_PLAYING: case BJ_DEALER_PLAYING:
see_if_dealer_hits(); see_if_dealer_hits();
break; break;
case BJ_BUST:
display_bust();
case BJ_RESULT: case BJ_RESULT:
display_title(); display_title();
break; break;
@ -369,6 +370,9 @@ bool blackjack_face_loop(movement_event_t event, void *context) {
if (game_state == BJ_DEALER_PLAYING) { if (game_state == BJ_DEALER_PLAYING) {
see_if_dealer_hits(); see_if_dealer_hits();
} }
else if (game_state == BJ_BUST) {
display_bust();
}
break; break;
case EVENT_LIGHT_BUTTON_UP: case EVENT_LIGHT_BUTTON_UP:
case EVENT_DOUBLE_TAP: case EVENT_DOUBLE_TAP: