Merge pull request #167 from voloved/blackjack_face

Fix Win-Lose Ratio and Reset it
This commit is contained in:
voloved 2025-12-03 13:36:26 -05:00 committed by GitHub
commit bd28a76233
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -277,7 +277,7 @@ static void display_win_ratio(blackjack_face_state_t *state) {
game_state = BJ_WIN_RATIO;
uint8_t win_ratio = 0;
if (state->games_played > 0) { // Avoid dividing by zero
win_ratio = (uint8_t)(100 * state->games_won) / state->games_played;
win_ratio = (uint8_t)((100 * state->games_won) / state->games_played);
}
watch_display_text(WATCH_POSITION_TOP_RIGHT, " ");
watch_display_text_with_fallback(WATCH_POSITION_TOP, "WINS ", "WR");
@ -444,6 +444,11 @@ bool blackjack_face_loop(movement_event_t event, void *context) {
case EVENT_ALARM_LONG_PRESS:
if (game_state == BJ_TITLE_SCREEN) {
toggle_tap_control(state);
} else if (game_state == BJ_WIN_RATIO) {
// Reset the win-lose ratio
state->games_won = 0;
state->games_played = 0;
watch_display_text(WATCH_POSITION_BOTTOM, " 0Pct");
}
break;
case EVENT_TIMEOUT:

View File

@ -63,6 +63,7 @@
*
* Long-pressing the LIGHT button on the Title Screen will display your win rate as a percentage of games finished.
* It displays as games won / (games won + games lost) it does not include incomplete nor tied games.
* You can reset the win rate on that screen by long-pressing the ALARM button.
*
* | Cards | |
* |---------|--------------------------|