Skip to content

Commit

Permalink
Fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
bolknote committed Nov 9, 2023
1 parent 0d1727f commit f231185
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions helpers/hangman.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,20 @@ void hangman_input_callback(InputEvent* input_event, void* ctx) {

void hangman_choice_letter(HangmanApp* app) {
if(strchr(app->word, app->lang->letters[app->pos] + app->lang->first_letter_offset) == NULL) {
app->gallows_state++;
app->opened[app->pos] = HangmanOpenedNotFound;
if(app->opened[app->pos] != HangmanOpenedNotFound) {
app->gallows_state++;
app->opened[app->pos] = HangmanOpenedNotFound;

if(app->gallows_state >= HANGMAN_GALLOWS_MAX_STATE - 1) {
app->eog = HangmanGameLoose;
if(app->gallows_state >= HANGMAN_GALLOWS_MAX_STATE - 1) {
app->eog = HangmanGameLoose;

// Open the non-guessed letters
for(uint8_t i = 0; i < strlen(app->word); i++) {
int letter = app->word[i] - app->lang->first_letter_offset;
// Open the non-guessed letters
for(uint8_t i = 0; i < strlen(app->word); i++) {
int letter = app->word[i] - app->lang->first_letter_offset;

if(app->opened[letter] != HangmanOpenedFound) {
app->opened[letter] = HangmanOpenedNotFound;
if(app->opened[letter] != HangmanOpenedFound) {
app->opened[letter] = HangmanOpenedNotFound;
}
}
}
}
Expand Down

0 comments on commit f231185

Please sign in to comment.