From 754119980fa86c84395051d4759418d6bbd9bb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:05:57 +0200 Subject: [PATCH 1/9] package: update .gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7bfcd7a..067e3b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ __pycache__/ -*.pyc \ No newline at end of file +*.pyc +dist/ +build/ +*.egg-info/ \ No newline at end of file -- 2.47.3 From 388c92f81782fd089c086ab2829aa48f3f6f984d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:09:15 +0200 Subject: [PATCH 2/9] =?UTF-8?q?package:=20p=C5=99esuny=20soubor=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hodnoty.csv => kostky/hodnoty.csv | 0 main.py => kostky/main.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename hodnoty.csv => kostky/hodnoty.csv (100%) rename main.py => kostky/main.py (100%) diff --git a/hodnoty.csv b/kostky/hodnoty.csv similarity index 100% rename from hodnoty.csv rename to kostky/hodnoty.csv diff --git a/main.py b/kostky/main.py similarity index 100% rename from main.py rename to kostky/main.py -- 2.47.3 From 9d5c51a17a7a1df5f9acaabd04bb5dfb1c20f1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:09:43 +0200 Subject: [PATCH 3/9] =?UTF-8?q?package:=20bezpe=C4=8Dn=C3=A9=20otev=C3=ADr?= =?UTF-8?q?=C3=A1n=C3=AD=20csv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kostky/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kostky/main.py b/kostky/main.py index d103c9d..deeba69 100644 --- a/kostky/main.py +++ b/kostky/main.py @@ -2,6 +2,7 @@ from typing import Any from random import randint from os import system, name import re +from importlib.resources import files import csv from collections import Counter from tabulate import tabulate @@ -16,7 +17,8 @@ aggr: dict[str, int] = {} final_score: int = 10000 with open("hodnoty.csv", "r") as csv_file: - csv_reader = csv.reader(csv_file) + csv_text = files(__package__).joinpath("hodnoty.csv").read_text(encoding="utf-8") + csv_reader = csv.reader(csv_text.splitlines()) for row in csv_reader: key = str(row[0]) -- 2.47.3 From 38080814827cfe8f991f2bf6731f415d26dc4369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:10:02 +0200 Subject: [PATCH 4/9] =?UTF-8?q?package:=20povinn=C3=A1=20struktura?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kostky/__init__.py | 0 kostky/__main__.py | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 kostky/__init__.py create mode 100644 kostky/__main__.py diff --git a/kostky/__init__.py b/kostky/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/kostky/__main__.py b/kostky/__main__.py new file mode 100644 index 0000000..598d4c0 --- /dev/null +++ b/kostky/__main__.py @@ -0,0 +1,4 @@ +from kostky.main import main + +if __name__ == "__main__": + main() \ No newline at end of file -- 2.47.3 From 9346735af6367e869bda46c34064850387b2d3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:16:04 +0200 Subject: [PATCH 5/9] =?UTF-8?q?package:=20p=C5=99ejmenovat=20main.py=20na?= =?UTF-8?q?=20kostky.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kostky/{main.py => kostky.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename kostky/{main.py => kostky.py} (100%) diff --git a/kostky/main.py b/kostky/kostky.py similarity index 100% rename from kostky/main.py rename to kostky/kostky.py -- 2.47.3 From a31eff26fda7a37f88ef2c93e5a43eb50e873c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:18:16 +0200 Subject: [PATCH 6/9] =?UTF-8?q?package:=20p=C5=99idat=20pyproject.toml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ce6429b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "kostky" +dynamic = ["version"] +description = "Textová hra v kostky." +readme = "README.md" +requires-python = ">=3.9" +license = "GPL-3.0-or-later" +license-files = ["LICENSE"] +authors = [{ name = "David Spáčil" }] +keywords = ["hra", "kostky", "cli"] +classifiers = [ + "Programming Language :: Python :: 3", + "Environment :: Console", + "Operating System :: OS Independent", + "Topic :: Games/Entertainment", +] +dependencies = [ + "tabulate", +] + +[project.optional-dependencies] +dev = ["mypy", "ruff", "types-tabulate"] + +[project.urls] +Repository = "https://gitea.spacilovi.eu/david/kostky" + +[project.scripts] +kostky = "kostky.kostky:main" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.targets.wheel] +packages = ["kostky"] + +[tool.mypy] +python_version = "3.9" +strict = true +files = ["kostky"] + +[tool.ruff] +target-version = "py39" +line-length = 100 + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B", "SIM"] \ No newline at end of file -- 2.47.3 From a9ef19ee528b4b595000e080f2a355a49c8fa3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:18:37 +0200 Subject: [PATCH 7/9] =?UTF-8?q?package:=20zm=C4=9Bna=20n=C3=A1zvu=20import?= =?UTF-8?q?u=20v=20=5F=5Fmain=5F=5F.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kostky/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kostky/__main__.py b/kostky/__main__.py index 598d4c0..ac32257 100644 --- a/kostky/__main__.py +++ b/kostky/__main__.py @@ -1,4 +1,4 @@ -from kostky.main import main +from kostky.kostky import main if __name__ == "__main__": main() \ No newline at end of file -- 2.47.3 From 69b30552cb3c52536ba1587d66cc9cba6abf69af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:38:40 +0200 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20opravy=20(na=C4=8D=C3=ADt=C3=A1n?= =?UTF-8?q?=C3=AD=20csv=20+=20ruff)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kostky/kostky.py | 62 +++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/kostky/kostky.py b/kostky/kostky.py index deeba69..1d063ea 100644 --- a/kostky/kostky.py +++ b/kostky/kostky.py @@ -1,10 +1,11 @@ -from typing import Any -from random import randint -from os import system, name -import re -from importlib.resources import files import csv +import re from collections import Counter +from importlib.resources import files +from os import name, system +from random import randint +from typing import Any + from tabulate import tabulate score: int = 0 @@ -16,20 +17,19 @@ h_bool: bool = True aggr: dict[str, int] = {} final_score: int = 10000 -with open("hodnoty.csv", "r") as csv_file: - csv_text = files(__package__).joinpath("hodnoty.csv").read_text(encoding="utf-8") - csv_reader = csv.reader(csv_text.splitlines()) +csv_text = files(__package__).joinpath("hodnoty.csv").read_text(encoding="utf-8") +csv_reader = csv.reader(csv_text.splitlines()) - for row in csv_reader: - key = str(row[0]) - value = int(row[1]) +for row in csv_reader: + key = str(row[0]) + value = int(row[1]) - hodnoty[key] = value + hodnoty[key] = value def throw(count: int) -> str: count = int(count) new_throw: list[str] = [] - for dice in range(count): + for _dice in range(count): new_throw.append(str(randint(1, 6))) new_throw_str: str = "".join(new_throw) return new_throw_str @@ -41,7 +41,7 @@ def show_throw(throw: str) -> str: pretty_list: str = ", ".join(throw_temp) pretty_list += "\n" - for i in range(1, len(throw_temp) + 1): + for _i in range(1, len(throw_temp) + 1): pretty_list += "^ " pretty_list += "\n" for i in range(1, len(throw_temp) + 1): @@ -49,10 +49,7 @@ def show_throw(throw: str) -> str: return pretty_list def clear() -> None: - if name == 'nt': - _ = system('cls') - else: - _ = system('clear') + _ = system('cls') if name == 'nt' else system('clear') def evaluate(inp: Any, count: int, throw: str) -> tuple[Any, ...]: @@ -80,16 +77,25 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple[Any, ...]: inp = str(inp) if re.search(r"^\d+$", inp): if len(inp) > count: - data: tuple[Any, ...] = ("msg", "ER01", "Tolika kostkami nemůžete hodit. Zkuste to znovu: ", count, throw) + data: tuple[Any, ...] = ( + "msg", + "ER01", + "Tolika kostkami nemůžete hodit. Zkuste to znovu: ", + count, + throw + ) else: for x in inp: x = int(x) if x > count: - if count == 1: - ran = "1" - else: - ran = f"1–{count}" - data = ("msg", "ER02", f"Zvolte prosím kostky v platném rozsahu ({ran}): ", count, throw) + ran = "1" if count == 1 else f"1–{count}" + data = ( + "msg", + "ER02", + f"Zvolte prosím kostky v platném rozsahu ({ran}): ", + count, + throw + ) return data old_throw: list[str] = [] pick: list[str] = [] @@ -205,8 +211,9 @@ def add_players() -> None: else: break -def to_sorted_tuple(d: dict[str, int], s: bool = True) -> tuple[list[tuple[int, str, int]], dict[str, int]]: - L: list[tuple[str, int]] = [] +def to_sorted_tuple(d: dict[str, int], s: bool = True) -> (tuple[list[tuple[int, str, int]], + dict[str, int]]): + L: list[tuple[int, str, int]] = [] if s: d = dict(sorted(d.items(), key=lambda x: x[1], reverse=True)) @@ -278,7 +285,8 @@ def game(data: tuple) -> None: if count == 0: count = 6 msg: str = ("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" + " - Zadejte kombinaci kostek k ponechání (dojde k jejich vyhodnocení): " + "[pozice kostek] (např. 1 nebo 34 nebo 123456).\n" " - Hodit znovu: [h].\n" f" - Ukončit hod a ponechat si skóre z tohoto hodu ({score}): [k].\n" " - Ukončit hru: [exit].\n" -- 2.47.3 From db3f71592c93b088b66ed508dbe1acda64af3949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sp=C3=A1=C4=8Dil?= Date: Sat, 27 Jun 2026 18:47:54 +0200 Subject: [PATCH 9/9] fix: oprava anotace to_sorted_tuple() --- kostky/kostky.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kostky/kostky.py b/kostky/kostky.py index 1d063ea..92e2333 100644 --- a/kostky/kostky.py +++ b/kostky/kostky.py @@ -211,8 +211,8 @@ def add_players() -> None: else: break -def to_sorted_tuple(d: dict[str, int], s: bool = True) -> (tuple[list[tuple[int, str, int]], - dict[str, int]]): +def to_sorted_tuple(d: dict[str, int], s: bool = True) -> tuple[list[tuple[int, str, int]], + dict[str, int]]: L: list[tuple[int, str, int]] = [] if s: -- 2.47.3