def get_ms_help_overview() -> str:
        """Returns help message for overview of skill."""
        ms_help_overview = get_linear_nlg(helper.data.MT_HELP_OVERVIEW)
        ms_skill_acts = HelpUtils.get_skill_acts()

        speech_list = (ms_help_overview, 0.75, ms_skill_acts, 2.25,
                       act_descriptions.data.MS_START_OR_ASK)
        return get_linear_nlg(speech_list)
    def get_ms_can_add_tables() -> str:
        """Returns message that can add tables."""
        ms_can_add_tables = get_linear_nlg(
            free_play.data.MMT_CAN_ADD_TIMES_TABLES)
        ms_add_table_example = FPTimesTables.get_ms_add_table_example()

        speech_list = (ms_can_add_tables, 2, ms_add_table_example)
        return get_linear_nlg(speech_list)
    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 get_question(handler_input,
                     first_question: bool = False,
                     player_obj: object = None) -> str:
        """Returns a question for survival mode."""
        if not first_question:
            QuestionAttr.increment_questions_answered(handler_input)

        ## Get new question
        flag_get_new_question = True
        while flag_get_new_question:
            new_question = SMQuestions.get_sampled_num(handler_input)

            if not GenQuestions.check_same_question(handler_input,
                                                    new_question):
                flag_get_new_question = False

        ## Save question
        QuestionAttr.save_question(handler_input, new_question)

        ## Messages
        ms_question_intro = SMQuestions.get_ms_question_intro(
            handler_input,
            first_question=first_question,
            player_obj=player_obj)
        ms_question = GenQuestions.format_question(new_question)

        speech_list = (ms_question_intro, ms_question)
        return get_linear_nlg(speech_list)
    def get_ms_average_score_welcome(player_obj: object) -> str:
        """Returns welcome message telling the player's average time."""

        average_records = None
        for difficulty in speed_challenge.data.SC_DIFFICULTIES:
            average_records = player_obj.get_sc_average_records(difficulty)
            if average_records is not None:
                break

        if (difficulty is None) or (average_records is None):
            log_all(difficulty, average_records, log_level=40)
            logger.error(
                "get_ms_high_score_welcome: Found no difficulty or average_records."
            )
            return SC_WelcomeUtils.get_ms_short_welcome()

        avg_score = int(mean(average_records))
        avg_score = SC_EndGame.format_score_as_minutes_seconds(avg_score)

        ms_average_score = random.choice(
            speed_challenge.data.MT_AVERAGE_SCORE).format(
                difficulty, avg_score)
        ms_beat_it = random.choice(speed_challenge.data.MT_BEAT_IT)

        speech_list = (ms_average_score, 1, ms_beat_it)
        return get_linear_nlg(speech_list)
Esempio n. 6
0
 def get_ms_overall_act_descript() -> str:
     """Returns description of overall activities.
     
     Triggered if activity slot is not resolved."""
     master_ms_tuple = data.MMT_GEN_DESCRIPT
     ms_gen_descript = get_linear_nlg(master_ms_tuple)
     return ms_gen_descript
    def get_ms_use_problems_start() -> str:
        """Returns initial message about what problems to use.

        e.g.,
            "I'll ask questions from."
        """
        return get_linear_nlg(free_play.data.MMT_USE_PROBLEMS_START)
    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 get_ms_need_more_data(questions_answered: int) -> str:
     """Returns message that user needs to answer more questions before playing."""
     ms_answered_so_far = custom_practice.data.MS_ANSWERED_Q_SO_FAR.format(
         questions_answered)
     speech_list = (custom_practice.data.MS_MORE_DATA, 2,
                    ms_answered_so_far, 1,
                    custom_practice.data.MS_COME_BACK_AFTER)
     return get_linear_nlg(speech_list)
    def get_ms_added_tables(tables_query: list) -> str:
        """Confirms message that added tables to message list."""
        ms_tables = 'tables' if len(tables_query) > 1 else 'table'
        ms_added_tables = get_str_from_list(tables_query, punct=False)

        speech_list = (free_play.data.MT_INCLUDING_TABLES, ms_added_tables,
                       ms_tables, free_play.data.MT_TO_PRACTICE)
        return get_linear_nlg(speech_list)
