void stats(){ play_mp3(MODE_FILESET, "STS1"); // "You have spelled" play_number(md14_words_spelled); // # of words if (md14_total_mistakes == 0) { if (md14_words_spelled == 1) play_mp3(MODE_FILESET,"WORD"); // word. [if 1 word, 0 mistakes] else play_mp3(MODE_FILESET,"WRDS"); // words. [if !1 word, 0 mistakes] } else { if (md14_words_spelled == 1) play_mp3(MODE_FILESET, "STS2"); // "word, and have made" [if 1 word, >0 mistakes] else play_mp3(MODE_FILESET, "STS3"); // "words, and have made" [if >1 word, >0 mistakes] play_number(md14_total_mistakes); // # of md15_curr_mistakes if (md14_total_mistakes == 1) play_mp3(MODE_FILESET, "STS4"); // "mistake" [if 1 mistake] else play_mp3(MODE_FILESET, "STS5"); // "mistakes" [if >1 mistakes] } }
void mode_14_play_stats(){ if (score == 0) return; play_feedback(MP3_YOU_HAVE_SPELLED); play_number(score); if (mistakes == 0) { if (score == 1) play_feedback(MP3_WORD); else play_feedback(MP3_WORDS); } else { if (score == 1) play_feedback(MP3_WORD_AND_HAVE_MADE); else play_feedback(MP3_WORDS_AND_HAVE_MADE); play_number(mistakes); if (mistakes == 1) play_feedback(MP3_MISTAKE); else play_feedback(MP3_MISTAKES); } }
/* * @brief Step through the main stages in the code. * @return Void */ void mode_5_main(void) { switch(current_state) { case INITIAL: /* if (!done_rd_dict) { log_msg("Reading dictionary file..."); play_direction(MP3_PLEASE_WAIT) init_read_dict((unsigned char *)"wordsEn.txt"); while (!done_rd_dict) read_dict_file(); } */ play_welcome(); current_state = REQUEST_QUESTION; break; case REQUEST_QUESTION: if (got_input) { got_input = false; current_state = GENERATE_QUESTION; } break; case GENERATE_QUESTION: if (cell == 0) { // if return was entered twice mode_5_chosen_word[input_word_index] = '\0'; // if (bin_srch_dict((unsigned char *)mode_5_chosen_word)) { // valid word; switch to player 2 // @TODO "valid word, please hand device to player 2 and press enter when ready" // play_mode_audio(MP3_VALID_WORD_PASS_DEVICE); input_word_index = 0; play_feedback(MP3_YOUR_WORD_IS); play_string(mode_5_chosen_word, strlen(mode_5_chosen_word)); play_feedback(MP3_PASS_DEVICE_PRESS_ENTER); current_state = SWITCH_USERS; /* } else { // invalid word; clear variables and try again play_feedback(MP3_WORD_NOT_FOUND); mode_5_reset(); current_state = REQUEST_QUESTION; } */ } else if (mode_5_valid_letter(cell)) { // letter valid; word not complete log_msg("Letter %c entered.", entered_letter); char letter[2] = {entered_letter, '\0'}; play_lang_audio(letter); // reset because too many letters were input if (input_word_index == MAX_WORD_LENGTH) { log_msg("Too many letters inputted!"); play_feedback(MP3_TOO_LONG); mode_5_reset(); current_state = REQUEST_QUESTION; break; } mode_5_chosen_word[input_word_index] = entered_letter; // add letter to chosen_word input_word_index++; current_state = REQUEST_QUESTION; } else { // invalid letter play_feedback(MP3_INVALID_PATTERN); current_state = REQUEST_QUESTION; } break; case SWITCH_USERS: if (got_input) { got_input = false; current_state = PROMPT; } break; case PROMPT: log_msg("Entering ask for guess state."); play_direction(MP3_PLAYER_2); play_feedback(MP3_YOUR_WORD_IS_NOW); play_string(input_word, strlen(mode_5_chosen_word)); play_direction(MP3_GUESS_A_LETTER); current_state = GET_INPUT; break; case GET_INPUT: if (got_input) { got_input = false; current_state = PROCESS_ANSWER; } break; case PROCESS_ANSWER: log_msg("Entering checkans state."); if (cell == 0) // nothing entered: repeat word current_state = GAME_OVER; else if (mode_5_valid_letter(cell)) { // valid letter: read aloud char buff[7]; sprintf(buff, "%c", entered_letter); play_lang_audio(buff); //@todo fix this current_state = CHECK_ANSWER; } else { play_feedback(MP3_INVALID_PATTERN); mistakes++; current_state = GAME_OVER; } break; case CHECK_ANSWER: log_msg("Entering check match state."); if (mode_5_place_letter()) // letters is in word; fn places it play_feedback(MP3_YES); else { play_feedback(MP3_NO); if (!mode_5_is_past_mistake(entered_letter)) { mistake_pool[mistakes] = entered_letter; mistakes++; } else play_feedback(MP3_YOU_HAVE_MADE_THE_SAME_MISTAKE); } current_state = GAME_OVER; break; case GAME_OVER: log_msg("Entering evaluate game state."); if (!strncmp(input_word, mode_5_chosen_word, strlen(mode_5_chosen_word))) { play_feedback(MP3_YOU_HAVE_GUESSED_THE_WORD); play_tada(); current_state = INITIAL; } else if (mistakes == max_mistakes) { play_feedback(MP3_7_MISTAKES_YOU_MISSED); play_string(mode_5_chosen_word, strlen(mode_5_chosen_word)); current_state = INITIAL; } else { if (mistakes > 0) { play_feedback(MP3_YOU_HAVE); play_number(max_mistakes - mistakes); if (max_mistakes - mistakes == 1) play_feedback(MP3_MISTAKE_REMAINING); else play_feedback(MP3_MISTAKES_REMAINING); } current_state = PROMPT; } break; default: log_msg("Invalid state_t %d", current_state); quit_mode(); break; } }