Wordle game resets after 24hrs of not playing when not using daily streak
This commit is contained in:
parent
41df6c113f
commit
c43820e75d
@ -25,9 +25,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "wordle_face.h"
|
#include "wordle_face.h"
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
|
||||||
#include "watch_utility.h"
|
#include "watch_utility.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint32_t get_random(uint32_t max) {
|
static uint32_t get_random(uint32_t max) {
|
||||||
#if __EMSCRIPTEN__
|
#if __EMSCRIPTEN__
|
||||||
@ -298,6 +296,11 @@ static uint32_t get_day_unix_time(void) {
|
|||||||
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);
|
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
|
||||||
|
|
||||||
static void display_lose(wordle_state_t *state, uint8_t subsecond) {
|
static void display_lose(wordle_state_t *state, uint8_t subsecond) {
|
||||||
@ -373,9 +376,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:
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
|
||||||
state->curr_day = get_day_unix_time();
|
state->curr_day = get_day_unix_time();
|
||||||
#endif
|
|
||||||
reset_board(state);
|
reset_board(state);
|
||||||
return true;
|
return true;
|
||||||
case SCREEN_WIN:
|
case SCREEN_WIN:
|
||||||
@ -495,10 +496,15 @@ 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;
|
||||||
|
uint32_t now = get_day_unix_time();
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
#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 (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
|
#endif
|
||||||
state->using_random_guess = false;
|
state->using_random_guess = false;
|
||||||
if (is_playing(state) && state->curr_screen >= SCREEN_RESULT) {
|
if (is_playing(state) && state->curr_screen >= SCREEN_RESULT) {
|
||||||
|
@ -66,7 +66,8 @@
|
|||||||
|
|
||||||
#define WORDLE_LENGTH 5
|
#define WORDLE_LENGTH 5
|
||||||
#define WORDLE_MAX_ATTEMPTS 6
|
#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.
|
#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
|
||||||
@ -119,9 +120,9 @@ 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;
|
||||||
#if WORDLE_USE_DAILY_STREAK
|
#if WORDLE_USE_DAILY_STREAK
|
||||||
uint32_t prev_day;
|
uint32_t prev_day;
|
||||||
uint32_t curr_day;
|
|
||||||
#endif
|
#endif
|
||||||
} wordle_state_t;
|
} wordle_state_t;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user