def play_game(puzzle: str, remaining_words: List[str]) -> None:
    """Prompt the players to guess words that occur in the puzzle.  Print
    the score after each turn.  Print the winner.
    """

    # Whether it's player one's turn. If False, it's player two's turn.
    player_one_turn = True

    # The scores for the two players.
    player_one_score = 0
    player_two_score = 0

    print('''***************************************
**       Where's That Word?          **
***************************************''')

    # Prompt for a guess and add up the points until the game is over.
    while not game_over(remaining_words):

        print_puzzle(puzzle)
        print('the words left to be found: ')
        print_words(remaining_words)

        # Get the name of the player whose turn it is.
        current_player_name = puzzle_functions.get_current_player(
            player_one_turn)

        # Have the player take their turn and get the score.
        points = take_turn(puzzle, remaining_words, current_player_name)

        if (points == 0):
            print("incorrect guess :-(")
        else:
            print("correct guess!!!")

        # Update the score for whoever's turn it is.
        if player_one_turn:
            player_one_score = player_one_score + points
            current_player_score = player_one_score
        else:
            player_two_score = player_two_score + points
            current_player_score = player_two_score

        print(current_player_name + "'s score is " +
              str(current_player_score) + "\n")

        player_one_turn = not player_one_turn

    print(
        'woohoo!!! ',
        puzzle_functions.get_winner(player_one_score, player_two_score) +
        '!!!')
Example #2
0
def play_game(puzzle, words):
    """ (str, list of words) -> Nonetype

    Prompt the players to guess words that occur in the puzzle.
    Print the score after each turn.  Print the winner.
    """

    # Whether it's Player One's turn; if False, it's Player Two's turn.
    player_one_turn = True

    # The scores for the two players.
    player_one_score = 0
    player_two_score = 0

    print('''***************************************
**       Where's That Word?          **
***************************************''')

    # Prompt for a guess and add up the points until the game is over.
    while not game_over(words):

        print_puzzle(puzzle)
        print_words(words)

        # Get the name of the player whose turn it is.
        current_player_name = \
            puzzle_functions.get_current_player(player_one_turn)

        # Have the player take their turn and get the score.
        score = take_turn(puzzle, words, current_player_name)

        # Update the score for whoever's turn it is.
        if player_one_turn:
            player_one_score = player_one_score + score
            print(current_player_name + "'s score is " +
                  str(player_one_score) + '.\n')
        else:
            player_two_score = player_two_score + score
            print(current_player_name + "'s score is " +
                  str(player_two_score) + '.\n')

        player_one_turn = not player_one_turn

    print(puzzle_functions.get_winner(player_one_score, player_two_score))
def play_game(puzzle, words):
    """ (str, list of words) -> Nonetype

    Prompt the players to guess words that occur in the puzzle.
    Print the score after each turn.  Print the winner.
    """

    # Whether it's Player One's turn; if False, it's Player Two's turn.
    player_one_turn = True

    # The scores for the two players.
    player_one_score = 0
    player_two_score = 0

    print('''***************************************
**       Where's That Word?          **
***************************************''')

    # Prompt for a guess and add up the points until the game is over.
    while not game_over(words):

        print_puzzle(puzzle)
        print_words(words)

        # Get the name of the player whose turn it is.
        current_player_name = \
            puzzle_functions.get_current_player(player_one_turn)

        # Have the player take their turn and get the score.
        score = take_turn(puzzle, words, current_player_name)

        # Update the score for whoever's turn it is.
        if player_one_turn:
            player_one_score = player_one_score + score
            print(current_player_name + "'s score is " +
                  str(player_one_score) + '.\n')
        else:
            player_two_score = player_two_score + score
            print(current_player_name + "'s score is " +
                  str(player_two_score) + '.\n')

        player_one_turn = not player_one_turn

    print(puzzle_functions.get_winner(player_one_score, player_two_score))
Example #4
0
match the assignment specification, but it does not mean that your code works
correctly in all situations. Be sure to test your code before submitting.'''

import puzzle_functions as pf

# Get the initial values of the constants
constants_before = [pf.FORWARD_FACTOR, pf.DOWN_FACTOR, pf.BACKWARD_FACTOR,
                    pf.UP_FACTOR]
# Type check pf.get_current_player
result = pf.get_current_player(True)
assert isinstance(result, str), \
       '''pf.get_current_player should return a str, but returned {0}
       .'''.format(type(result))

# Type check pf.get_winner
result = pf.get_winner(17,32)
assert isinstance(result, str), \
       '''pf.get_winner should return a str, but returned {0}.''' \
       .format(type(result))

# Type check pf.get_factor
result = pf.get_factor('forward')
assert isinstance(result, int), \
       '''pf.get_factor should return an int, but returned {0}.''' \
       .format(type(result))


# Type check pf.get_points
result = pf.get_points('up', 7)
assert isinstance(result, int), \
       '''pf.get_points should return an int, but returned {0}.''' \
Example #5
0
    where the correct return type is expected."""

    return ('{0} should return a {1}, but returned {2}' + '.').format(
        func_name, expected, got)


# Type check puzzle_functions.get_current_player
print('Checking get_current_player...')
got = pf.get_current_player(True)
assert isinstance(got, str), \
    type_error_message('puzzle_functions.get_current_player', 'str', type(got))
print('  check complete')

# Type check puzzle_functions.get_winner
print('Checking get_winner...')
got = pf.get_winner(17, 32)
assert isinstance(got, str), \
    type_error_message('puzzle_functions.get_winner', 'str', type(got))
print('  check complete')

# Type check puzzle_functions.reverse
print('Checking reverse...')
got = pf.reverse('hello')
assert isinstance(got, str), \
    type_error_message('puzzle_functions.reverse', 'str', type(got))
print('  check complete')

# Type check puzzle_functions.get_row
print('Checking get_row...')
got = pf.get_row('abcd\nefgh\nijkl\n', 1)
assert isinstance(got, str), \