Esempio n. 11
0
 def get_ms_can_change_table_bounds() -> str:
     """Returns message that user can change the lower & upper bound of a table."""
     speech_list = [
         free_play.data.MT_CAN,
         free_play.data.MS_CHANGE_UPPER_LOW_BOUNDS,
         free_play.data.MT_QUESTIONS,
         ]
     return get_linear_nlg( speech_list)
Esempio n. 12
0
    def get_ms_practice_new_tables(handler_input) -> str:
        """Returns message that going to practice new tables outside comfort range."""
        speech_list = list(custom_practice.data.MTT_NEW_TABLES)

        ms_congrats = CongratUtils.get_player_congrats(handler_input, 1)
        speech_list.insert(0, ms_congrats)

        speech_list += CP_PractIntro.get_ms_num_in_row_to_complete()
        return get_linear_nlg(speech_list)
Esempio n. 13
0
 def get_ms_tied_highscore(sc_score_time: int) -> str:
     """Returns message for new highscore for speed challenge difficulty."""
     score_time_format = SC_EndGame.format_score_as_minutes_seconds(
         sc_score_time)
     ms_tied_hs = random.choice(
         speed_challenge.data.MT_TIE_HS).format(score_time_format)
     ms_close_one = random.choice(speed_challenge.data.MT_TIE_HS_PART_2)
     return MW_EXCITED_LOW.format(
         get_linear_nlg([ms_tied_hs, 0.5, ms_close_one]))
Esempio n. 14
0
    def handle(self, handler_input):
        logger.info("HAN    ModeStatsHandler")
        attr = handler_input.attributes_manager.session_attributes
        speech_list = []
        player_obj = PlayerDict.load_player_obj(handler_input)

        mode = attr.get('mode', None)
        activity = SlotUtils.get_resolved_value(handler_input, 'activity')
        activity = activity if activity else mode
        difficulty = True

        if activity == 'survival':
            speech_list += ModeSpeech.get_ms_sm_stats(player_obj, activity)

        elif activity == 'speed':
            difficulty = SlotUtils.get_resolved_value(handler_input,
                                                      'difficulty')
            sc_difficulty = difficulty if difficulty else attr.get(
                'sc_difficulty', None)

            if (difficulty in speed_challenge.data.SC_DIFFICULTIES):
                speech_list += ModeSpeech.get_ms_sc_stats(
                    player_obj, sc_difficulty, activity)
            else:
                reprompt = ModeSpeech.get_ms_sc_what_difficulty()
                speech_list += reprompt
                reprompt = get_linear_nlg(reprompt)

        else:
            ms_can_tell_record = ModeSpeech.get_ms_can_tell_record()
            ms_example_saying = ModeSpeech.get_example_hear_records()
            speech_list = [ms_can_tell_record, 2, ms_example_saying]

            reprompt = HelpUtils.get_q_what_todo()

        if activity in ('survival', 'speed') and (difficulty):
            prompt, reprompt = (LastPrompt.get_last_prompt(handler_input)
                                for _ in range(2))
            speech_list += Pauser.make_ms_pause_level_list(3, prompt)

        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 get_ms_intro_question_num(handler_input) -> str:
        """Returns message with the question number."""
        attr = handler_input.attributes_manager.session_attributes
        speech_list = []
        ms_num_question = get_linear_nlg(mult_questions.data.MMT_PROBLEM_NUM)
        questions_answered = attr['questions_answered'] + 1

        speech_list.append( ms_num_question)
        speech_list.append( str(questions_answered) + '.')
        return ' '.join(speech_list)
 def get_ms_answered_all_questions(num_questions: int) -> str:
     """Returns message that answered all requested questions."""
     ms_num = free_play.data.MS_NUM.format(num_questions)
     speech_list = (
         free_play.data.MT_DET,
         ms_num,
         free_play.data.MT_PROBLEM_SYNS,
         free_play.data.MT_REQUESTED,
     )
     return get_linear_nlg(speech_list)
