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
+16
View File
@@ -1,3 +1,5 @@
from bridzik import Card_colors
def get_points_sums(standings: []):
sums = [0] * 4
for series in standings:
@@ -5,3 +7,17 @@ def get_points_sums(standings: []):
for player, points in enumerate(round):
sums[player] += points
return sums
def sort_card_list(input_card_set: []) -> []:
color_paritions = [
[c for c in input_card_set if c.color == Card_colors['HEARTS']],
[c for c in input_card_set if c.color == Card_colors['LEAVES']],
[c for c in input_card_set if c.color == Card_colors['ACORNS']],
[c for c in input_card_set if c.color == Card_colors['BELLS']]
]
output_list = []
for color_list in color_paritions:
color_list.sort(key=lambda a : a.value)
output_list.extend(color_list)
return output_list