sort cards for player
This commit is contained in:
parent
129e676335
commit
4fa38fabef
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
from operator import attrgetter
|
||||||
|
|
||||||
def chunks(lst, n):
|
def chunks(lst, n):
|
||||||
"""Yield successive n-sized chunks from lst."""
|
"""Yield successive n-sized chunks from lst."""
|
||||||
@ -28,7 +29,7 @@ class Player:
|
|||||||
self.cards = []
|
self.cards = []
|
||||||
|
|
||||||
def set_cards(self, cards):
|
def set_cards(self, cards):
|
||||||
self.cards = cards
|
self.cards = sorted(cards, key=attrgetter('color', 'value'))
|
||||||
|
|
||||||
def show_cards(self):
|
def show_cards(self):
|
||||||
print(self.cards)
|
print(self.cards)
|
||||||
@ -45,9 +46,9 @@ class WizGame:
|
|||||||
for val in range(1, 14):
|
for val in range(1, 14):
|
||||||
self.card_deck.append(Card(color, val))
|
self.card_deck.append(Card(color, val))
|
||||||
for _ in range(1, 5):
|
for _ in range(1, 5):
|
||||||
self.card_deck.append(Card(None, 'Z'))
|
self.card_deck.append(Card('-', 'Z'))
|
||||||
for _ in range(1, 5):
|
for _ in range(1, 5):
|
||||||
self.card_deck.append(Card(None, 'N'))
|
self.card_deck.append(Card('-', 'N'))
|
||||||
print("carddeck:")
|
print("carddeck:")
|
||||||
print(self.card_deck)
|
print(self.card_deck)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user