WORDLE_USE_DAILY_STREAK logic changed

This commit is contained in:
David Volovskiy
2024-08-27 12:31:22 -04:00
parent c43820e75d
commit d1c19166a1
2 changed files with 27 additions and 27 deletions

View File

@@ -248,7 +248,7 @@ static void display_title(wordle_state_t *state) {
show_skip_wrong_letter_indicator(state->skip_wrong_letter, state->curr_screen);
}
#if !WORDLE_USE_DAILY_STREAK
#if WORDLE_USE_DAILY_STREAK != 2
static void display_continue_result(bool continuing) {
watch_display_string(continuing ? "y" : "n", 9);
}
@@ -264,7 +264,7 @@ static void display_continue(wordle_state_t *state) {
static void display_streak(wordle_state_t *state) {
char buf[12];
state->curr_screen = SCREEN_STREAK;
#if WORDLE_USE_DAILY_STREAK
#if WORDLE_USE_DAILY_STREAK != 2
if (state->streak > 99)
sprintf(buf, "WO St--dy");
else
@@ -277,7 +277,7 @@ static void display_streak(wordle_state_t *state) {
show_skip_wrong_letter_indicator(state->skip_wrong_letter, state->curr_screen);
}
#if WORDLE_USE_DAILY_STREAK
#if WORDLE_USE_DAILY_STREAK == 2
static void display_wait(wordle_state_t *state) {
state->curr_screen = SCREEN_WAIT;
if (state->streak < 40) {
@@ -290,18 +290,15 @@ static void display_wait(wordle_state_t *state) {
}
show_skip_wrong_letter_indicator(state->skip_wrong_letter, state->curr_screen);
}
#endif
static uint32_t get_day_unix_time(void) {
watch_date_time now = watch_rtc_get_date_time();
#if WORDLE_USE_DAILY_STREAK == 2
now.unit.hour = now.unit.minute = now.unit.second = 0;
return watch_utility_date_time_to_unix_time(now, 0);
}
#else
static uint32_t get_day_unix_time(void) {
watch_date_time now = watch_rtc_get_date_time();
return watch_utility_date_time_to_unix_time(now, 0);
}
#endif
return watch_utility_date_time_to_unix_time(now, 0);
}
static void display_lose(wordle_state_t *state, uint8_t subsecond) {
char buf[WORDLE_LENGTH + 6];
@@ -358,8 +355,8 @@ static bool act_on_btn(wordle_state_t *state, const uint8_t pin) {
display_playing(state);
return true;
case SCREEN_TITLE:
#if WORDLE_USE_DAILY_STREAK
if (state->prev_day == get_day_unix_time()) {
#if WORDLE_USE_DAILY_STREAK == 2
if (state->day_last_game_started == get_day_unix_time()) {
display_wait(state);
}
else if (is_playing(state))
@@ -376,7 +373,7 @@ static bool act_on_btn(wordle_state_t *state, const uint8_t pin) {
#endif
return true;
case SCREEN_STREAK:
state->curr_day = get_day_unix_time();
state->day_last_game_started = get_day_unix_time();
reset_board(state);
return true;
case SCREEN_WIN:
@@ -388,7 +385,7 @@ static bool act_on_btn(wordle_state_t *state, const uint8_t pin) {
state->position = get_first_pos(state->word_elements_result);
display_playing(state);
return true;
#if WORDLE_USE_DAILY_STREAK
#if WORDLE_USE_DAILY_STREAK == 2
case SCREEN_WAIT:
(void) pin;
display_title(state);
@@ -444,8 +441,8 @@ static void get_result(wordle_state_t *state) {
state->curr_screen = SCREEN_WIN;
if (state->streak < 0x7F)
state->streak++;
#if WORDLE_USE_DAILY_STREAK
state->prev_day = get_day_unix_time();
#if WORDLE_USE_DAILY_STREAK == 2
state->day_last_game_started = get_day_unix_time(); // On the edge-case where we solve the puzzle at midnight
#endif
return;
}
@@ -496,12 +493,10 @@ void wordle_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
void wordle_face_activate(movement_settings_t *settings, void *context) {
(void) settings;
wordle_state_t *state = (wordle_state_t *)context;
#if WORDLE_USE_DAILY_STREAK != 0
uint32_t now = get_day_unix_time();
#if WORDLE_USE_DAILY_STREAK
if (state->curr_day != now) reset_all_elements(state);
if (now >= (state->prev_day + (60 *60 * 24))) state->streak = 0;
#else
if (is_playing(state) && now >= (state->curr_day + (60 *60 * 24))) {
if (now >= (state->day_last_game_started + (60 *60 * 24)) &&
(is_playing(state) || WORDLE_USE_DAILY_STREAK == 2)) {
state->streak = 0;
reset_board(state);
}