Esempio n. 17
0
    def get_ms_num_questions_answered(handler_input) -> str:
        """Returns message how many questions the user answered."""
        attr = handler_input.attributes_manager.session_attributes
        questions_answered = attr.get('questions_answered', 0)

        ms_answered_qs = get_linear_nlg( free_play.data.MMT_ANSWERED_QUESTIONS)
        ms_answered_qs = ms_answered_qs.format( questions_answered)
        speech_list = (
            ms_answered_qs,
        )
        return ''.join(speech_list)
Esempio n. 18
0
 def get_ms_ask_num_questions(handler_input) -> str:
     """Returns message how many questions will ask user."""
     attr = handler_input.attributes_manager.session_attributes
     num_questions = attr['num_questions']
     
     speech_list = list( free_play.data.MMT_SET_QUESTIONS)
     speech_list.append( num_questions)
     speech_list.append( random.choice(
         free_play.data.MT_QUESTIONS))
         
     return get_linear_nlg(speech_list)
    def get_ms_use_existing_tables(handler_input) -> str:
        """Returns message that will use existing tables.

        Incase the user sets the parameters before entering Free Play mode."""
        attr = handler_input.attributes_manager.session_attributes

        times_tables = attr['times_tables']
        times_tables_to_use = get_str_from_list(times_tables)

        speech_list = (free_play.data.MTT_EXISTING_TABLES, times_tables_to_use)
        return get_linear_nlg(speech_list)
Esempio n. 20
0
    def get_ms_new_highscore(sm_score: int, sm_high_score: int) -> str:
        """Returns message that new highscore for survival mode."""
        speech_list = list(survival_mode.data.MTT_BEAT_OLD_HS)

        speech_list.append( str(sm_high_score))
        speech_list.append( random.choice(
            survival_mode.data.MT_QUESTION_SYN))
        
        ms_new_sm_high_score = get_linear_nlg(speech_list)

        return MW_EXCITED_MED.format(ms_new_sm_high_score)
 def get_ms_can_retry_query_format() -> str:
     """Returns message that can re-input query tables."""
     speech_list = (
         free_play.data.MMT_WRONG,
         1.5,
         "For example,",
         get_ms_try_saying(),
         0.75,
         FPTimesTables.get_example_tables_query(),
     )
     return get_linear_nlg(speech_list)
    def get_ms_use_query_times_tables(times_tables: list) -> str:
        """Returns message that will use queried times tables."""
        ms_use_problems = FPTimesTables.get_ms_use_problems_start()
        times_tables = get_str_from_list(times_tables)

        speech_list = (
            ms_use_problems,
            free_play.data.MS_FROM,
            free_play.data.MT_USE_TABLES,
            Pauser.get_p_level(1),
            times_tables,
        )
        return get_linear_nlg(speech_list)
Esempio n. 23
0
    def handle(self, handler_input):
        logger.info("HAN    NoHandler")

        ms_confirmation = ConfirmUtils.get_confirmation(punct=True)
        prompt = HelpUtils.get_q_what_todo()

        reprompt = HelpUtils.get_ms_help_overview()

        speech_list = (ms_confirmation, 1, prompt)
        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)
