void correct_answer(){ play_mp3(LANGUAGE, "CORR"); play_mp3("SYS_", "TADA"); md14_words_spelled++; stats(); md14_reset(); }
void md14_correct_answer() { play_mp3(LANGUAGE, "CORR"); speak_letters_in_word(md14_chosen_word); speak_word(md14_chosen_word); play_mp3("SYS_", "TADA"); md14_words_spelled++; md14_stats(); md14_reset(); }
/** * @brief Step through the main stages in the code. * @return Void */ void md14_main() { switch(md14_next_state) { case MD14_STATE_INTRO: lang_fileset = LANG_FILESET; mode_fileset = MODE_FILESET; play_mp3(MODE_FILESET, "WELC"); md14_next_state = MD14_STATE_LVLSEL; srand(timer_rand()); break; case MD14_STATE_LVLSEL: md14_last_dot = create_dialog("LVL3", (DOT_1 | DOT_2 | DOT_3)); if (md14_last_dot == NO_DOTS) break; switch (md14_last_dot) { case '1': play_mp3(LANGUAGE, "EASY"); strings_to_wordlist(easy, ARRAYLEN(easy), &md14_dict); break; case '2': play_mp3(LANGUAGE, "MED"); strings_to_wordlist(medium, ARRAYLEN(medium), &md14_dict); break; case '3': play_mp3(LANGUAGE, "HARD"); strings_to_wordlist(hard, ARRAYLEN(hard), &md14_dict); break; } print_words_in_list(&md14_dict); play_mp3(MODE_FILESET, "INST"); md14_next_state = MD14_STATE_GENQUES; break; case MD14_STATE_GENQUES: md14_reset(); get_next_word_in_wordlist(&md14_dict, &md14_chosen_word); log_msg("[MD14] Next word: %s\n\r", md14_chosen_word->name); md14_next_state = MD14_STATE_PROMPT; break; case MD14_STATE_PROMPT: play_mp3(LANGUAGE, "SPEL"); speak_word(md14_chosen_word); md14_next_state = MD14_STATE_INPUT; break; case MD14_STATE_INPUT: md14_cell = get_cell(); if (md14_cell == NO_DOTS) { break; } md14_cell_pattern = GET_CELL_PATTERN(md14_cell); md14_cell_control = GET_CELL_CONTROL(md14_cell); switch (md14_cell_control) { case WITH_ENTER: md14_user_cell.pattern = md14_cell_pattern; md14_next_state = MD14_STATE_CHECK; log_msg("[MD14] Checking answer\n\r"); break; case WITH_LEFT: md14_next_state = MD14_STATE_REPROMPT; break; case WITH_RIGHT: md14_next_state = MD14_STATE_GENQUES; break; case WITH_CANCEL: break; } break; case MD14_STATE_CHECK: md14_speak_inputted_cell(); get_next_cell_in_word(md14_chosen_word, &md14_curr_cell); log_msg("Target cell: %x, inputted cell: %x.\n\r", md14_curr_cell.pattern, md14_user_cell.pattern); if (cell_equals(&md14_curr_cell, &md14_user_cell)) { if (md14_chosen_word->curr_letter == md14_chosen_word->num_letters - 1) { // done md14_correct_answer(); md14_next_state = MD14_STATE_GENQUES; } else {// correct but not done play_mp3(LANGUAGE, "GOOD"); play_mp3(LANGUAGE, "NLET"); md14_curr_mistakes = 0; md14_next_state = MD14_STATE_INPUT; } } else { md14_incorrect_answer(); md14_next_state = MD14_STATE_REPROMPT; } break; case MD14_STATE_REPROMPT: if (md14_curr_mistakes >= MAX_INCORRECT_GUESS) { play_mp3(LANGUAGE, "PRSS"); char* letter_name = get_eng_letter_name_by_cell(&md14_curr_cell); play_mp3(LANGUAGE, letter_name); if (md14_curr_mistakes >= MAX_INCORRECT_GUESS + 1) play_pattern(md14_curr_cell.pattern); } else { play_mp3(LANGUAGE, "SPEL"); speak_word(md14_chosen_word); if (md14_chosen_word->curr_glyph > -1) {// not at beginning of word play_mp3(MODE_FILESET, "SPLS"); speak_letters_so_far(md14_chosen_word); play_mp3(LANGUAGE, "NLET"); } } md14_next_state = MD14_STATE_INPUT; break; default: break; } }