implemented the_winner_is() function
This commit is contained in:
parent
8a8dfc92db
commit
0c3cd94fc8
37
quartett.py
37
quartett.py
|
@ -20,15 +20,16 @@ def central_function():
|
|||
|
||||
switch = True
|
||||
|
||||
card_stack, players_with_cards, players, complete_card_stack = initialize()
|
||||
card_stack, players_with_cards, players, complete_card_stack = initialize()
|
||||
|
||||
# stores the dropped cards
|
||||
all_quartets = []
|
||||
# print("players",players) # debug
|
||||
# print("card stack", card_stack) # debug
|
||||
# for i in range(len(players)): # debug
|
||||
# pretty_print_deck(players_with_cards, i) # debug
|
||||
# print("active", active) # debug
|
||||
print("players",players) # debug
|
||||
print("card stack", card_stack) # debug
|
||||
print(players_with_cards) # debug
|
||||
for i in range(len(players)): # debug
|
||||
pretty_print_deck(players_with_cards, i) # debug
|
||||
print("active", active) # debug
|
||||
drop_cards(players_with_cards, all_quartets)
|
||||
while switch:
|
||||
round(card_stack, players_with_cards, players, active, complete_card_stack, all_quartets)
|
||||
|
@ -41,7 +42,7 @@ def central_function():
|
|||
if active >= len(players):
|
||||
active = 0
|
||||
|
||||
# the_winner_is()
|
||||
the_winner_is(players_with_cards, players)
|
||||
|
||||
|
||||
def round(card_stack, players_with_cards, players, active, complete_card_stack, all_quartets):
|
||||
|
@ -217,15 +218,33 @@ def initialize():
|
|||
return card_stack, players_with_cards, players, complete_card_stack
|
||||
|
||||
|
||||
def the_winner_is():
|
||||
def the_winner_is(players_with_cards, players):
|
||||
"""
|
||||
counts the number of quartets
|
||||
a player has made, and chooses the
|
||||
winner, who made the most
|
||||
"""
|
||||
pass
|
||||
|
||||
# TODO
|
||||
temp = 1
|
||||
winners = []
|
||||
|
||||
# all potential winners are saved in the winners-list
|
||||
# (in case there is more than one)
|
||||
for i in range(len(players)):
|
||||
winners.append(0)
|
||||
dropped_quartets = players_with_cards[i]['quartet']
|
||||
|
||||
if temp < dropped_quartets :
|
||||
temp = dropped_quartets
|
||||
winners.insert(i, dropped_quartets )
|
||||
|
||||
if temp == dropped_quartets :
|
||||
winners[i] = dropped_quartets
|
||||
print(winners)
|
||||
for i in range(len(winners)):
|
||||
if winners[i] == temp:
|
||||
print(players[i], "has won the game!")
|
||||
|
||||
# Call central_function() only if quartett.py is the main module
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue