Beispiel #1
0
        if game_type != pf.HUMAN:
            current_player = pf.next_player(current_player, quantity)

    # The game is over.
    display_outcome(pf.is_win(view, puzzle), score)


def display_outcome(won, score):
    """(bool, int) -> NoneType

    Display a message indicating whether the player won and, if so, their
    score.

    >>> display_outcome(True, 4)
    Winner! You scored 4 point(s).
    """

    if won:
        print("Winner! You scored {0} point(s).".format(score))
    else:
        print("Better luck next time!")


## The main Phrase Puzzler program
puzzle = get_puzzle()
view = pf.get_view(puzzle)

print('Welcome to Phrase Puzzler!')
game_type = prompt_for_game_type()
play_game(puzzle, view, game_type)
Beispiel #2
0
# Type check pf.is_win
result = pf.is_win('apple', 'about')
assert isinstance(result, bool), \
       """pf.is_win should return a bool, but returned {0}
       .""".format(type(result))


# Type check pf.game_over
result = pf.game_over('water', '^^te^', pf.CONSONANT)
assert isinstance(result, bool), \
       """pf.game_over should return a bool, but returned {0}.""" \
       .format(type(result))


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


# Type check pf.update_view
result = pf.update_view('apple', 'a^^l^', 'e')
assert isinstance(result, str), \
       """pf.update_view should return a str, but returned {0}.""" \
       .format(type(result))


# Type check pf.make_guessed
result = pf.make_guessed('jklmn', 'aeo', 'm')
assert isinstance(result, tuple) \