Added continue screen
This commit is contained in:
parent
57ca74b253
commit
1868f8446a
@ -307,6 +307,13 @@ static void display_title(wordle_state_t *state) {
|
|||||||
watch_display_string("WO WordLE", 0);
|
watch_display_string("WO WordLE", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void display_continue(wordle_state_t *state) {
|
||||||
|
char buf[7];
|
||||||
|
state->curr_screen = SCREEN_CONTINUE;
|
||||||
|
sprintf(buf, "Cont %c", state->continuing ? 'y' : 'n');
|
||||||
|
watch_display_string(buf, 4);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -389,7 +396,7 @@ static void display_result(wordle_state_t *state, uint8_t subsecond) {
|
|||||||
watch_display_string(buf, 5);
|
watch_display_string(buf, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool act_on_btn(wordle_state_t *state) {
|
static bool act_on_btn(wordle_state_t *state, const uint8_t pin) {
|
||||||
switch (state->curr_screen)
|
switch (state->curr_screen)
|
||||||
{
|
{
|
||||||
case SCREEN_RESULT:
|
case SCREEN_RESULT:
|
||||||
@ -401,13 +408,15 @@ static bool act_on_btn(wordle_state_t *state) {
|
|||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
if (state->prev_day == get_day_unix_time()) {
|
if (state->prev_day == get_day_unix_time()) {
|
||||||
display_wait(state);
|
display_wait(state);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
if (state->playing)
|
if (state->playing) {
|
||||||
display_playing(state);
|
state->continuing = true;
|
||||||
|
display_continue(state);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
display_streak(state);
|
display_streak(state);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
case SCREEN_STREAK:
|
case SCREEN_STREAK:
|
||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
@ -424,6 +433,23 @@ static bool act_on_btn(wordle_state_t *state) {
|
|||||||
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;
|
||||||
|
case SCREEN_CONTINUE:
|
||||||
|
switch (pin)
|
||||||
|
{
|
||||||
|
case BTN_ALARM:
|
||||||
|
if (state->continuing)
|
||||||
|
display_playing(state);
|
||||||
|
else {
|
||||||
|
reset_board(state);
|
||||||
|
display_streak(state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BTN_LIGHT:
|
||||||
|
state->continuing = !state->continuing;
|
||||||
|
display_continue(state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
case SCREEN_WAIT:
|
case SCREEN_WAIT:
|
||||||
display_title(state);
|
display_title(state);
|
||||||
@ -514,7 +540,7 @@ void wordle_face_activate(movement_settings_t *settings, void *context) {
|
|||||||
if (state->curr_day != now) state->playing = false;
|
if (state->curr_day != now) state->playing = false;
|
||||||
#endif
|
#endif
|
||||||
state->using_random_guess = false;
|
state->using_random_guess = false;
|
||||||
if (state->playing && state->curr_screen >= SCREEN_WIN) {
|
if (state->playing && state->curr_screen >= SCREEN_RESULT) {
|
||||||
reset_incorrect_elements(state);
|
reset_incorrect_elements(state);
|
||||||
state->position = get_first_pos(state->word_elements_result);
|
state->position = get_first_pos(state->word_elements_result);
|
||||||
}
|
}
|
||||||
@ -550,7 +576,7 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_BUTTON_UP:
|
case EVENT_LIGHT_BUTTON_UP:
|
||||||
if (act_on_btn(state)) break;
|
if (act_on_btn(state, BTN_LIGHT)) break;
|
||||||
get_next_letter(state->position, state->word_elements);
|
get_next_letter(state->position, state->word_elements);
|
||||||
display_letter(state, true);
|
display_letter(state, true);
|
||||||
break;
|
break;
|
||||||
@ -560,7 +586,7 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
|
|||||||
display_letter(state, true);
|
display_letter(state, true);
|
||||||
break;
|
break;
|
||||||
case EVENT_ALARM_BUTTON_UP:
|
case EVENT_ALARM_BUTTON_UP:
|
||||||
if (act_on_btn(state)) break;
|
if (act_on_btn(state, BTN_ALARM)) break;
|
||||||
display_letter(state, true);
|
display_letter(state, true);
|
||||||
if (state->word_elements[state->position] == _num_valid_letters) break;
|
if (state->word_elements[state->position] == _num_valid_letters) break;
|
||||||
state->playing = true;
|
state->playing = true;
|
||||||
@ -586,7 +612,7 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
|
|||||||
case EVENT_ACTIVATE:
|
case EVENT_ACTIVATE:
|
||||||
break;
|
break;
|
||||||
case EVENT_TIMEOUT:
|
case EVENT_TIMEOUT:
|
||||||
if (state->curr_screen >= SCREEN_WIN)
|
if (state->curr_screen >= SCREEN_RESULT)
|
||||||
display_title(state);
|
display_title(state);
|
||||||
break;
|
break;
|
||||||
case EVENT_LOW_ENERGY_UPDATE:
|
case EVENT_LOW_ENERGY_UPDATE:
|
||||||
|
@ -89,12 +89,13 @@ typedef enum {
|
|||||||
SCREEN_PLAYING = 0,
|
SCREEN_PLAYING = 0,
|
||||||
SCREEN_TITLE,
|
SCREEN_TITLE,
|
||||||
SCREEN_STREAK,
|
SCREEN_STREAK,
|
||||||
|
SCREEN_CONTINUE,
|
||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
SCREEN_WAIT,
|
SCREEN_WAIT,
|
||||||
#endif
|
#endif
|
||||||
|
SCREEN_RESULT,
|
||||||
SCREEN_WIN,
|
SCREEN_WIN,
|
||||||
SCREEN_LOSE,
|
SCREEN_LOSE,
|
||||||
SCREEN_RESULT,
|
|
||||||
SCREEN_NO_DICT,
|
SCREEN_NO_DICT,
|
||||||
SCREEN_ALREADY_GUESSED,
|
SCREEN_ALREADY_GUESSED,
|
||||||
SCREEN_COUNT
|
SCREEN_COUNT
|
||||||
@ -108,8 +109,9 @@ typedef struct {
|
|||||||
uint8_t attempt : 4;
|
uint8_t attempt : 4;
|
||||||
uint8_t position : 3;
|
uint8_t position : 3;
|
||||||
bool playing : 1;
|
bool playing : 1;
|
||||||
uint16_t curr_answer : 15;
|
uint16_t curr_answer : 14;
|
||||||
bool using_random_guess : 1;
|
bool using_random_guess : 1;
|
||||||
|
bool continuing : 1;
|
||||||
uint8_t streak;
|
uint8_t streak;
|
||||||
WordleScreen curr_screen;
|
WordleScreen curr_screen;
|
||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user