Пример #1
0
def main():
    """
    Play a game of uno
    """
    # Set up the MVC components.
    print("Welcome to Uno!\n \
        Here are the rules:\n \
        1. Match the card in the middle by either color or number\n \
        2. Watch out for action cards! Plus Two, Skip, Reverse, and Wild Cards\n \
        3. If you are at one card and the game prompts you with: \n\t\"Hit enter once you are finished with your turn\"\n \
        Please type \"Uno!\" or else you will get extra cards\n \
        4. Do not look at other player cards!\n\n")
    continue_game = "y"
    while continue_game == "y":
        uno_set = Deck()
        uno_controller = TextController(uno_set)
        names = uno_controller.start()
        uno_game = PlayGame(uno_set, names)
        uno_set.game_start()
        view = TextView(uno_game)
        while not uno_game.check_win():
            view.display()
            uno_game.play()
        for player in uno_game.player_list:
            if player.check_empty():
                uno_game.win_message(player)
                continue_game = input(
                    "Do you want to continue play again? y/n: ")
    print("Thanks for playing!")
Пример #2
0
def test_deck_check_match(card, is_match):
    """
    Checks that the average image finder returns an average of all the images in the list
    using our second color averaging method.

    Args:
        image_list: a list representing the images to average.
        resulting_image: a image representing the expected resulting average image.
    """
    uno_deck = Deck()
    uno_deck.game_start()

    assert uno_deck.check_match(card) == is_match
Пример #3
0
"""
Check the correctness of functions in icon_averaging
"""
# Import required libraries.
import pytest

# Import the code to be tested.
from uno_deck import (Card, Deck, Player, PlayGame)

# create test objects
test_uno_deck = Deck()
test_uno_deck.game_start()
test_uno_player = Player(test_uno_deck, "name")


@pytest.mark.parametrize(
    "color, rank, resulting_card",
    [
        # Checks that creating a card with a minimum rank is created correctly
        ("Red", 0, "Red 0"),
        # Checks that creating a card with a maximum rank is created correctly
        ("Green", 9, "Green 9"),
        # Checks that creating a card with rank 10 outputs a Draw Two card
        ("Yellow", 10, "Yellow Draw Two"),
        # Checks that creating a card with rank 11 outputs a Reverse card
        ("Blue", 11, "Blue Reverse"),
        # Checks that creating a card with rank 12 outputs a Skip card
        ("Red", 12, "Red Skip"),
        # Checks that creating a card with rank 13 outputs a Wild Card card
        ("Wild", 13, "Wild Card"),
        # Checks that creating a card with rank 14 outputs a Wild Draw Four card