refactor: převod rekurze na smyčky v game() a add_players() #12
@@ -209,6 +209,7 @@ def check_win() -> str:
|
|||||||
return winner
|
return winner
|
||||||
|
|
||||||
def game(data: tuple):
|
def game(data: tuple):
|
||||||
|
while True:
|
||||||
if data[0] == "count":
|
if data[0] == "count":
|
||||||
count = data[1]
|
count = data[1]
|
||||||
th = data[2]
|
th = data[2]
|
||||||
@@ -223,7 +224,6 @@ def game(data: tuple):
|
|||||||
score = 0
|
score = 0
|
||||||
input("Oh no... anyway.")
|
input("Oh no... anyway.")
|
||||||
data = evaluate("k", count, th)
|
data = evaluate("k", count, th)
|
||||||
game(data)
|
|
||||||
else:
|
else:
|
||||||
if count == 0:
|
if count == 0:
|
||||||
count = 6
|
count = 6
|
||||||
@@ -234,7 +234,6 @@ def game(data: tuple):
|
|||||||
)
|
)
|
||||||
inp = input(msg)
|
inp = input(msg)
|
||||||
data = evaluate(inp, count, th)
|
data = evaluate(inp, count, th)
|
||||||
game(data)
|
|
||||||
|
|
||||||
elif data[0] == "msg":
|
elif data[0] == "msg":
|
||||||
if data[1] == "ER01" or data[1] == "ER02" or data[1] == "ER03":
|
if data[1] == "ER01" or data[1] == "ER02" or data[1] == "ER03":
|
||||||
@@ -244,10 +243,10 @@ def game(data: tuple):
|
|||||||
clear()
|
clear()
|
||||||
inp = input(msg)
|
inp = input(msg)
|
||||||
data = evaluate(inp, count, th)
|
data = evaluate(inp, count, th)
|
||||||
game(data)
|
|
||||||
else:
|
else:
|
||||||
msg = data[1]
|
msg = data[1]
|
||||||
print(msg)
|
print(msg)
|
||||||
|
break
|
||||||
|
|
||||||
elif data[0] == "win":
|
elif data[0] == "win":
|
||||||
winner = data[1]
|
winner = data[1]
|
||||||
@@ -256,6 +255,7 @@ def game(data: tuple):
|
|||||||
clear()
|
clear()
|
||||||
print(f"Vítězem se stává {winner} s {score} body!")
|
print(f"Vítězem se stává {winner} s {score} body!")
|
||||||
print("Díky za hru a zase příště.")
|
print("Díky za hru a zase příště.")
|
||||||
|
break
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
clear()
|
clear()
|
||||||
|
|||||||
Reference in new issue
Block a user