From c1e94faf9896efbc68b9e42390c865f8761043e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Fri, 19 Jun 2026 17:05:19 +0200 Subject: [PATCH] =?UTF-8?q?feature:=20funkce=20game=20nyn=C3=AD=20dost?= =?UTF-8?q?=C3=A1v=C3=A1=20jako=20argument=20tuple:=20na=20prvn=C3=ADm=20m?= =?UTF-8?q?=C3=ADst=C4=9B=20je=20v=C5=BEdy=20typ=20p=C5=99ed=C3=A1van?= =?UTF-8?q?=C3=BDch=20dat=20(zat=C3=ADm=20"count"/"msg")=20funkce=20evalua?= =?UTF-8?q?te=20kontroluje=20maxim=C3=A1ln=C3=AD=20mo=C5=BEn=C3=BD=20po?= =?UTF-8?q?=C4=8Det=20hozen=C3=BDch=20kostek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 106525d..cc6ff48 100644 --- a/main.py +++ b/main.py @@ -28,22 +28,36 @@ def clear(): def evaluate(inp, count): inp = str(inp) if re.search("^\d+$", inp): - count = len(inp) - return count + if len(inp) > count: + data = ("msg", "ER01", "Tolika kostkami nemůžete hodit. Zkuste to znovu:", count) + return data + else: + count = len(inp) + data = ("count", count) + return data -def game(count): - new_throw = throw(count) - clear() - print(show_throw(new_throw)) - inp = input("Vyberte, kterými kostkami chcete hodit znovu (např. 135):") - count = evaluate(inp, count) - game(count) +def game(data: tuple): + if data[0] == "count": + count = data[1] + new_throw = throw(count) + clear() + print(show_throw(new_throw)) + inp = input("Vyberte, kterými kostkami chcete hodit znovu (např. 135):") + data = evaluate(inp, count) + game(data) + elif data[0] == "msg": + if data[1] == "ER01": + msg = data[2] + count = data[3] + inp = input(msg) + data = evaluate(inp, count) + game(data) def main(): print("Vítejte ve hře v kostky!") input("Prosím, stiskněte enter pro první hod:") - count = 6 - game(count) + data = ("count", 6) + game(data) if __name__ == "__main__": main()