Esempio n. 24
0
    def handle(self, handler_input):
        logger.info("HAN    CP_StartHandler")
        player_obj = PlayerDict.load_player_obj(handler_input)

        ## Check Sufficient Data
        ## NOTE: make like to refacor this into a method that returns response object
        ## That will remove the nested loop below.
        answered_questions = player_obj.get_answered_questions()
        if answered_questions < custom_practice.data.MIN_DATA_REQUIRED:
            prompt, reprompt = (HelpUtils.get_q_what_todo() for _ in range(2))

            speech_list = (
                CP_Welcome.get_ms_need_more_data(answered_questions),
                2,
                prompt,
            )

        else:
            CP_Attr.set_attr_start_cp(handler_input)
            CP_Attr.set_tbl_mean_err_list_attr(
                handler_input, player_obj)  # used in practice type

            ms_welcome = CP_Welcome.get_ms_welcome(handler_input, player_obj)

            practice_type = CP_PracticeType.get_practice_type(
                handler_input, allow_incorrect_problems=True)
            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)
            question = CP_Questions.get_question(handler_input,
                                                 player_obj,
                                                 practice_type,
                                                 first_question=True)
            reprompt = GenQuestions.get_same_question(handler_input)
            speech_list = (
                ms_welcome,
                2.5,
                ms_practice_intro,
                2,
                question,
            )

        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)
Esempio n. 25
0
    def handle(self, handler_input):
        logger.info("HAN    CreateUserProfileHandler")

        user_name = SlotUtils.get_first_slot_value(handler_input)
        if not user_name:
            logger.info("HAN    RetryUserName")
            ms_welcome = UserProfileUtils.get_ms_welcome(handler_input)
            ms_retry_name = UserProfileUtils.get_ms_did_not_hear_name()

            prompt, reprompt = (
                UserProfileUtils.get_q_retry_name() for _ in range(2))
            prompt = CardFuncs.format_prompt(prompt)

            speech_list = (
                ms_welcome, 
                0.5,
                ms_retry_name,
                1.75,
                prompt
            )
        else:
            logger.info("HAN    CreatedProfile")
            UserProfileUtils.set_sesh_attr(handler_input, user_name)
            PlayerDict.create_new_player(handler_input, user_name)
            
            ms_confirm = ConfirmUtils.get_player_confirmation(handler_input)
            ms_created_first_profile = UserProfileUtils.get_ms_created_first_profile(handler_input)
        
            ms_overview = HelpUtils.get_ms_act_descript()
            prompt, reprompt = (
                HelpUtils.get_q_what_todo() for _ in range(2))
            prompt = CardFuncs.format_prompt(prompt)

            speech_list = (
                ms_confirm, 
                1,
                ms_created_first_profile,
                3,
                ms_overview,
                2.25,
                prompt
            )
        
        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)
Esempio n. 26
0
    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 get_ms_add_table_example() -> str:
        """Returns example of how to add tables"""
        random_nums = set()
        while len(random_nums) != 3:
            num = random.randint(0, 10)
            if num not in random_nums:
                random_nums.add(str(num))

        speech_list = (
            get_ms_try_saying(),
            get_linear_nlg(free_play.data.MMT_EXAMPLE_ADD_TIMES_TABLES),
            ' and '.join(random_nums),
        )
        return ' '.join(speech_list)
    def get_example_table_range() -> str:
        """Returns example of providing times table range."""
        # ms_start_table_req = random.choice( free_play.data.MT_START_TABLE_REQUEST)
        low_table, upper_table = random.randint(0, 5), random.randint(6, 10)
        ms_range = random.choice(free_play.data.MT_RANGE_TABLES).format(
            low_table, upper_table)

        speech_list = (
            # ms_start_table_req,
            # free_play.data.MT_FROM,
            free_play.data.MS_USE,
            free_play.data.MT_TIMES_TABLES,
            ms_range,
        )
        return get_linear_nlg(speech_list)
    def get_consecutive_incorrect_congrats(handler_input,
                                           excite_level: int) -> str:
        """Returns congrats message for breaking consecutive incorrect."""
        ms_congrats = CongratUtils.get_random_congrats(
            handler_input,
            excite_level=excite_level,
            chance_speechcon=0.25,
            chance_player_congrats=0.75)

        excite_wrapper = CongratUtils.get_excited_level_mw(excite_level)
        ms_broke_consecutive_incorrect = excite_wrapper.format(
            random.choice(data_congrat.MT_BROKE_INCORRECT_STREAK_1))

        speech_list = (ms_congrats, 1, ms_broke_consecutive_incorrect)
        return get_linear_nlg(speech_list)
Esempio n. 30
0
    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)