combined two areas of code into one function
This commit is contained in:
parent
67c1089fb2
commit
4257b71562
@ -267,10 +267,12 @@ static void display_attempt(uint8_t attempt) {
|
|||||||
watch_display_string(buf, 3);
|
watch_display_string(buf, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_start_of_attempt(wordle_state_t *state) {
|
static void show_start_of_attempt(wordle_state_t *state, bool reset_all_letters) {
|
||||||
for (size_t i = 0; i < WORDLE_LENGTH; i++) {
|
if (reset_all_letters) {
|
||||||
if (state->word_elements_result[i] != WORDLE_LETTER_CORRECT)
|
for (size_t i = 0; i < WORDLE_LENGTH; i++) {
|
||||||
state->word_elements[i] = _num_valid_letters;
|
if (state->word_elements_result[i] != WORDLE_LETTER_CORRECT)
|
||||||
|
state->word_elements[i] = _num_valid_letters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
display_attempt(state->attempt);
|
display_attempt(state->attempt);
|
||||||
display_all_letters(state);
|
display_all_letters(state);
|
||||||
@ -291,7 +293,7 @@ static void reset_board(wordle_state_t *state) {
|
|||||||
state->attempt = 0;
|
state->attempt = 0;
|
||||||
watch_clear_colon();
|
watch_clear_colon();
|
||||||
watch_display_string(" ", 4);
|
watch_display_string(" ", 4);
|
||||||
show_start_of_attempt(state);
|
show_start_of_attempt(state, true);
|
||||||
watch_display_string("-", 5);
|
watch_display_string("-", 5);
|
||||||
#if __EMSCRIPTEN__
|
#if __EMSCRIPTEN__
|
||||||
printf("ANSWER: %s\r\n", _legal_words[state->curr_answer]);
|
printf("ANSWER: %s\r\n", _legal_words[state->curr_answer]);
|
||||||
@ -389,7 +391,7 @@ static bool act_on_btn(wordle_state_t *state) {
|
|||||||
switch (state->curr_screen)
|
switch (state->curr_screen)
|
||||||
{
|
{
|
||||||
case SCREEN_RESULT:
|
case SCREEN_RESULT:
|
||||||
show_start_of_attempt(state);
|
show_start_of_attempt(state, true);
|
||||||
return true;
|
return true;
|
||||||
case SCREEN_TITLE:
|
case SCREEN_TITLE:
|
||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
@ -399,7 +401,7 @@ static bool act_on_btn(wordle_state_t *state) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (state->playing)
|
if (state->playing)
|
||||||
show_start_of_attempt(state);
|
show_start_of_attempt(state, true);
|
||||||
else
|
else
|
||||||
display_streak(state);
|
display_streak(state);
|
||||||
return true;
|
return true;
|
||||||
@ -415,9 +417,7 @@ static bool act_on_btn(wordle_state_t *state) {
|
|||||||
return true;
|
return true;
|
||||||
case SCREEN_NO_DICT:
|
case SCREEN_NO_DICT:
|
||||||
case SCREEN_ALREADY_GUESSED:
|
case SCREEN_ALREADY_GUESSED:
|
||||||
state->position= state->position = get_first_pos(state->word_elements_result);
|
show_start_of_attempt(state, false);
|
||||||
display_all_letters(state);
|
|
||||||
state->curr_screen = SCREEN_PLAYING;
|
|
||||||
return true;
|
return true;
|
||||||
#if USE_DAILY_STREAK
|
#if USE_DAILY_STREAK
|
||||||
case SCREEN_WAIT:
|
case SCREEN_WAIT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user