WORDLE_USE_DAILY_STREAK logic changed
This commit is contained in:
parent
c43820e75d
commit
d1c19166a1
@ -248,7 +248,7 @@ static void display_title(wordle_state_t *state) {
|
|||||||
show_skip_wrong_letter_indicator(state->skip_wrong_letter, state->curr_screen);
|
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) {
|
static void display_continue_result(bool continuing) {
|
||||||
watch_display_string(continuing ? "y" : "n", 9);
|
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) {
|
static void display_streak(wordle_state_t *state) {
|
||||||
char buf[12];
|
char buf[12];
|
||||||
state->curr_screen = SCREEN_STREAK;
|
state->curr_screen = SCREEN_STREAK;
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
#if WORDLE_USE_DAILY_STREAK != 2
|
||||||
if (state->streak > 99)
|
if (state->streak > 99)
|
||||||
sprintf(buf, "WO St--dy");
|
sprintf(buf, "WO St--dy");
|
||||||
else
|
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);
|
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) {
|
static void display_wait(wordle_state_t *state) {
|
||||||
state->curr_screen = SCREEN_WAIT;
|
state->curr_screen = SCREEN_WAIT;
|
||||||
if (state->streak < 40) {
|
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);
|
show_skip_wrong_letter_indicator(state->skip_wrong_letter, state->curr_screen);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint32_t get_day_unix_time(void) {
|
static uint32_t get_day_unix_time(void) {
|
||||||
watch_date_time now = watch_rtc_get_date_time();
|
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;
|
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
|
#endif
|
||||||
|
return watch_utility_date_time_to_unix_time(now, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void display_lose(wordle_state_t *state, uint8_t subsecond) {
|
static void display_lose(wordle_state_t *state, uint8_t subsecond) {
|
||||||
char buf[WORDLE_LENGTH + 6];
|
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);
|
display_playing(state);
|
||||||
return true;
|
return true;
|
||||||
case SCREEN_TITLE:
|
case SCREEN_TITLE:
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
#if WORDLE_USE_DAILY_STREAK == 2
|
||||||
if (state->prev_day == get_day_unix_time()) {
|
if (state->day_last_game_started == get_day_unix_time()) {
|
||||||
display_wait(state);
|
display_wait(state);
|
||||||
}
|
}
|
||||||
else if (is_playing(state))
|
else if (is_playing(state))
|
||||||
@ -376,7 +373,7 @@ static bool act_on_btn(wordle_state_t *state, const uint8_t pin) {
|
|||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
case SCREEN_STREAK:
|
case SCREEN_STREAK:
|
||||||
state->curr_day = get_day_unix_time();
|
state->day_last_game_started = get_day_unix_time();
|
||||||
reset_board(state);
|
reset_board(state);
|
||||||
return true;
|
return true;
|
||||||
case SCREEN_WIN:
|
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);
|
state->position = get_first_pos(state->word_elements_result);
|
||||||
display_playing(state);
|
display_playing(state);
|
||||||
return true;
|
return true;
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
#if WORDLE_USE_DAILY_STREAK == 2
|
||||||
case SCREEN_WAIT:
|
case SCREEN_WAIT:
|
||||||
(void) pin;
|
(void) pin;
|
||||||
display_title(state);
|
display_title(state);
|
||||||
@ -444,8 +441,8 @@ static void get_result(wordle_state_t *state) {
|
|||||||
state->curr_screen = SCREEN_WIN;
|
state->curr_screen = SCREEN_WIN;
|
||||||
if (state->streak < 0x7F)
|
if (state->streak < 0x7F)
|
||||||
state->streak++;
|
state->streak++;
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
#if WORDLE_USE_DAILY_STREAK == 2
|
||||||
state->prev_day = get_day_unix_time();
|
state->day_last_game_started = get_day_unix_time(); // On the edge-case where we solve the puzzle at midnight
|
||||||
#endif
|
#endif
|
||||||
return;
|
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 wordle_face_activate(movement_settings_t *settings, void *context) {
|
||||||
(void) settings;
|
(void) settings;
|
||||||
wordle_state_t *state = (wordle_state_t *)context;
|
wordle_state_t *state = (wordle_state_t *)context;
|
||||||
|
#if WORDLE_USE_DAILY_STREAK != 0
|
||||||
uint32_t now = get_day_unix_time();
|
uint32_t now = get_day_unix_time();
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
if (now >= (state->day_last_game_started + (60 *60 * 24)) &&
|
||||||
if (state->curr_day != now) reset_all_elements(state);
|
(is_playing(state) || WORDLE_USE_DAILY_STREAK == 2)) {
|
||||||
if (now >= (state->prev_day + (60 *60 * 24))) state->streak = 0;
|
|
||||||
#else
|
|
||||||
if (is_playing(state) && now >= (state->curr_day + (60 *60 * 24))) {
|
|
||||||
state->streak = 0;
|
state->streak = 0;
|
||||||
reset_board(state);
|
reset_board(state);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,16 @@
|
|||||||
|
|
||||||
#define WORDLE_LENGTH 5
|
#define WORDLE_LENGTH 5
|
||||||
#define WORDLE_MAX_ATTEMPTS 6
|
#define WORDLE_MAX_ATTEMPTS 6
|
||||||
#define WORDLE_USE_DAILY_STREAK false // If true, the board will reset daily and the streak will go to zero if the game isn't played for a day
|
/* WORDLE_USE_DAILY_STREAK
|
||||||
// If false, then the streak will still reset if the game is not completed within 24 hours
|
* 0 = Don't ever reset the streak or the puzzle.
|
||||||
|
* 1 = Reset the streak and puzzle 24hrs after starting a puzzle and not finishing it.
|
||||||
|
* If the last puzzle was started at 8AM, it'll be considered failed at 8AM the next day.
|
||||||
|
* 2 = Reset the streak and puzzle if a puzzle goes unsolved or not started a day after the previous one.
|
||||||
|
* If the last puzzle was started at 8AM, it'll be considered failed at midnight the next day.
|
||||||
|
* This will not be the case if the puzzle is started at 8AM, continued at 11:59PM and solved at 12:01AM, the game will let that slide.
|
||||||
|
* Starting a new game instead of continuing is not allowed in this state.
|
||||||
|
*/
|
||||||
|
#define WORDLE_USE_DAILY_STREAK 1
|
||||||
#define WORDLE_ALLOW_NON_WORD_AND_REPEAT_GUESSES false // This allows non-words to be entered and repeat guesses to be made. It saves ~11.5KB of ROM.
|
#define WORDLE_ALLOW_NON_WORD_AND_REPEAT_GUESSES false // This allows non-words to be entered and repeat guesses to be made. It saves ~11.5KB of ROM.
|
||||||
/* WORDLE_USE_RANDOM_GUESS
|
/* WORDLE_USE_RANDOM_GUESS
|
||||||
* 0 = Don't allow quickly choosing a random quess
|
* 0 = Don't allow quickly choosing a random quess
|
||||||
@ -120,10 +128,7 @@ typedef struct {
|
|||||||
uint8_t streak;
|
uint8_t streak;
|
||||||
WordleScreen curr_screen;
|
WordleScreen curr_screen;
|
||||||
bool known_wrong_letters[WORDLE_NUM_VALID_LETTERS];
|
bool known_wrong_letters[WORDLE_NUM_VALID_LETTERS];
|
||||||
uint32_t curr_day;
|
uint32_t day_last_game_started;
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
|
||||||
uint32_t prev_day;
|
|
||||||
#endif
|
|
||||||
} wordle_state_t;
|
} wordle_state_t;
|
||||||
|
|
||||||
void wordle_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
void wordle_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user