# wait for next input user_input = list(h.get_input()) if won is True: # We've got a WINNER! h.display_state(pattern, error_count, wrong_guess_lst, h.WIN_MSG, True) else: # Pa! They done gone and haaaaanged that man!! h.display_state(pattern, error_count, wrong_guess_lst, h.LOSS_MSG + word, True) user_input = list(h.get_input()) # loop until the user makes up their darn mind while user_input[0] != h.PLAY_AGAIN: user_input = list(h.get_input()) # run new game if requested, otherwise end. if user_input[1] is True: run_single_game(words_list) def main(): """ Loads words, and runs game """ words_list = h.load_words() run_single_game(words_list) if __name__ == "__main__": h.start_gui_and_call_main(main) h.close_gui()
def end_game_msg(pattern, word, error_count, msg): """ returns a msg which specifies the reason of the game ending. """ if pattern == word: msg = hangman_helper.WIN_MSG elif error_count == MAX_ERRORS: msg = hangman_helper.LOSS_MSG + word return msg def main(): """ responsible of the running of the game. """ a = True words_lst = hangman_helper.load_words() while a: run_single_game(words_lst) user_input_type, user_input = hangman_helper.get_input() if user_input_type == hangman_helper.PLAY_AGAIN: 'input is either true (user wants to play another game) or false' if not user_input: a = False if __name__ == '__main__': hangman_helper.start_gui_and_call_main(main) hangman_helper.close_gui()
def run(): hangman_helper.start_gui_and_call_main(main) hangman_helper.close_gui()