active in central_function() is now random

This commit is contained in:
Steinadler 2021-01-13 18:36:39 +01:00
parent 7b6851c9de
commit a0474000ba
1 changed files with 13 additions and 14 deletions

View File

@ -16,20 +16,19 @@ def central_function():
does everything, keeps order does everything, keeps order
''' '''
active = 0 # contains index of the active player
switch = True switch = True
card_stack, players_with_cards, players, complete_card_stack = initialize() card_stack, players_with_cards, players, complete_card_stack = initialize()
active = random.randint(0, len(players) - 1) # contains index of the active player
# stores the dropped cards # stores the dropped cards
all_quartets = [] all_quartets = []
print("players",players) # debug print("players", players) # debug
print("card stack", card_stack) # debug print("card stack", card_stack) # debug
print(players_with_cards) # debug print(players_with_cards) # debug
for i in range(len(players)): # debug for i in range(len(players)): # debug
pretty_print_deck(players_with_cards, i) # debug pretty_print_deck(players_with_cards, i) # debug
print("active", active) # debug print("active", active) # debug
drop_cards(players_with_cards, all_quartets) drop_cards(players_with_cards, all_quartets)
while switch: while switch:
round(card_stack, players_with_cards, players, active, complete_card_stack, all_quartets) round(card_stack, players_with_cards, players, active, complete_card_stack, all_quartets)
@ -264,11 +263,11 @@ def the_winner_is(players_with_cards, players):
winners.append(0) winners.append(0)
dropped_quartets = players_with_cards[i]['quartet'] dropped_quartets = players_with_cards[i]['quartet']
if temp < dropped_quartets : if temp < dropped_quartets:
temp = dropped_quartets temp = dropped_quartets
winners.insert(i, dropped_quartets ) winners.insert(i, dropped_quartets)
if temp == dropped_quartets : if temp == dropped_quartets:
winners[i] = dropped_quartets winners[i] = dropped_quartets
# winners then functions as a template # winners then functions as a template
@ -277,7 +276,7 @@ def the_winner_is(players_with_cards, players):
if winners[i] == temp: if winners[i] == temp:
print(players[i], "has won the game!") print(players[i], "has won the game!")
# Call central_function() only if quartett.py is the main module # Call central_function() only if quartett.py is the main module
if __name__ == "__main__": if __name__ == "__main__":
central_function() central_function()