#include <stdlib.h>
#include <string.h>
#include "wordle_face.h"
-#if WORDLE_USE_DAILY_STREAK
#include "watch_utility.h"
-#endif
static uint32_t get_random(uint32_t max) {
#if __EMSCRIPTEN__
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
static void display_lose(wordle_state_t *state, uint8_t subsecond) {
#endif
return true;
case SCREEN_STREAK:
-#if WORDLE_USE_DAILY_STREAK
state->curr_day = get_day_unix_time();
-#endif
reset_board(state);
return true;
case SCREEN_WIN:
void wordle_face_activate(movement_settings_t *settings, void *context) {
(void) settings;
wordle_state_t *state = (wordle_state_t *)context;
+ uint32_t now = get_day_unix_time();
#if WORDLE_USE_DAILY_STREAK
- uint32_t now = get_day_unix_time() ;
- if (now >= (state->prev_day + (60 *60 * 24))) state->streak = 0;
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))) {
+ state->streak = 0;
+ reset_board(state);
+ }
#endif
state->using_random_guess = false;
if (is_playing(state) && state->curr_screen >= SCREEN_RESULT) {
#define WORDLE_LENGTH 5
#define WORDLE_MAX_ATTEMPTS 6
-#define WORDLE_USE_DAILY_STREAK false
+#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
+ // If false, then the streak will still reset if the game is not completed within 24 hours
#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
* 0 = Don't allow quickly choosing a random quess
uint8_t streak;
WordleScreen curr_screen;
bool known_wrong_letters[WORDLE_NUM_VALID_LETTERS];
+ uint32_t curr_day;
#if WORDLE_USE_DAILY_STREAK
uint32_t prev_day;
- uint32_t curr_day;
#endif
} wordle_state_t;