feature: multiplayer – registrace hráčů, střídání tahů a agregace skóre #9
@@ -9,6 +9,7 @@ hodnoty = {}
|
|||||||
players = {}
|
players = {}
|
||||||
pointer = ""
|
pointer = ""
|
||||||
first = ""
|
first = ""
|
||||||
|
h_bool = True
|
||||||
|
|
||||||
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)
|
||||||
@@ -48,6 +49,9 @@ def clear():
|
|||||||
_ = system('clear')
|
_ = system('clear')
|
||||||
|
|
||||||
def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
||||||
|
|
||||||
|
global h_bool
|
||||||
|
|
||||||
def eval_score(pick: str) -> bool:
|
def eval_score(pick: str) -> bool:
|
||||||
if(pick in hodnoty):
|
if(pick in hodnoty):
|
||||||
global score
|
global score
|
||||||
@@ -99,16 +103,25 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
|||||||
if eval_score(pick) == False:
|
if eval_score(pick) == False:
|
||||||
new_count = count
|
new_count = count
|
||||||
old_throw = throw
|
old_throw = throw
|
||||||
|
else:
|
||||||
|
h_bool = False
|
||||||
|
|
||||||
data = ("count", new_count, old_throw)
|
data = ("count", new_count, old_throw)
|
||||||
return data
|
return data
|
||||||
elif inp == "h":
|
elif inp == "h":
|
||||||
data = ("count", count, "")
|
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
|
return data
|
||||||
elif inp == "k":
|
elif inp == "k":
|
||||||
global score
|
global score
|
||||||
players[pointer].append(score)
|
players[pointer].append(score)
|
||||||
score = 0
|
score = 0
|
||||||
|
h_bool = True
|
||||||
next_player()
|
next_player()
|
||||||
data = ("count", 6, "")
|
data = ("count", 6, "")
|
||||||
return data
|
return data
|
||||||
@@ -175,6 +188,7 @@ 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