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