def test_deck(): # Setup card = Card(12, "red") special_card = Pickup2Card(0, "red") blue_card = ReverseCard(0, "blue") cards = [card, special_card, blue_card] deck = Deck(cards) # Testing print("Get Cards:", deck.get_cards( )) #== [Card(12, 'red'), Pickup2Card(0, 'red'), ReverseCard(0, 'blue')]) print("Amount:", deck.get_amount() == 3) print("Top:", deck.top()) #ReverseCard(0, blue) print() new_card = SkipCard(0, "green") deck.add_card(new_card) deck.add_cards([card, special_card, blue_card]) print("new amount:", deck.get_amount() == 7) print( "New Deck:", deck.get_cards() ) # [Card(12, red), Pickup2Card(0, red), ReverseCard(0, blue), SkipCard(0, green), Card(12, red), Pickup2Card(0, red),ReverseCard(0, blue)]) print("Pick:", deck.pick()) # [ReverseCard(0, blue)] print("Pick 2:", deck.pick(amount=2)) # [Pickup2Card(0, red), Card(12, red)] deck.shuffle() print( "New Deck", deck.get_cards() ) #[SkipCard(0, green), Card(12, red), Pickup2Card(0, red),ReverseCard(0, blue)]
def build_deck(self, cards): deck = Deck() for card in cards: if card is None: card = Card() deck.add_card(card) return deck
def init(): anna = ComputerPlayer("Anna Truffet") players = [ anna, HumanPlayer("Henry O'Brien"), ComputerPlayer("Josh Arnold") ] deck = Deck( [Card(1, "red"), Card(2, "blue"), Card(3, "red"), Card(4, "green")]) game = UnoGame(deck, players) return anna, players, deck, game
__version__ = "1.0.1" class CardColour(Enum): """ An enumeration of card colours in the Uno game. """ blue = "#508ebf" red = "#a30e15" yellow = "#f9bf3b" green = "#5d8402" black = "#222" FULL_DECK = [ (Card(0, CardColour.red), (0, 10)), (Card(0, CardColour.yellow), (0, 10)), (Card(0, CardColour.green), (0, 10)), (Card(0, CardColour.blue), (0, 10)), (Card(0, CardColour.red), (1, 10)), (Card(0, CardColour.yellow), (1, 10)), (Card(0, CardColour.green), (1, 10)), (Card(0, CardColour.blue), (1, 10)), (SkipCard(0, CardColour.red), (0, 2)), (SkipCard(0, CardColour.yellow), (0, 2)), (SkipCard(0, CardColour.green), (0, 2)), (SkipCard(0, CardColour.blue), (0, 2)), (ReverseCard(0, CardColour.red), (0, 2)), (ReverseCard(0, CardColour.yellow), (0, 2)), (ReverseCard(0, CardColour.green), (0, 2)), (ReverseCard(0, CardColour.blue), (0, 2)),
print('-' * 5) print("'card.play(anna,game)'") card.play(anna, game) print("\n") print("game.current_player().get_name()") print(game.current_player().get_name()) print(game.next_player().get_deck().get_cards()) print('*' * 40, end="\n\n") #P7 test print("card = Card(23,'yellow')") card = Card(23, "yellow") print('card.__str__()') print(card.__str__()) print('-' * 5) print('card') print(card) print('-' * 5) print("card = Card(42,'red')") card = Card(42, 'red') print('card.get_number()') print(card.get_number()) print('-' * 5)
def test_pickup2(): print(game.next_player().get_deck().get_cards() == []) card = Pickup2Card(0, "red") card.play(anna, game) print(game.next_player().get_deck().get_cards() == [Card(3, 'red'), Card(4, 'green')])
from a2 import Card, Player, Pickup2Card, Pickup4Card, HumanPlayer, ComputerPlayer, Deck, ReverseCard, SkipCard import a2_support # Set Up Uno Game anna = ComputerPlayer("Anna Truffet") players = [anna, HumanPlayer("Henry O'Brien"), ComputerPlayer("Josh Arnold")] deck = Deck( [Card(1, "red"), Card(2, "blue"), Card(3, "red"), Card(4, "green")]) game = a2_support.UnoGame(deck, players) def test_reverse_card(): print("reverse", '*' * 10) card = ReverseCard(0, "red") print(game.current_player().get_name()) # 'Anna Truffet' print(game.next_player().get_name()) # "Henry O'Brien" print(game.next_player().get_name()) # 'Josh Arnold' print(game.next_player().get_name()) # 'Anna Truffet' print("Reverse", '-' * 10) card.play(anna, game) print(game.next_player().get_name()) # 'Josh Arnold'
from a2 import Pickup2Card, Card, ReverseCard, SkipCard, ComputerPlayer, HumanPlayer, Pickup4Card from a2 import Deck import a2_support card = Card(42, "red") special_card = Pickup2Card(0, "red") blue_card = ReverseCard(0, "blue") cards = [card, special_card, blue_card] new_card = SkipCard(0, "green") deck = Deck(cards) anna = ComputerPlayer("Anna") players = [anna, HumanPlayer("Henry"), ComputerPlayer("john")] game = a2_support.UnoGame(deck, players) for i in game.players: print(i.get_name()) print(i.get_deck().get_cards()) special_card.play(anna, game) for i in game.players: print(i) print(i.get_name()) print(i.get_deck().get_cards()) print(id(i.get_deck().get_cards()))