# Path: linux_story/common.py
# def get_max_challenge_number():
# def get_username():
# def get_story_file(name):


import os
import traceback
from kano.utils import play_sound as play_sound_toolset
from kano.logging import logger
from linux_story.common import sounds_dir

    def on_typing_story_text(self, story_text):
        """
        Play the sound for the key_words in the story_text.

        It checks which of the key_words are at the beginning of the story_text
        and plays the corresponding sound, e.g. 'Ding. Dong.' in the story plays 'bell'.

        Args:
            story_text (str) - an excerpt of the story text in the challenges
        """

        for key_words, sound_name in self.story_text_sound.items():
            if story_text.startswith(key_words):
                try:
                    self.play_sound(sound_name)
                    break

                except Exception:
                    logger.error('Unexpected error while playing sound. story_text is {}'
                                 ' {}'.format(story_text, traceback.format_exc()))

    def play_sound(self, sound_name, background=True):
        """
        Play a game sound in blocking or unblocking mode.

        Args:
            sound_name (str) - sound file name without extension, e.g. 'bell'
        """


# Path: linux_story/common.py
# def get_max_challenge_number():
# def get_username():
# def get_story_file(name):


# Path: linux_story/sound_manager.py
import os
import traceback
from kano.utils import play_sound as play_sound_toolset
from kano.logging import logger
from linux_story.common import sounds_dir


    def on_typing_story_text(self, story_text):
        """
        Play the sound for the key_words in the story_text.

        It checks which of the key_words are at the beginning of the story_text
        and plays the corresponding sound, e.g. 'Ding. Dong.' in the story plays 'bell'.

        Args:
            story_text (str) - an excerpt of the story text in the challenges
        """

        for key_words, sound_name in self.story_text_sound.items():
            if story_text.startswith(key_words):
                try:
                    self.play_sound(sound_name)
                    break

                except Exception:
                    logger.error('Unexpected error while playing sound. story_text is {}'
                                 ' {}'.format(story_text, traceback.format_exc()))

    def play_sound(self, sound_name, background=True):
        """
        Play a game sound in blocking or unblocking mode.

        Args:
            sound_name (str) - sound file name without extension, e.g. 'bell'
        """


        sound_path = os.path.join(sounds_dir, sound_name + '.wav')