added return value for initialize()

This commit is contained in:
Steinadler 2021-01-11 16:49:05 +01:00
parent 469857aec3
commit 87e615abe4
1 changed files with 20 additions and 14 deletions

View File

@ -11,9 +11,17 @@ def central_function():
active = 0 # contains index of the active player
..., players_with_cards, players = initialize()[0], initialize()[1], initialize()[2]
while deckP1 and deckP2 and deckP3 not empty:
round(..., players_with_cards, players)
card_stack, players_with_cards, players = initialize()
# print(card_stack)
# print(str(len(card_stack)))
#
# print(players_with_cards)
# print(str(len(players_with_cards)))
#
# print(players)
#while deckP1 and deckP2 and deckP3 not empty:
# round(..., players_with_cards, players)
# TO DO implement active_player rotation
@ -40,7 +48,7 @@ def choose(..., players_with_cards, players):
else:
# end of round
if stack == exists:
# TO DO player.values + card_from_stack
# TODO: player.values + card_from_stack
break
@ -54,7 +62,7 @@ def initialize():
:return:
"""
card_deck = []
card_stack = []
players = []
players_with_cards = []
@ -62,7 +70,7 @@ def initialize():
for i in range(4):
for l in "abcdefgh":
d = {"id": x, "number": i, "letter": l}
card_deck.append(d)
card_stack.append(d)
x += 1
number_of_players = clean_input.io_int("Mit wie vielen Spielern wollen Sie spielen?")
@ -74,24 +82,22 @@ def initialize():
if len(players) == 2:
cards_per_player = 10
else:
cards_per_player = int(len(card_deck) // len(players))
cards_per_player = int(len(card_stack) // len(players))
for i in range(number_of_players): # Select cards for x players
cards_of_player = [] # Player deck
for j in range(cards_per_player): # Select ten cards
x = random.randint(0, len(card_deck) - 1) # Select one random card
selected_card = card_deck[x]
del card_deck[x] # Remove card from main card deck.
x = random.randint(0, len(card_stack) - 1) # Select one random card
selected_card = card_stack[x]
del card_stack[x] # Remove card from main card deck.
cards_of_player.append(selected_card)
# Add list of dicts (cards) to players
players_with_cards.append({"player": players[i], "cards_on_hand": cards_of_player})
# print(len(card_deck))
# print(players_with_cards)
return ..., players_with_cards, players # TODO: clarify what is returned, this is needed is central()
return card_stack, players_with_cards, players
central_function()
'''
players_with_cards = [
{'player': 'player0', 'cards_on_hand': [{'id': 13, 'number': 1, 'letter': 'f'},