def handle(self, handler_input): logger.info("HAN FP_SetNumberQuestionsHandler") speech_list = [] FreePlayAttr.set_attr_free_play( handler_input) # reset questions asked. num_questions = SlotUtils.get_slot_val_by_name(handler_input, 'num_questions') if num_questions is None: ms_can_set_questions = FPNumQuestions.get_ms_can_set_num_questions( ) prompt, reprompt = (FPNumQuestions.get_q_num_questions() for _ in range(2)) speech_list += Pauser.make_ms_pause_level_list( ms_can_set_questions, 2, prompt) else: FreePlayAttr.set_attr_num_questions(handler_input, num_questions) ms_confirm = ConfirmUtils.get_random_confirmation(handler_input) ms_ask_num_questions = FPNumQuestions.get_ms_ask_num_questions( handler_input) prompt = FPPrompts.get_q_fp_setup_prompt(handler_input) reprompt = FPPrompts.get_q_fp_setup_reprompt(handler_input) speech_list += Pauser.make_ms_pause_level_list( ms_confirm, ms_ask_num_questions, 2, prompt) ModeStats.translate_mode_stats_to_sesh(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN FP_WrongAnswerHandler") speech_list = [] player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats(handler_input, correct=False, player_obj=player_obj) WrongAnswer.record_wrong_question(handler_input) ms_incorrect = IncorrectAnsUtils.get_buzz_and_incorrect() ms_retry_question = AllQuestionIntros.get_retry_question(handler_input) reprompt = GenQuestions.get_same_question(handler_input) speech_list += Pauser.make_ms_pause_level_list(ms_incorrect, 1, ms_retry_question) SessionStats.update_consecutive_correct(handler_input, correct=False) ModeStats.update_mode_stats(handler_input, correct=False) logger.debug(speech_list) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN FP_CorrectAnswerHandler") speech_list = [] player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats(handler_input, correct=True, player_obj=player_obj) ms_congrats = CongratUtils.get_answer_congrats(handler_input, player_obj=player_obj) ms_question = FPQuestions.get_question(handler_input) reprompt = FPQuestions.get_rephrased_question(handler_input) logger.debug(ms_congrats) if ms_congrats != "": speech_list += Pauser.make_ms_pause_level_list( ms_congrats, 1, ms_question) else: speech_list.append(ms_question) SessionStats.update_consecutive_correct(handler_input, correct=True) ModeStats.update_mode_stats(handler_input, correct=True) logger.debug(speech_list) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN SM_CorrectQuestionHandler") speech_list = [] player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats(handler_input, correct = True, player_obj= player_obj) SM_Attr.increment_sm_upper(handler_input) ms_congrats = CongratUtils.get_answer_congrats( handler_input, player_obj= player_obj, survival_mode=True) logger.debug(ms_congrats) ms_question = SMQuestions.get_question( handler_input, first_question= False, player_obj= player_obj) reprompt = GenQuestions.get_same_question(handler_input) if len(ms_congrats): sm_pause = Pauser.get_sm_pause_length(handler_input) speech_list += Pauser.make_ms_pause_level_list(ms_congrats, sm_pause) speech_list.append( ms_question) SessionStats.update_consecutive_correct(handler_input, True) ModeStats.update_mode_stats(handler_input, True) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return ( handler_input.response_builder .speak(speech) .ask(reprompt) .set_card( SimpleCard( card_title, card_text)) .response)
def handle(self, handler_input): logger.info("HAN CP_CorrectAnswerHandler") attr = handler_input.attributes_manager.session_attributes speech_list = [] practice_type = attr['practice_type'] if practice_type == custom_practice.data.PRACT_TYPES[0]: CP_Attr.remove_question_from_incorrect_questions( handler_input) ## Before updating last question CP_Attr.update_last_question_attr(handler_input, correct=True) player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats(handler_input, correct=True, player_obj=player_obj) ms_congrats = CongratUtils.get_answer_congrats(handler_input, player_obj=player_obj) ms_question = CP_Questions.get_question(handler_input, player_object=player_obj, practice_type=practice_type, first_question=False) reprompt = GenQuestions.get_same_question(handler_input) speech_list = (ms_congrats, 1, ms_question) SessionStats.update_consecutive_correct(handler_input, True) ModeStats.update_mode_stats(handler_input, True) PlayerDict.save_player_obj(handler_input, player_obj) speech = get_linear_nlg(speech_list) reprompt = GenQuestions.get_same_question(handler_input) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN CP_WrongAnswerHandler") speech_list = [] player_obj = PlayerDict.load_player_obj(handler_input) CP_Attr.update_last_question_attr(handler_input, correct=False) UserStats.update_player_stats(handler_input, correct=False, player_obj=player_obj) ms_wrong = IncorrectAnsUtils.get_ms_incorrect() question = GenQuestions.get_same_question(handler_input) reprompt = question speech_list = ( ms_wrong, 1, question, ) SessionStats.update_consecutive_correct(handler_input, correct=False) ModeStats.update_mode_stats(handler_input, correct=False) WrongAnswer.record_wrong_question(handler_input) PlayerDict.save_player_obj(handler_input, player_obj) speech = get_linear_nlg(speech_list) reprompt = GenQuestions.get_same_question(handler_input) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN FP_AnsweredRequestedQuestionsHandler") attr = handler_input.attributes_manager.session_attributes speech_list = [] correct = QuestionChecker.check_answer(handler_input) UserStats.update_player_stats(handler_input, correct) ms_congrats = CongratUtils.get_player_congrats(handler_input, 2) num_questions = attr.get('num_questions', '') ms_answered_all_questions = FPSpeech.get_ms_answered_all_questions( num_questions) prompt, reprompt = (HelpUtils.get_q_what_todo() for _ in range(2)) prompt = CardFuncs.format_prompt(prompt) speech_list += Pauser.make_ms_pause_level_list( ms_congrats, 1, ms_answered_all_questions, 3, prompt) SessionStats.update_consecutive_correct(handler_input, correct) ModeStats.update_mode_stats(handler_input, correct) ModeStats.translate_mode_stats_to_sesh(handler_input) FreePlayAttr.set_attr_end_fp(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN FP_SetTimesTablesHandler") attr = handler_input.attributes_manager.session_attributes speech_list = [] ## Get & Set slots lower_table, upper_table, tables_query = ( FreePlayAttr.get_times_table_input_slots(handler_input)) ## Logic checks retry_query = attr.get('inform_query_tables_format', False) tables_provided = FreePlayLogic.check_tables_provided( lower_table, upper_table, tables_query) if tables_provided: FreePlayAttr.set_attr_free_play(handler_input) FreePlayAttr.set_attr_times_tables(handler_input, lower_table, upper_table, tables_query) if retry_query: ms_potential_mistake = FPTimesTables.get_ms_potential_mistake_parsing_query( ) speech_list += Pauser.make_ms_pause_level_list( ms_potential_mistake, 2) else: ms_confirm = ConfirmUtils.get_random_confirmation( handler_input) speech_list.append(ms_confirm) ms_using_tables = (FPTimesTables.get_ms_using_tables_from_input( lower_table, upper_table, tables_query)) speech_list += Pauser.make_ms_pause_level_list(ms_using_tables, 2) if retry_query: ms_retry_query = FPTimesTables.get_ms_can_retry_query_format() speech_list += Pauser.make_ms_pause_level_list( ms_retry_query, 3.5) FreePlayAttr.reset_attr_query_format(handler_input) prompt = FPPrompts.get_q_fp_setup_prompt(handler_input) reprompt = FPPrompts.get_q_fp_setup_reprompt(handler_input) speech_list.append(prompt) ## Ask for times_tables slots else: q_times_tables, reprompt = ( FPTimesTables.get_q_times_tables_input() for _ in range(2)) q_times_tables = CardFuncs.format_prompt(q_times_tables) speech_list.append(q_times_tables) reprompt = LastPrompt.get_last_prompt(handler_input) ModeStats.translate_mode_stats_to_sesh(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN SM_WrongAnswerHandler") player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats( handler_input, correct = False, player_obj= player_obj) WrongAnswer.record_wrong_question(handler_input) ms_incorrect = IncorrectAnsUtils.get_buzz_and_incorrect() ms_correct_ans = GetAnswerSpeech.get_ms_answer(handler_input) ms_score = SMEndGame.get_ms_game_score(handler_input) ms_congrats = CongratUtils.get_player_congrats(handler_input, 1) ms_results = SMEndGame.get_ms_score_results( handler_input, player_obj= player_obj) ms_thanks = get_ms_thanks(handler_input, mode = True, excite=True) prompt, reprompt = ( HelpUtils.get_q_what_todo() for _ in range(2)) speech_list = ( ms_incorrect, 1, ms_correct_ans, 2, ms_congrats, 0.75, ms_score, 1.25, ms_results, 1.75, ms_thanks, 4.5, prompt, ) SM_Attr.log_stats(handler_input) SessionStats.update_consecutive_correct(handler_input, correct= False) ModeStats.update_mode_stats(handler_input, correct= False) UserStats.update_player_sm_stats(handler_input, player_obj= player_obj) #before translating mode stats SM_Attr.set_attr_end_survival_mode(handler_input) ModeStats.translate_mode_stats_to_sesh(handler_input) speech = get_linear_nlg(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return ( handler_input.response_builder .speak(speech) .ask(reprompt) .set_card( SimpleCard( card_title, card_text)) .response)
def update_player_fp_stats(handler_input, player_obj: object) -> None: """Updates player statistics for free play mode.""" attr = handler_input.attributes_manager.session_attributes mode = attr.get('mode', None) correct, _ = ModeStats.get_mode_stats(handler_input, mode = mode) return None
def handle(self, handler_input): logger.info("HAN SC_FinishedChallengeHandler") speech_list = [] SC_Attr.save_end_time(handler_input) sc_score_time = SC_Attr.get_sc_total_time(handler_input) player_obj = PlayerDict.load_player_obj(handler_input) SessionStats.update_consecutive_correct(handler_input, correct=True) ModeStats.update_mode_stats(handler_input, correct=True) UserStats.update_player_stats(handler_input, correct=True, player_obj=player_obj) ms_congrats = CongratUtils.get_player_congrats(handler_input, 2) ms_complete_time = SC_EndGame.get_ms_game_score( handler_input, sc_score_time) ms_score_results = SC_EndGame.get_ms_score_results( handler_input, sc_score_time=sc_score_time, player_obj=player_obj) ms_thanks = get_ms_thanks(handler_input, mode=True, excite=True) prompt, reprompt = (HelpUtils.get_q_what_todo() for _ in range(2)) speech_list = ( ms_congrats, 1, ms_complete_time, 1.5, ms_score_results, 1.75, ms_thanks, 4, prompt, ) SC_Attr.log_sc_stats(handler_input) ModeStats.translate_mode_stats_to_sesh(handler_input) UserStats.update_player_sc_stats(handler_input, sc_score_time=sc_score_time, player_obj=player_obj) SC_Attr.set_attr_end_sc(handler_input) PlayerDict.save_player_obj(handler_input, player_obj) speech = get_linear_nlg(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def update_player_cp_stats( handler_input, player_obj: object = None) -> None: """Updates the player's Custom practice Statistics.""" correct, incorrect = ModeStats.get_mode_stats(handler_input, 'custom') if correct > 3: player_obj.cp_plays += 1 return None
def handle(self, handler_input): logger.info("HAN FP_AddTimesTablesHandler") attr = handler_input.attributes_manager.session_attributes speech_list = [] lower_table, upper_table, tables_query = ( FreePlayAttr.get_times_table_input_slots(handler_input)) retry_query = attr.get('inform_query_tables_format', False) if not tables_query: ms_can_add = FPTimesTables.get_ms_can_add_tables() speech_list += Pauser.make_ms_pause_level_list(ms_can_add, 2.5) else: FreePlayAttr.add_to_attr_times_tables(handler_input, lower_table, upper_table, tables_query) if retry_query: ms_potential_mistake = FPTimesTables.get_ms_potential_mistake_parsing_query( ) speech_list += Pauser.make_ms_pause_level_list( ms_potential_mistake, 2) ms_added_tables = FPTimesTables.get_ms_added_tables(tables_query) speech_list += Pauser.make_ms_pause_level_list( ms_added_tables, 1.5) if retry_query: ms_retry_query = FPTimesTables.get_ms_can_retry_query_format() speech_list += Pauser.make_ms_pause_level_list( ms_retry_query, 3.5) FreePlayAttr.reset_attr_query_format(handler_input) ## May like to add only if tables query?? prompt = FPPrompts.get_q_fp_setup_prompt(handler_input) reprompt = FPPrompts.get_q_fp_setup_reprompt(handler_input) speech_list.append(prompt) ModeStats.translate_mode_stats_to_sesh(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN SC_CorrectAnswerHandler") ## TODO: Check sc attr and if anything needs to be incremented?? player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats(handler_input, correct=True, player_obj=player_obj) question = SC_Questions.get_question(handler_input) reprompt = question SessionStats.update_consecutive_correct(handler_input, correct=True) ModeStats.update_mode_stats(handler_input, correct=True) speech = question card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def get_ms_game_score(handler_input) -> str: """Returns a message with the user's Survival Mode score.""" attr = handler_input.attributes_manager.session_attributes mode = attr.get('mode', None) correct, _ = ModeStats.get_mode_stats(handler_input, mode= mode) ms_problems_correct = random.choice( survival_mode.data.MT_PROBLEM_SCORE).format(correct) return MW_EXCITED_LOW.format( ms_problems_correct)
def handle(self, handler_input): speech_list = [] ms_confirm = ConfirmUtils.get_random_confirmation(handler_input) prompt, reprompt = (HelpUtils.get_q_what_todo() for _ in range(2)) speech_list += Pauser.make_ms_pause_level_list(ms_confirm, 2, prompt) ModeStats.translate_mode_stats_to_sesh(handler_input) ## Set end all attr FreePlayAttr.set_attr_end_fp(handler_input) SM_Attr.set_attr_end_survival_mode(handler_input) SC_Attr.set_attr_end_sc(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN SM_StartHandler") speech_list = [] SM_Attr.set_attr_start_survival_mode(handler_input) ModeStats.translate_mode_stats_to_sesh(handler_input) ms_welcome = SM_WelcomeUtils.get_ms_welcome(handler_input) ms_question = SMQuestions.get_question(handler_input, first_question= True) reprompt = GenQuestions.get_same_question(handler_input) speech_list += Pauser.make_ms_pause_level_list( ms_welcome, 2, ms_question) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return ( handler_input.response_builder .speak( speech) .ask( reprompt) .set_card( SimpleCard( card_title, card_text)) .response)
def handle(self, handler_input): logger.info("HAN FP_SetTableBoundsHandler") speech_list = [] lower_bound, upper_bound = FreePlayAttr.get_table_bound_slots( handler_input) FreePlayAttr.set_table_bounds(handler_input, lower_bound, upper_bound) bounds_provided = FreePlayLogic.check_table_bounds_provided( lower_bound, upper_bound) if bounds_provided: confirm = ConfirmUtils.get_random_confirmation(handler_input) ms_adjusted_table_bounds = FPUpperLowerBounds.get_ms_set_table_bounds( lower_bound, upper_bound) prompt = FPPrompts.get_q_fp_setup_prompt(handler_input) reprompt = FPPrompts.get_q_fp_setup_reprompt(handler_input) # QuestionAttr.increment_questions_answered(handler_input, increase=False) ## New question, but not counted as answered. speech_list += Pauser.make_ms_pause_level_list( confirm, 1, ms_adjusted_table_bounds, 2, prompt) else: ms_can_change_bounds = FPUpperLowerBounds.get_ms_can_change_table_bounds( ) prompt, reprompt = (FPUpperLowerBounds.get_q_change_bounds() for _ in range(2)) speech_list += Pauser.make_ms_pause_level_list( ms_can_change_bounds, 2.5, prompt) ModeStats.translate_mode_stats_to_sesh(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def update_player_sm_stats(handler_input, player_obj: object = None) -> None: """Updates the player's Survival Mode stats.""" attr = handler_input.attributes_manager.session_attributes mode = attr.get('mode', None) correct, _ = ModeStats.get_mode_stats(handler_input, mode= mode) if not player_obj: player_obj = PlayerDict.load_player_obj(handler_input) if correct > player_obj.get_sm_high_score(): player_obj.set_sm_high_score(correct) player_obj.update_sm_records(correct) player_obj.sm_plays += 1 PlayerDict.save_player_obj(handler_input, player_obj) return None
def get_ms_score_results(handler_input, player_obj: object = None) -> str: """Returns message about the user's relative SM score.""" attr = handler_input.attributes_manager.session_attributes mode = attr.get('mode', None) if not player_obj: player_obj = PlayerDict.load_player_obj(handler_input) sm_high_score = player_obj.get_sm_high_score() sm_score, _ = ModeStats.get_mode_stats(handler_input, mode= mode) if SM_Attr.check_sm_highscore(sm_high_score, sm_score): if SM_Attr.check_first_highscore(sm_high_score, sm_score): return SMEndGame.get_ms_first_highscore(sm_score) return SMEndGame.get_ms_new_highscore(sm_score, sm_high_score) elif SM_Attr.check_sm_tie_highscore(sm_high_score, sm_score): return SMEndGame.get_ms_tied_highscore(sm_high_score) else: return SMEndGame.get_ms_relative_attempt_success( handler_input, sm_score, player_obj= player_obj)
def update_player_mode_statistics(handler_input, player_obj: object) -> None: """Updates relevant mode statistics.""" attr = handler_input.attributes_manager.session_attributes mode = attr.get('mode', None) if mode: correct, _ = ModeStats.get_mode_stats(handler_input, mode) else: correct = 0 MODE_FUNC_DICT = { 'free_play': UserStats.update_player_fp_stats, 'custom': UserStats.update_player_cp_stats, 'speed': UserStats.update_player_sc_stats, 'survival': UserStats.update_player_sm_stats, } update_stats_func = MODE_FUNC_DICT.get(mode, None) log_all(update_stats_func, correct) if (update_stats_func) and (correct > 4): update_stats_func(handler_input, player_obj) return None
def handle(self, handler_input): logger.info("HAN FP_StartHandler") attr = handler_input.attributes_manager.session_attributes speech_list = [] ## Set attr & get slots FreePlayAttr.set_attr_free_play(handler_input) ## Get table_input to start game. lower_table, upper_table, tables_query = ( FreePlayAttr.get_times_table_input_slots(handler_input)) FreePlayAttr.set_attr_times_tables(handler_input, lower_table, upper_table, tables_query) ## Logic check retry_query = attr.get('inform_query_tables_format', False) tables_provided = FreePlayLogic.check_tables_provided( lower_table, upper_table, tables_query) tables_exist = FreePlayLogic.check_tables_exist(handler_input) log_all(retry_query, tables_exist) ## Confirmation if tables_provided or tables_exist: if retry_query: ms_potential_mistake = FPTimesTables.get_ms_potential_mistake_parsing_query( ) speech_list += Pauser.make_ms_pause_level_list( ms_potential_mistake, 2) else: ms_confirm = ConfirmUtils.get_confirmation(punct=True) speech_list += Pauser.make_ms_pause_level_list(ms_confirm, 1) if tables_provided: ms_using_tables = ( FPTimesTables.get_ms_using_tables_from_input( lower_table, upper_table, tables_query)) elif tables_exist: ms_using_tables = None # Create method to use existing tables. speech_list += Pauser.make_ms_pause_level_list(ms_using_tables, 2) if retry_query: ms_retry_query = FPTimesTables.get_ms_can_retry_query_format() speech_list += Pauser.make_ms_pause_level_list( ms_retry_query, 3.5) FreePlayAttr.reset_attr_query_format(handler_input) ms_first_problem = FPQuestions.get_question(handler_input, first_question=True) speech_list.append(ms_first_problem) reprompt = FPQuestions.get_rephrased_question(handler_input) if not tables_provided: ms_welcome = FPSpeech.get_ms_welcome(handler_input) q_times_tables, reprompt = ( FPTimesTables.get_q_times_tables_input() for _ in range(2)) q_times_tables = CardFuncs.format_prompt(q_times_tables) speech_list += Pauser.make_ms_pause_level_list( ms_welcome, 1.5, q_times_tables) ModeStats.translate_mode_stats_to_sesh(handler_input) speech = ' '.join(speech_list) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)
def handle(self, handler_input): logger.info("HAN CP_NextPracticeHandler") attr = handler_input.attributes_manager.session_attributes speech_list = [] player_obj = PlayerDict.load_player_obj(handler_input) UserStats.update_player_stats(handler_input, correct=True, player_obj=player_obj) CP_Attr.set_attr_new_practice(handler_input) CP_Attr.set_tbl_mean_err_list_attr(handler_input, player_obj) practice_type = attr['practice_type'] ms_end_pract_type = CP_PractEnd.get_ms_practice_type_end( handler_input, practice_type=practice_type) if practice_type == custom_practice.data.PRACT_TYPES[0]: CP_Attr.remove_question_from_incorrect_questions(handler_input) ms_congrats = CongratUtils.get_player_congrats(handler_input) if practice_type != custom_practice.data.PRACT_TYPES[-1]: practice_type = CP_PracticeType.get_practice_type( handler_input, allow_incorrect_problems=False) CP_Attr.save_practice_type(handler_input, practice_type) CP_Attr.set_pract_type_attr(handler_input, player_obj, practice_type) CP_Attr.update_last_question_attr(handler_input, correct=True) ms_practice_intro = CP_PractIntro.get_ms_practice_type_intro( handler_input, practice_type=practice_type) question = CP_Questions.get_question(handler_input, player_obj, practice_type, first_question=True) reprompt = GenQuestions.get_same_question(handler_input) speech_list = ( ms_congrats, 0.5, ms_end_pract_type, 2.5, ms_practice_intro, 2, question, ) else: UserStats.update_player_cp_stats(handler_input, player_obj) prompt, reprompt = (HelpUtils.get_q_what_todo() for _ in range(2)) speech_list = (ms_congrats, 0.5, ms_end_pract_type, 2, prompt) SessionStats.update_consecutive_correct(handler_input, True) ModeStats.update_mode_stats(handler_input, True) PlayerDict.save_player_obj(handler_input, player_obj) speech = get_linear_nlg(speech_list) reprompt = GenQuestions.get_same_question(handler_input) card_title, card_text = CardFuncs.get_card_info(handler_input, speech) return (handler_input.response_builder.speak(speech).ask( reprompt).set_card(SimpleCard(card_title, card_text)).response)