feature: multiplayer – registrace hráčů, střídání tahů a agregace skóre #9
@@ -9,6 +9,7 @@ hodnoty = {}
|
||||
players = {}
|
||||
pointer = ""
|
||||
first = ""
|
||||
h_bool = True
|
||||
|
||||
with open("hodnoty.csv", "r") as csv_file:
|
||||
csv_reader = csv.reader(csv_file)
|
||||
@@ -48,6 +49,9 @@ def clear():
|
||||
_ = system('clear')
|
||||
|
||||
def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
||||
|
||||
global h_bool
|
||||
|
||||
def eval_score(pick: str) -> bool:
|
||||
if(pick in hodnoty):
|
||||
global score
|
||||
@@ -99,16 +103,25 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
||||
if eval_score(pick) == False:
|
||||
new_count = count
|
||||
old_throw = throw
|
||||
else:
|
||||
h_bool = False
|
||||
|
||||
data = ("count", new_count, old_throw)
|
||||
return data
|
||||
elif inp == "h":
|
||||
if h_bool:
|
||||
clear()
|
||||
input("Nemůžete házet znovu, dokud nevyhodnotíte některé kostky.")
|
||||
data = ("count", count, throw)
|
||||
else:
|
||||
h_bool = True
|
||||
data = ("count", count, "")
|
||||
return data
|
||||
elif inp == "k":
|
||||
global score
|
||||
players[pointer].append(score)
|
||||
score = 0
|
||||
h_bool = True
|
||||
next_player()
|
||||
data = ("count", 6, "")
|
||||
return data
|
||||
@@ -175,6 +188,7 @@ def game(data: tuple):
|
||||
" - Hodit znovu: [h].\n"
|
||||
f" - Ukončit hod a ponechat si skóre z tohoto hodu ({score}): [k].\n"
|
||||
)
|
||||
print(players)
|
||||
# if old_throw != "":
|
||||
# msg += f"\nHodnoty odložených kostek: {old_throw}"
|
||||
inp = input(msg)
|
||||
|
||||
Reference in New Issue
Block a user