From 5b282416de402ebca7477830ee5687f690650ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Mon, 22 Jun 2026 19:24:08 +0200 Subject: [PATCH 01/10] =?UTF-8?q?feature/hraci:=20z=C3=A1kladn=C3=AD=20log?= =?UTF-8?q?ika=20pro=20p=C5=99id=C3=A1n=C3=AD=20hr=C3=A1=C4=8D=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/main.py b/main.py index 320e72e..d0c6e12 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,8 @@ import csv score = 0 hodnoty = {} +players = {} +pointer = "" with open("hodnoty.csv", "r") as csv_file: csv_reader = csv.reader(csv_file) @@ -100,6 +102,33 @@ def check_value(throw: str) -> bool: return hodnota +def add_players(iter=False): + global players + global pointer + + if not iter: + var = "prvního hráče" + else: + var = "dalšího hráče nebo [x] pro ukončení zadávání hráčů" + + inp = input(f"Zadejte jméno {var}: ") + + if inp == "x": + if not iter: + add_players() + elif inp == "": + print("Jméno nemůže být prázdné.") + add_players(iter) + else: + if inp in players: + print("Zadávejte, prosím, unikátní jména.") + else: + players[inp] = [] + print(f"Do seznamu přidáno jméno {inp}.") + if not iter: + pointer = inp + add_players(True) + def game(data: tuple): if data[0] == "count": count = data[1] @@ -136,6 +165,7 @@ def game(data: tuple): def main(): print("Vítejte ve hře v kostky!") + add_players() input("Prosím, stiskněte enter pro první hod:") data = ("count", 6, "") game(data) -- 2.47.3 From 6ad58046a68c58776e1c79af54d8eb639fec76cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 21:08:47 +0200 Subject: [PATCH 02/10] =?UTF-8?q?feature/hraci:=20dal=C5=A1=C3=AD=20hod=20?= =?UTF-8?q?v=20r=C3=A1mci=20"tahu"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.py b/main.py index d0c6e12..62555be 100644 --- a/main.py +++ b/main.py @@ -90,6 +90,9 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: data = ("count", new_count, old_throw) return data + elif inp == "h": + data = ("count", count, "") + return data def check_value(throw: str) -> bool: throw_s = sorted(throw) -- 2.47.3 From 7e412f4d9efee3b0d391cae19fd399eec15fd4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 21:17:35 +0200 Subject: [PATCH 03/10] =?UTF-8?q?feature/hraci:=20pomocn=C3=A1=20funkce=20?= =?UTF-8?q?next=5Fplayer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.py b/main.py index 62555be..633f49e 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ score = 0 hodnoty = {} players = {} pointer = "" +first = "" with open("hodnoty.csv", "r") as csv_file: csv_reader = csv.reader(csv_file) @@ -55,6 +56,17 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: else: return False + def next_player() -> None: + global pointer + + keys_iter = iter(players) + for key in keys_iter: + if key == pointer: + nxt_key = next(keys_iter, first) + break + + pointer = nxt_key + inp = str(inp) if re.search("^\d+$", inp): if len(inp) > count: @@ -108,6 +120,7 @@ def check_value(throw: str) -> bool: def add_players(iter=False): global players global pointer + global first if not iter: var = "prvního hráče" @@ -130,6 +143,7 @@ def add_players(iter=False): print(f"Do seznamu přidáno jméno {inp}.") if not iter: pointer = inp + first = inp add_players(True) def game(data: tuple): -- 2.47.3 From 9added32009ae56de00c2e0c8359e8e15b80547c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 21:31:15 +0200 Subject: [PATCH 04/10] =?UTF-8?q?feature/hraci:=20vyhodnocen=C3=AD=20konce?= =?UTF-8?q?=20"tahu";=20p=C5=99epnut=C3=AD=20na=20dal=C5=A1=C3=ADho=20hr?= =?UTF-8?q?=C3=A1=C4=8De=20v=20=C5=99ad=C4=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 633f49e..2484b49 100644 --- a/main.py +++ b/main.py @@ -68,7 +68,7 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: pointer = nxt_key inp = str(inp) - if re.search("^\d+$", inp): + if re.search(r"^\d+$", inp): if len(inp) > count: data = ("msg", "ER01", "Tolika kostkami nemůžete hodit. Zkuste to znovu:", count, throw) return data @@ -105,6 +105,13 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: elif inp == "h": data = ("count", count, "") return data + elif inp == "k": + global score + players[pointer].append(score) + score = 0 + next_player() + data = ("count", 6, "") + return data def check_value(throw: str) -> bool: throw_s = sorted(throw) -- 2.47.3 From 61dc5056ff74cb21566b8b3a6fe170128187e264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 21:38:17 +0200 Subject: [PATCH 05/10] =?UTF-8?q?feature/hraci:=20o=C5=A1et=C5=99en=C3=AD?= =?UTF-8?q?=20edge-case:=20hot=20dice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 2484b49..8250dec 100644 --- a/main.py +++ b/main.py @@ -161,9 +161,11 @@ def game(data: tuple): th = throw(count) clear() print(show_throw(th)) - if not check_value(th) and data[2] == "": + if not check_value(th) and data[2] == "" and count != 0: print("Smůla, třeba příště.") else: + if count == 0: + count = 6 msg = ("Jakou akci chcete provést?\n" " - Zadejte kombinaci kostek k ponechání (dojde k jejich vyhodnocení): [pozice kostek] (např. 1 nebo 34 nebo 123456).\n" " - Hodit znovu: [h].\n" -- 2.47.3 From 83f4a222ade3891956df80554058a10a8dc1f3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 21:49:40 +0200 Subject: [PATCH 06/10] =?UTF-8?q?feature/hraci:=20hod=20s=20nulovou=20hodn?= =?UTF-8?q?otou=20zap=C3=AD=C5=A1e=200=20bod=C5=AF=20a=20p=C5=99epne=20na?= =?UTF-8?q?=20dal=C5=A1=C3=ADho=20hr=C3=A1=C4=8De?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 8250dec..1306607 100644 --- a/main.py +++ b/main.py @@ -162,7 +162,11 @@ def game(data: tuple): clear() print(show_throw(th)) if not check_value(th) and data[2] == "" and count != 0: - print("Smůla, třeba příště.") + global score + score = 0 + input("Oh no... anyway.") + data = evaluate("k", count, th) + game(data) else: if count == 0: count = 6 -- 2.47.3 From cf21f7fbdde411f5abb6164b4492c097bbe6a4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 22:04:44 +0200 Subject: [PATCH 07/10] =?UTF-8?q?feature/hraci:=20z=C3=A1kaz=20nov=C3=A9ho?= =?UTF-8?q?=20hodu=20v=C3=ADce=20ne=C5=BE=20jednou=20v=20=C5=99ad=C4=9B=20?= =?UTF-8?q?(v=C4=8Detn=C4=9B=20hodu=20n=C3=A1sleduj=C3=ADc=C3=ADho=20po=20?= =?UTF-8?q?prvn=C3=ADm=20hodu=20tahu)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1306607..a77dfe7 100644 --- a/main.py +++ b/main.py @@ -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": - 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 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) -- 2.47.3 From 0e134eb4a873f0a594887206e4c661e7004ccf1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 22:15:31 +0200 Subject: [PATCH 08/10] =?UTF-8?q?feature/hraci:=20p=C5=99id=C3=A1n=20ukaza?= =?UTF-8?q?tel=20aktivn=C3=ADho=20hr=C3=A1=C4=8De=20s=20aktu=C3=A1ln=C3=AD?= =?UTF-8?q?m=20sk=C3=B3re=20p=C5=99es=20agrega=C4=8Dn=C3=AD=20prom=C4=9Bnn?= =?UTF-8?q?ou?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index a77dfe7..820743e 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ players = {} pointer = "" first = "" h_bool = True +aggr = {} with open("hodnoty.csv", "r") as csv_file: csv_reader = csv.reader(csv_file) @@ -120,6 +121,7 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: elif inp == "k": global score players[pointer].append(score) + aggr[pointer] = sum(players[pointer]) score = 0 h_bool = True next_player() @@ -160,6 +162,7 @@ def add_players(iter=False): print("Zadávejte, prosím, unikátní jména.") else: players[inp] = [] + aggr[inp] = 0 print(f"Do seznamu přidáno jméno {inp}.") if not iter: pointer = inp @@ -173,6 +176,7 @@ def game(data: tuple): if(th == ""): th = throw(count) clear() + print(f"Na tahu je {pointer} ({aggr[pointer]})") print(show_throw(th)) if not check_value(th) and data[2] == "" and count != 0: global score @@ -188,7 +192,6 @@ 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) -- 2.47.3 From 973a08ebd51bc7c956542426ea64b3f801d9f1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 22:28:00 +0200 Subject: [PATCH 09/10] =?UTF-8?q?feature/hraci:=20o=C5=A1et=C5=99en=C3=AD?= =?UTF-8?q?=20pr=C3=A1zdn=C3=A9ho=20vstupu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 820743e..10bd7a1 100644 --- a/main.py +++ b/main.py @@ -127,6 +127,9 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: next_player() data = ("count", 6, "") return data + else: + data = ("msg", "ER03", "Zadejte prosím platnou hodnotu:", count, throw) + return data def check_value(throw: str) -> bool: throw_s = sorted(throw) @@ -192,6 +195,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(f"Count je {count}") # if old_throw != "": # msg += f"\nHodnoty odložených kostek: {old_throw}" inp = input(msg) @@ -199,10 +203,11 @@ def game(data: tuple): game(data) elif data[0] == "msg": - if data[1] == "ER01" or data[1] == "ER02": + if data[1] == "ER01" or data[1] == "ER02" or data[1] == "ER03": msg = data[2] count = data[3] th = data[4] + clear() inp = input(msg) data = evaluate(inp, count, th) game(data) -- 2.47.3 From 1cd796d3d92206d1bccdd5da0c803a302056196b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Tue, 23 Jun 2026 22:35:37 +0200 Subject: [PATCH 10/10] =?UTF-8?q?refactor:=20=C4=8Di=C5=A1t=C4=9Bn=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.py b/main.py index 10bd7a1..84e7913 100644 --- a/main.py +++ b/main.py @@ -101,7 +101,7 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: new_count = len(old_throw) - if eval_score(pick) == False: + if not eval_score(pick): new_count = count old_throw = throw else: @@ -195,9 +195,6 @@ def game(data: tuple): " - Hodit znovu: [h].\n" f" - Ukončit hod a ponechat si skóre z tohoto hodu ({score}): [k].\n" ) - print(f"Count je {count}") - # if old_throw != "": - # msg += f"\nHodnoty odložených kostek: {old_throw}" inp = input(msg) data = evaluate(inp, count, th) game(data) -- 2.47.3