sort cards for player

This commit is contained in:
Stefan Rupp 2020-04-06 21:59:31 +02:00
parent 129e676335
commit 4fa38fabef

View File

@ -1,5 +1,6 @@
import random
from operator import attrgetter
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
@ -28,7 +29,7 @@ class Player:
self.cards = []
def set_cards(self, cards):
self.cards = cards
self.cards = sorted(cards, key=attrgetter('color', 'value'))
def show_cards(self):
print(self.cards)
@ -45,9 +46,9 @@ class WizGame:
for val in range(1, 14):
self.card_deck.append(Card(color, val))
for _ in range(1, 5):
self.card_deck.append(Card(None, 'Z'))
self.card_deck.append(Card('-', 'Z'))
for _ in range(1, 5):
self.card_deck.append(Card(None, 'N'))
self.card_deck.append(Card('-', 'N'))
print("carddeck:")
print(self.card_deck)