def play_game(num1, num2, num3): turn_num = get_turn_num() last_num = num3 if last_num is None: last_num = num2 if last_num is None: last_num = num3 if last_num is None: last_num = num1 # Exceptional case: when CEK fail to match slots if last_num is None: return question('아... 다시 한번만 말해주세요') # check if an user keep the rule or remind if last_num - int(turn_num) > 2 or last_num - int(turn_num) < 0: return question('규칙에 어긋납니다. 다시 해주세요.').add_speech(turn_num + "을 말할 차례입니다.") if last_num >= 31: # when user lose return statement("제가 이겼네요. 하하하.") if last_num == 30: # expect not to reach this code line return statement("제가 졌네요.. 개발자가 잘못만들었다.") speech_num = make_number_to_speech(last_num) speech = speech_num if not speech: speech = str(last_num + 1) return question(speech).add_speech("이제 너 차례").reprompt("그만 할거야?")
def give_answer(): attr = session.sessionAttributes ask_word = attr.get('word') if ask_word is None: # when user ask answer before play # and end process. return statement('물어본적이 없는데 어떻게 정답을 말하나요.').add_speech('서비스 종료합니다.') for key ,word in words_set.items(): # find matched word # and give new random question. if word == ask_word: ans = key next_word = make_question() return question('정답은 ' + ans + '입니다. 다른 단어를 들려드릴게요').add_speech(next_word, lang='ja') return statement('착오가 있었네요 개발자 잘못입니다. ㅠ')
def give_answer(): attr = session.sessionAttributes ask_word = attr.get('word') if ask_word is None: # when user ask answer before play # and end process. return statement('물어본적이 없는데 어떻게 정답을 말하나요.').add_speech('서비스 종료합니다.') for key, word in words_set.items(): # find matched word # and give new random question. if word == ask_word: ans = key next_word = make_question() return question('정답은 ' + ans + '입니다. 다른 단어를 들려드릴게요').add_speech( next_word, lang='ja') return statement('착오가 있었네요 개발자 잘못입니다. ㅠ')
def throw_handler(dice_cnt): speech = "주사위를 " + str(dice_cnt) + "개 던집니다." dice_sound = os.path.join(os.getcwd(), "rolling_dice_sound.mp3") result_text = get_answer(dice_cnt) return statement(say.Korean(speech))\ .add_speech(say.Link(dice_sound))\ .add_speech(say.Korean(result_text))
def whats_my_color(): color = session.attributes.get(COLOR_KEY) if color is not None: statement_text = render_template('known_color_bye', color=color) return statement(statement_text) else: question_text = render_template('unknown_color_reprompt') return question(question_text).reprompt(question_text)
def throw_handler(dice_cnt): speech = "주사위를 " + str(dice_cnt) + "개 던집니다." dice_sound = os.path.join(os.getcwd(), "rolling_dice_sound.mp3") result_text = get_answer(dice_cnt) return statement(speech)\ .add_speech(dice_sound, url=True)\ .add_speech(result_text)
def answer(ans): attr = session.sessionAttributes ask_word = attr.get('word') usr_word = words_set.get(ans) if ask_word is None: return not_play_game() elif usr_word is None: return statement("단어 사전 미등록..") elif usr_word == ask_word: word = make_question() return question("정답입니다.").add_speech("이건 뭘까요?").add_speech(word, lang='ja').reprompt(word, lang='ja') else: return question("틀렸습니다. 다시 들어보세요.").add_speech(ask_word ,lang='ja').reprompt(ask_word, lang='ja')
def answer(ans): attr = session.sessionAttributes ask_word = attr.get('word') usr_word = words_set.get(ans) if ask_word is None: return not_play_game() elif usr_word is None: return statement("단어 사전 미등록..") elif usr_word == ask_word: word = make_question() return question("정답입니다.").add_speech("이건 뭘까요?").add_speech( word, lang='ja').reprompt(word, lang='ja') else: return question("틀렸습니다. 다시 들어보세요.").add_speech( ask_word, lang='ja').reprompt(ask_word, lang='ja')
def default_intent(): magic_sound = "https://ssl.pstatic.net/static/clova/service/native_extensions/magicball/magic_ball_sound.mp3" speech = "마법 구슬이 " + get_answer() + " 라고 말합니다." return statement(magic_sound, url=True).add_speech(speech)
def hello_world(): speech_text = render_template('hello') return statement(say.English(speech_text))
def hello_world(): speech_text = render_template('hello') return statement(speech_text, lang='en')
def hello_world(test_slot): speech_text = 'Hello world' return statement(speech_text, lang='en')\ .add_speech(test_slot, lang='en')
def session_ended(): return statement("주사위 놀이 익스텐션을 종료합니다.")
def session_ended(): return statement(say.Korean("주사위 놀이 익스텐션을 종료합니다."))
def hello_world(test_slot): speech_text = 'Hello world' return statement(say.English(speech_text))\ .add_speech(say.English(test_slot)).add_directive(directive.open_mike())
def default_intent(): speech = random.choice(dialog_set) return statement(speech)