sort_card_list moved to utils and refactored

This commit is contained in:
Jakub Senderák
2020-04-25 18:30:43 +02:00
parent 834e03c172
commit 618e632ce4
3 changed files with 18 additions and 14 deletions
-12
View File
@@ -69,18 +69,6 @@ class Card():
def __repr__(self):
return '<Card {}_{}>'.format(self.color.name, self.value.name)
@staticmethod
def sort_card_list(input_card_set: []) -> []:
hearts = [c for c in input_card_set if c.color == Card_colors['HEARTS']]
leaves = [c for c in input_card_set if c.color == Card_colors['LEAVES']]
acorns = [c for c in input_card_set if c.color == Card_colors['ACORNS']]
bells = [c for c in input_card_set if c.color == Card_colors['BELLS']]
hearts.sort(key=lambda a : a.value)
leaves.sort(key=lambda a : a.value)
acorns.sort(key=lambda a : a.value)
bells.sort(key=lambda a : a.value)
return hearts + leaves + acorns + bells
class JSONEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, Card):