From e1450a1d301d6d0339853a0e6f49a3faf8cf8d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Wed, 24 Jun 2026 10:14:46 +0200 Subject: [PATCH 1/3] =?UTF-8?q?feature/konec-hry:=20nastaven=C3=AD=20v?= =?UTF-8?q?=C3=ADt=C4=9Bzn=C3=A9ho=20sk=C3=B3re?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 84e7913..1a1a0d7 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ pointer = "" first = "" h_bool = True aggr = {} +final_score = 10000 with open("hodnoty.csv", "r") as csv_file: csv_reader = csv.reader(csv_file) @@ -146,6 +147,7 @@ def add_players(iter=False): global players global pointer global first + global final_score if not iter: var = "prvního hráče" @@ -157,6 +159,11 @@ def add_players(iter=False): if inp == "x": if not iter: add_players() + inp = input("Zadejte finální skóre (nechte prázdné pro výchozích 10 000): ") + if inp != "": + inp = int(inp) + final_score = inp + elif inp == "": print("Jméno nemůže být prázdné.") add_players(iter) @@ -179,7 +186,8 @@ def game(data: tuple): if(th == ""): th = throw(count) clear() - print(f"Na tahu je {pointer} ({aggr[pointer]})") + print(f"Vítězné skóre: {final_score}.") + 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 @@ -213,6 +221,7 @@ def game(data: tuple): print(msg) def main(): + clear() print("Vítejte ve hře v kostky!") add_players() input("Prosím, stiskněte enter pro první hod:") -- 2.47.3 From 4ec5a15e321b3526c6f6f749c12e58b1a4556390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Wed, 24 Jun 2026 23:34:00 +0200 Subject: [PATCH 2/3] =?UTF-8?q?feature/konec-hry:=20vyhodnocen=C3=AD=20v?= =?UTF-8?q?=C3=ADt=C4=9Bze=20v=C4=8Detn=C4=9B=20p=C5=99=C3=ADpadu=20stejn?= =?UTF-8?q?=C3=A9ho=20po=C4=8Dtu=20bod=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/main.py b/main.py index 1a1a0d7..0a6331f 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from random import randint from os import system, name import re import csv +from collections import Counter score = 0 hodnoty = {} @@ -127,6 +128,10 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple: h_bool = True next_player() data = ("count", 6, "") + if pointer == first: + winner = check_win() + if winner: + data = ("win", winner, aggr[winner]) return data else: data = ("msg", "ER03", "Zadejte prosím platnou hodnotu:", count, throw) @@ -179,6 +184,30 @@ def add_players(iter=False): first = inp add_players(True) +def check_win() -> str: + over_limit = {} + for p in aggr: + if aggr[p] >= final_score: + over_limit[p] = aggr[p] + + i = 1 + winner = "" + + if over_limit: + over_limit_sorted = dict(sorted(over_limit.items(), key=lambda x: x[1], reverse=True)) + over_limit_sorted_list = [] + for ols in over_limit_sorted: + over_limit_sorted_list.append((ols, over_limit_sorted[ols])) + + + count = Counter(list(over_limit_sorted.values())) + + for c in count: + if i == 1: + if count[c] == 1: + winner = over_limit_sorted_list[0][0] + return winner + def game(data: tuple): if data[0] == "count": count = data[1] @@ -219,6 +248,14 @@ def game(data: tuple): else: msg = data[1] print(msg) + + elif data[0] == "win": + winner = data[1] + score = data[2] + + clear() + print(f"Vítězem se stává {winner} s {score} body!") + print("Díky za hru a zase příště.") def main(): clear() -- 2.47.3 From e550f7d50ac244f996d12db4ad4b7e2167987054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Wed, 24 Jun 2026 23:53:07 +0200 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20opraveno=20iterov=C3=A1n=C3=AD=20v?= =?UTF-8?q?=C3=ADt=C4=9Bze=20v=20check=5Fwin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 0a6331f..1af2f02 100644 --- a/main.py +++ b/main.py @@ -190,7 +190,6 @@ def check_win() -> str: if aggr[p] >= final_score: over_limit[p] = aggr[p] - i = 1 winner = "" if over_limit: @@ -203,9 +202,10 @@ def check_win() -> str: count = Counter(list(over_limit_sorted.values())) for c in count: - if i == 1: - if count[c] == 1: - winner = over_limit_sorted_list[0][0] + if count[c] == 1: + winner = over_limit_sorted_list[0][0] + break + return winner def game(data: tuple): -- 2.47.3