modified drop_cards_help()
This commit is contained in:
parent
9b628e5917
commit
4484a60f26
55
quartett.py
55
quartett.py
|
@ -6,7 +6,7 @@ __email__ = ""
|
|||
|
||||
import random
|
||||
import clean_input
|
||||
#import itertools
|
||||
import itertools
|
||||
|
||||
|
||||
# Game
|
||||
|
@ -16,6 +16,8 @@ def central_function():
|
|||
|
||||
active = 0 # contains index of the active player
|
||||
|
||||
switch = True
|
||||
|
||||
card_stack, players_with_cards, players = initialize()
|
||||
print(players)
|
||||
drop_cards(players_with_cards)
|
||||
|
@ -27,7 +29,7 @@ def central_function():
|
|||
|
||||
for i in itertools.cycle(range(len(players))): # rotate active player
|
||||
active = i
|
||||
#the_winner_is()
|
||||
# the_winner_is()
|
||||
|
||||
|
||||
def round(card_stack, players_with_cards, players, active):
|
||||
|
@ -72,27 +74,29 @@ def steal(active, chosen_player, players_with_cards, player_request):
|
|||
players_with_cards[active]['cards_on_hand'].append(
|
||||
players_with_cards[chosen_player]['cards_on_hand'].pop(player_request))
|
||||
|
||||
def drop_cards(players_with_cards, active = None):
|
||||
|
||||
def drop_cards(players_with_cards, active=None):
|
||||
"""
|
||||
function that lets players drop cards
|
||||
if they have a quartet in their deck
|
||||
:return: None
|
||||
"""
|
||||
|
||||
#default, check all players
|
||||
# default, check all players
|
||||
if active is None:
|
||||
for p in players_with cards:
|
||||
for p in players_with_cards:
|
||||
drop_cards_help(p)
|
||||
|
||||
else:
|
||||
p = players_with_cards[active]
|
||||
drop_cards_help(p)
|
||||
|
||||
def drop_cards_help(players_with_cards,p):
|
||||
|
||||
def drop_cards_help(p):
|
||||
"""
|
||||
eh
|
||||
"""
|
||||
reference = ['a','b','c','d','e','f','g','h']
|
||||
reference = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
|
||||
counter = [0, 0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
for card in p["cards_on_hand"]:
|
||||
|
@ -100,10 +104,15 @@ def drop_cards_help(players_with_cards,p):
|
|||
|
||||
for i in counter:
|
||||
if i == 4:
|
||||
quartet_letter = reference[index(i)]
|
||||
for card in p["cards_on_hand"]:
|
||||
if card["letter"] == quartet_letter:
|
||||
del card
|
||||
quartet_letter = reference[counter.index(i)]
|
||||
counter[counter.index(i)] = 0
|
||||
p["quartet"] += 1
|
||||
print(f"{p['player']} legt das {quartet_letter}-Quartett ab...")
|
||||
p["cards_on_hand"] = [c for c in p["cards_on_hand"] if quartet_letter != c["letter"]]
|
||||
|
||||
# print(p)
|
||||
return p
|
||||
|
||||
|
||||
def initialize():
|
||||
"""
|
||||
|
@ -146,21 +155,37 @@ def initialize():
|
|||
cards_of_player.append(selected_card)
|
||||
|
||||
# create a list that contains every player, their deck and successes
|
||||
players_with_cards.append({"player": players[i], "cards_on_hand": cards_of_player, "quartet": 0})
|
||||
players_with_cards.append(
|
||||
{"player": players[i], "cards_on_hand": cards_of_player, "quartet": 0})
|
||||
|
||||
return card_stack, players_with_cards, players
|
||||
|
||||
#def the_winner_is():
|
||||
|
||||
def the_winner_is():
|
||||
"""
|
||||
counts the number of quartets
|
||||
a player has made, and chooses the
|
||||
winner, who made the most
|
||||
"""
|
||||
#TODO
|
||||
pass
|
||||
# TODO
|
||||
|
||||
|
||||
# Call central_function() only if quartett.py is the main module
|
||||
if __name__ == "__main__":
|
||||
central_function()
|
||||
p = {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
|
||||
{'id': '3', 'number': '0', 'letter': 'd'},
|
||||
{'id': '25', 'number': '3', 'letter': 'd'},
|
||||
{'id': '19', 'number': '2', 'letter': 'd'},
|
||||
{'id': '0', 'number': '0', 'letter': 'a'},
|
||||
{'id': '28', 'number': '3', 'letter': 'a'},
|
||||
{'id': '26', 'number': '3', 'letter': 'a'},
|
||||
{'id': '5', 'number': '0', 'letter': 'a'},
|
||||
{'id': '9', 'number': '1', 'letter': 'b'},
|
||||
{'id': '7', 'number': '0', 'letter': 'h'}],
|
||||
'quartet': 0}
|
||||
drop_cards_help(p)
|
||||
# central_function()
|
||||
|
||||
'''
|
||||
players_with_cards = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user