# Path: linux_story/story/challenges/CompanionMisc.py
# class StepTemplateNano(StepTemplateEleanorBernard):
#     TerminalClass = TerminalNanoBernard
# 
# Path: linux_story/helper_functions.py
# def record_user_interaction(instance, base_name):
#     """
#     This is to store some of the user actions, so we can determine
#     if the user does the optional side quests.
# 
#     Args:
#         The class instance.
#         base_name (str): a string for the identity of the command.
#     """
# 
#     class_instance = instance.__class__.__name__
#     challenge_number = instance.__module__.split("_")[-1]
#     profile_var_name = "{} {} {}".format(
#         base_name, challenge_number, class_instance
#     )
# 
#     # First, try loading the profile variable name
#     # If the value is None, then make it True and increment the total.
#     already_done = load_app_state_variable("linux-story", profile_var_name)
# 
#     # If the command has not been done yet in this class, then increment the
#     # total
#     if not already_done:
#         save_app_state_variable("linux-story", profile_var_name, True)
#         total_name = "{} total".format(base_name)
#         increment_app_state_variable("linux-story", total_name, 1)
# 
#         # If total reaches a certain amount, then can award XP.


import os
from linux_story.story.challenges.CompanionMisc import StepTemplateNano
from linux_story.helper_functions import record_user_interaction
class StepNanoStory(StepTemplateNano):
    commands = [
        "echo 1"
    ]

    start_dir = "~/town/east/restaurant/.cellar"
    end_dir = "~/town/east/restaurant/.cellar"
    hints = [
        _("{{rb:Talk to Clara using}} {{yb:echo 1}}{{rb:,}} {{yb:echo 2}} {{rb:or}} {{yb:echo 3}}{{rb:.}}")
    ]
    step_number = None


    def story_check_command(self, line, echo_hit):
        # If self.last_user_input equal to "echo 1" or "echo 3"
        if line in story_replies:

            if line == "echo 1":
                return True

            else:
                if echo_hit[line]:
                    echo_hit[line] = False
                    reply = pop_story(line)["clara"]
                    self.send_hint("\n\n" + reply)

                    # Record that the user got optional info
                    # Replace spaces with underscores
                    user_input = "_".join(line.split(" "))
                    state_name = "clara_%s" % user_input

# Path: linux_story/story/challenges/CompanionMisc.py
# class StepTemplateNano(StepTemplateEleanorBernard):
#     TerminalClass = TerminalNanoBernard
# 
# Path: linux_story/helper_functions.py
# def record_user_interaction(instance, base_name):
#     """
#     This is to store some of the user actions, so we can determine
#     if the user does the optional side quests.
# 
#     Args:
#         The class instance.
#         base_name (str): a string for the identity of the command.
#     """
# 
#     class_instance = instance.__class__.__name__
#     challenge_number = instance.__module__.split("_")[-1]
#     profile_var_name = "{} {} {}".format(
#         base_name, challenge_number, class_instance
#     )
# 
#     # First, try loading the profile variable name
#     # If the value is None, then make it True and increment the total.
#     already_done = load_app_state_variable("linux-story", profile_var_name)
# 
#     # If the command has not been done yet in this class, then increment the
#     # total
#     if not already_done:
#         save_app_state_variable("linux-story", profile_var_name, True)
#         total_name = "{} total".format(base_name)
#         increment_app_state_variable("linux-story", total_name, 1)
# 
#         # If total reaches a certain amount, then can award XP.


# Path: linux_story/story/challenges/challenge_29.py
import os
from linux_story.story.challenges.CompanionMisc import StepTemplateNano
from linux_story.helper_functions import record_user_interaction

class StepNanoStory(StepTemplateNano):
    commands = [
        "echo 1"
    ]

    start_dir = "~/town/east/restaurant/.cellar"
    end_dir = "~/town/east/restaurant/.cellar"
    hints = [
        _("{{rb:Talk to Clara using}} {{yb:echo 1}}{{rb:,}} {{yb:echo 2}} {{rb:or}} {{yb:echo 3}}{{rb:.}}")
    ]
    step_number = None


    def story_check_command(self, line, echo_hit):
        # If self.last_user_input equal to "echo 1" or "echo 3"
        if line in story_replies:

            if line == "echo 1":
                return True

            else:
                if echo_hit[line]:
                    echo_hit[line] = False
                    reply = pop_story(line)["clara"]
                    self.send_hint("\n\n" + reply)

                    # Record that the user got optional info
                    # Replace spaces with underscores
                    user_input = "_".join(line.split(" "))
                    state_name = "clara_%s" % user_input

                    record_user_interaction(self, state_name)