def main(): list_of_all_words = hangman_helper.load_words(file='words.txt') run_single_game(list_of_all_words) ans = hangman_helper.get_input() while ans[0] == hangman_helper.PLAY_AGAIN and ans[1]: run_single_game(list_of_all_words) ans = hangman_helper.get_input()
def main(): """This function allows to run the program.""" # load the game words_list = hangman_helper.load_words() run_single_game(words_list) # answer of the user about if he want to play more or not user_input = hangman_helper.get_input() # rerun a game if he want to play more while user_input[0] == hangman_helper.PLAY_AGAIN and user_input[1]: words_list = hangman_helper.load_words() run_single_game(words_list) user_input = hangman_helper.get_input()
def main(): """Runs the game, repeat if user wants to""" the_word_list = hangman_helper.load_words() run_another_game = True while run_another_game: run_single_game(the_word_list) run_another_game = hangman_helper.get_input()[1]
def main(): """ Run games and keep score until player decides to stop """ # Load list of words from file and initialize games stats word_list = hangman_helper.load_words("words.txt") games_played = 0 score = hangman_helper.POINTS_INITIAL # Keep playing until player stops while score > 0: # Run a single round score = run_single_game(word_list, score) games_played += 1 # Write end-of-round message end_of_round_message = GAMES_PLAYED_MESSAGE + str(games_played) + \ CURRENT_SCORE_MESSAGE + str(score) + ". " end_of_round_message += PLAY_AGAIN_MESSAGE if score > 0 \ else NEW_SERIES_MESSAGE # Ask player whether to continue if hangman_helper.play_again(end_of_round_message): # If player lost but wants to continue reset game stats if score == 0: games_played = 0 score = hangman_helper.POINTS_INITIAL else: break
def main(): words_list = hangman_helper.load_words() run_single_game(words_list) status, input_t = hangman_helper.get_input() while status == hangman_helper.PLAY_AGAIN and input_t: run_single_game(words_list) status, input_t = hangman_helper.get_input()
def main(): """operate several games of hangman acorrding to user will""" words_list = list(hangman_helper.load_words()) game_played = 1 score = run_single_game(words_list, hangman_helper.POINTS_INITIAL) another_game = True while another_game: if score > 0: another_game = hangman_helper.play_again("Games played: " + str(game_played) + " current score: " + str(score) + " would you like" " to play again?") if another_game == False: break score = run_single_game(words_list, score) game_played += 1 elif score == 0: another_game = hangman_helper.play_again("Games played: " + str(game_played) + " would you like to " "restart the game?") if another_game == False: break score = run_single_game(words_list, hangman_helper.POINTS_INITIAL) game_played = 1
def main(): """main function""" words_list = hangman_helper.load_words(file='words.txt') run_single_game(words_list) options, letter = hangman_helper.get_input() while options == hangman_helper.PLAY_AGAIN and letter == True: """runs another turn""" run_single_game(words_list)
def main(): """runs full hangman game""" words_list = hangman_helper.load_words() run_single_game(words_list) new_game = hangman_helper.get_input() while new_game[1] == True: run_single_game(words_list) new_game = hangman_helper.get_input()
def main(): """This function handle running the game more than once according to the user input, and uses the load_words function to load the words into the run_single_game funcction""" words_list = hangman_helper.load_words() run_single_game(words_list) type_input, value_input = hangman_helper.get_input() while type_input == 3 and value_input : run_single_game(words_list) type_input, value_input = hangman_helper.get_input()
def main(): """A function that generates the game 'hangman' using the function- run_single_game""" words_list = hangman_helper.load_words() run_single_game(words_list) input1 = hangman_helper.get_input() while input1[0] == hangman_helper.PLAY_AGAIN and input1[1]: run_single_game(words_list) input1 = hangman_helper.get_input()
def main(): """the main function that runs the game by using the run_single_game function.""" words_list = hangman_helper.load_words() run_single_game(words_list) another_game = define_input() while another_game: # the loop runs as long as the user wants to keep playing run_single_game(words_list) another_game = define_input()
def main(): """This function activate the game""" words_list = hangman_helper.load_words( "words.txt") # load words list from an external file wanna_play = True while wanna_play: run_single_game(words_list) # runs the game # every time a game is finished the user gets a screen that offers a new game input_type, wanna_play = hangman_helper.get_input()
def main(): """This function loads a lists of words and uses that list in order to start a new game. At the end of the game asks if the player wants to start a new game or not, and proceeds suitable with the player's choice""" new_words_list = hangman_helper.load_words() run_single_game(new_words_list) wants_to_play = hangman_helper.get_input() while wants_to_play[1] == True: run_single_game(new_words_list) wants_to_play = hangman_helper.get_input()
def main(): """this function load word from word list(from hangman_helper). this function start the game and when the game end the function suggest to play again""" word_list = hangman_helper.load_words() while True: run_single_game(word_list) user_decision, second_choice = hangman_helper.get_input() if not second_choice: break
def main(): ''' Executes main function. Iterates over the game as long as player asks to play again. ''' WORDS_LIST = hangman_helper.load_words('words.txt') play_again = True while play_again: run_single_game(WORDS_LIST) play_again = hangman_helper.get_input()[1]
def main(): """This function start a game. While the player want to keep playing, new game will start.""" words_lst = hangman_helper.load_words() run_single_game(words_lst) move = hangman_helper.get_input() while move[0] == hangman_helper.PLAY_AGAIN and move[1]: run_single_game(words_lst) move = hangman_helper.get_input()
def main(): """ the function start a hangman game till the user do not want to continue . """ words_list = hh.load_words() # loads words from words.txt continue_game = True # play a game till the user choose not to while continue_game: run_single_game(words_list) # checking if the user wants to continue playing continue_game = hh.get_input()[1]
def main(): """The spine of hangman - start single game im the first time and every time the player asks to play again""" # load the word index words_list = hangman_helper.load_words('words.txt') run_single_game(words_list) key, value = hangman_helper.get_input() # evaluates whether or not to play again if key == hangman_helper.PLAY_AGAIN: while value: run_single_game(words_list) key, value = hangman_helper.get_input()
def main(): """ The main/root function of the file """ # Initialize words from specific file words_list = hangman_helper.load_words() # Run single game with given word list to choose from run_single_game(words_list) # Ask the user if he would like to play again request = hangman_helper.get_input() if request[INPUT_TYPE] == hangman_helper.PLAY_AGAIN: if request[INPUT_VALUE]: run_single_game(words_list)
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
def main(): """ Launching the game until the user click on no more :return: """ # Launching the first game words_list = hangman_helper.load_words() # Loading words run_single_game(words_list) # Running the game with those words input_from_user = hangman_helper.get_input() # Playing again while input_from_user[COMMAND_INDEX] == hangman_helper.PLAY_AGAIN \ and input_from_user[VALUE_INDEX]: # While the input is play # again choice and it's true run_single_game(words_list) # Running the game input_from_user = hangman_helper.get_input()
def get_hint(error_count, msg, pattern, wrong_guess_lst): words = hangman_helper.load_words("words.txt") # loads the words to a list filtered_words = filter_words_list( words, pattern, wrong_guess_lst) # filters the words that fit to the pattern hint_letter = choose_letter(filtered_words, pattern) # defines the best letter for a hint msg = hangman_helper.HINT_MSG + hint_letter # update the hint msg to the user hangman_helper.display_state(pattern, error_count, wrong_guess_lst, msg, ask_play=False) return msg
def main(): words_list = hangman_helper.load_words() PLAY = True while PLAY: PLAY = run_single_game(words_list)
def main(): """ Loads words, and runs game """ words_list = h.load_words() run_single_game(words_list)