コード例 #1
0
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)]
コード例 #2
0
print(card.matches(special_card))
print('-' * 5)

blue_card = ReverseCard(0, "blue")

print('special_card.matches(blue_card)')
print(special_card.matches(blue_card))
print('-' * 5)
print('*' * 40)

# Deck
cards = [card, special_card, blue_card]
deck = Deck(cards)

print('deck.get_cards()')
print(deck.get_cards())
print('-' * 5)
print('deck.get_amount()')
print(deck.get_amount())
print('-' * 5)
print('deck.top()')
print(deck.top())
print('-' * 5)
new_card = SkipCard(0, "green")
deck.add_card(new_card)
from os import system
system('pause')
deck.add_cards([card, special_card, blue_card])
print(deck.get_cards())
print(deck.get_amount())
print(deck.pick())