feature: multiplayer – registrace hráčů, střídání tahů a agregace skóre #9
@@ -10,6 +10,7 @@ players = {}
|
|||||||
pointer = ""
|
pointer = ""
|
||||||
first = ""
|
first = ""
|
||||||
h_bool = True
|
h_bool = True
|
||||||
|
aggr = {}
|
||||||
|
|
||||||
with open("hodnoty.csv", "r") as csv_file:
|
with open("hodnoty.csv", "r") as csv_file:
|
||||||
csv_reader = csv.reader(csv_file)
|
csv_reader = csv.reader(csv_file)
|
||||||
@@ -120,6 +121,7 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
|||||||
elif inp == "k":
|
elif inp == "k":
|
||||||
global score
|
global score
|
||||||
players[pointer].append(score)
|
players[pointer].append(score)
|
||||||
|
aggr[pointer] = sum(players[pointer])
|
||||||
score = 0
|
score = 0
|
||||||
h_bool = True
|
h_bool = True
|
||||||
next_player()
|
next_player()
|
||||||
@@ -160,6 +162,7 @@ def add_players(iter=False):
|
|||||||
print("Zadávejte, prosím, unikátní jména.")
|
print("Zadávejte, prosím, unikátní jména.")
|
||||||
else:
|
else:
|
||||||
players[inp] = []
|
players[inp] = []
|
||||||
|
aggr[inp] = 0
|
||||||
print(f"Do seznamu přidáno jméno {inp}.")
|
print(f"Do seznamu přidáno jméno {inp}.")
|
||||||
if not iter:
|
if not iter:
|
||||||
pointer = inp
|
pointer = inp
|
||||||
@@ -173,6 +176,7 @@ def game(data: tuple):
|
|||||||
if(th == ""):
|
if(th == ""):
|
||||||
th = throw(count)
|
th = throw(count)
|
||||||
clear()
|
clear()
|
||||||
|
print(f"Na tahu je {pointer} ({aggr[pointer]})")
|
||||||
print(show_throw(th))
|
print(show_throw(th))
|
||||||
if not check_value(th) and data[2] == "" and count != 0:
|
if not check_value(th) and data[2] == "" and count != 0:
|
||||||
global score
|
global score
|
||||||
@@ -188,7 +192,6 @@ def game(data: tuple):
|
|||||||
" - Hodit znovu: [h].\n"
|
" - Hodit znovu: [h].\n"
|
||||||
f" - Ukončit hod a ponechat si skóre z tohoto hodu ({score}): [k].\n"
|
f" - Ukončit hod a ponechat si skóre z tohoto hodu ({score}): [k].\n"
|
||||||
)
|
)
|
||||||
print(players)
|
|
||||||
# if old_throw != "":
|
# if old_throw != "":
|
||||||
# msg += f"\nHodnoty odložených kostek: {old_throw}"
|
# msg += f"\nHodnoty odložených kostek: {old_throw}"
|
||||||
inp = input(msg)
|
inp = input(msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user