Compare commits
52
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c8e029a70 | ||
|
|
c2bd4fd6ac | ||
|
|
222df46c47 | ||
|
|
21efddc1a0 | ||
|
|
b3650b7243 | ||
|
|
b070e22f33 | ||
|
|
e9cf875192 | ||
|
|
caa743fcc9 | ||
|
|
26f53761a7 | ||
|
|
d420664fde | ||
|
|
5dee428752 | ||
|
|
e2d689a618 | ||
|
|
c53a58c8e4 | ||
|
|
48f8998d7c | ||
|
|
17ccd3b61a | ||
|
|
1fc55d90f3 | ||
|
|
0a83d27962 | ||
|
|
06474e7f68 | ||
|
|
d7648a196c | ||
|
|
db3f71592c | ||
|
|
69b30552cb | ||
|
|
a9ef19ee52 | ||
|
|
a31eff26fd | ||
|
|
9346735af6 | ||
|
|
3808081482 | ||
|
|
9d5c51a17a | ||
|
|
388c92f817 | ||
|
|
754119980f | ||
|
|
74849ff503 | ||
|
|
c8a31ac6be | ||
|
|
7b0c9cadbb | ||
|
|
bdd66379f7 | ||
|
|
c3a2e94cab | ||
|
|
485f152a41 | ||
|
|
26ad8508b5 | ||
|
|
2f8d5b12c2 | ||
|
|
5aa5beff69 | ||
|
|
a58487e9a6 | ||
|
|
9967682373 | ||
|
|
c225161374 | ||
|
|
e7c8d99c96 | ||
|
|
cef9468ad0 | ||
|
|
0682ad88ce | ||
|
|
a6a256992e | ||
|
|
1fcf01152d | ||
|
|
2fa0aa8a95 | ||
|
|
73e8747b73 | ||
|
|
14f1ebbd29 | ||
|
|
7e3639ab12 | ||
|
|
c1c1c5ebfb | ||
|
|
ed309a10b4 | ||
|
|
abc8f92dbb |
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg-info/
|
||||||
|
test.py
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## Working style
|
||||||
|
|
||||||
|
- During code review and code discussions, do NOT present ready-made code
|
||||||
|
proposals or concrete snippets. Limit yourself to advice and recommendations
|
||||||
|
(what is wrong, why, and the direction of the fix). Only write concrete code
|
||||||
|
when the user explicitly asks for it.
|
||||||
|
|
||||||
|
## Project
|
||||||
|
|
||||||
|
`kostky` is a Czech-language terminal CLI game — a Farkle/"tisícovky" dice game variant for multiple players. Single runtime dependency: `tabulate` (for the final results table).
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e ".[dev]" # editable install with mypy + ruff
|
||||||
|
kostky # run the game (after install)
|
||||||
|
python -m kostky # run without installing (requires tabulate)
|
||||||
|
mypy # type-check (strict mode, see pyproject.toml)
|
||||||
|
ruff check . # lint
|
||||||
|
```
|
||||||
|
|
||||||
|
There are no tests in this repository.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
The entire game lives in `kostky/kostky.py` as a single module with module-level mutable state (no classes):
|
||||||
|
|
||||||
|
- `hodnoty: dict[str, int]` — scoring table, loaded at import time from `kostky/hodnoty.csv` via `importlib.resources`. Keys are sorted-digit strings representing dice combos (e.g. `"111"` = three ones), values are point totals.
|
||||||
|
- `players: dict[str, list[int]]` — per-player history of per-turn scores (insertion order == turn order).
|
||||||
|
- `aggr: dict[str, int]` — per-player running total, used for win checks and the results table.
|
||||||
|
- `pointer` / `first` — current player's name / the player who started the round (used to detect when a full round has completed in `next_player`/`check_win`).
|
||||||
|
- `score` — points accumulated *within the current turn*, reset on bust or on banking (`k`).
|
||||||
|
- `h_bool` — guards re-rolling: you can't roll again until you've banked at least one scoring combination in the current roll sequence.
|
||||||
|
|
||||||
|
Control flow is a manual state machine driven by tuples, not exceptions or return codes:
|
||||||
|
|
||||||
|
- `evaluate(inp, count, throw)` parses a single line of user input against the current dice state and returns a `data` tuple whose first element is a tag: `"count"` (continue turn with N remaining dice and a throw string), `"msg"` (show an error/message, possibly re-prompting), `"win"`, or `"exit"`.
|
||||||
|
- `game(data)` is the main loop: it pattern-matches on `data[0]`, prints state, prompts for input, and calls `evaluate` again to get the next `data` tuple. This loop is how every turn — and the whole game — progresses.
|
||||||
|
- Dice picks are entered as letters (`a`-`f` mapped to position 1-6 via `ord(x)-96`), not digit values; `evaluate` converts letters to positions internally before checking the picked dice values against `hodnoty`.
|
||||||
|
- Bust detection (`check_value`) checks whether *any* key in `hodnoty` is a substring of the sorted current throw — not a full combinatorial scoring check, so this is the single source of truth for "is this throw dead."
|
||||||
|
- Win condition (`check_win`) only fires once `pointer` cycles back to `first`, i.e. checked once per full round rather than once per turn, and only declares a winner if exactly one player is alone at/above `final_score`.
|
||||||
|
|
||||||
|
`kostky/__main__.py` and the `kostky` console-script entry point (in `pyproject.toml`) both call `kostky.kostky.main()`.
|
||||||
|
|
||||||
|
## Scoring data
|
||||||
|
|
||||||
|
`kostky/hodnoty.csv` (digit-string-of-dice-values → points) is the single source of truth for scoring and is also documented in tables in `README.md`. If you change one, update the other.
|
||||||
@@ -1,2 +1,100 @@
|
|||||||
# kostky
|
# kostky
|
||||||
|
|
||||||
|
Textová (CLI) hra v kostky pro více hráčů – varianta klasického *Farkle*
|
||||||
|
(„tisícovky“). Běží celá v terminálu, v Pythonu, s jedinou závislostí
|
||||||
|
(`tabulate` pro závěrečnou výsledkovou tabulku).
|
||||||
|
|
||||||
|
## Požadavky
|
||||||
|
|
||||||
|
- Python 3.9+
|
||||||
|
- Závislost `tabulate` (doinstaluje se automaticky při instalaci)
|
||||||
|
|
||||||
|
## Instalace a spuštění
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://gitea.spacilovi.eu/david/kostky.git
|
||||||
|
cd kostky
|
||||||
|
pip install .
|
||||||
|
kostky
|
||||||
|
```
|
||||||
|
|
||||||
|
Případně bez instalace (s nainstalovaným `tabulate`) přes `python -m kostky`,
|
||||||
|
nebo izolovaně jako CLI nástroj přes `pipx install .`.
|
||||||
|
|
||||||
|
> Pro vývoj: `pip install -e ".[dev]"` – editovatelná instalace včetně `mypy`
|
||||||
|
> a `ruff`.
|
||||||
|
|
||||||
|
## Jak se hraje
|
||||||
|
|
||||||
|
### Začátek hry
|
||||||
|
|
||||||
|
1. Zadej jméno prvního hráče (povinné, nesmí být prázdné).
|
||||||
|
2. Přidávej další hráče; zadáním `x` zadávání ukončíš. Jména musí být unikátní.
|
||||||
|
3. Zadej cílové skóre, nebo nech pole prázdné pro výchozích **10 000**.
|
||||||
|
|
||||||
|
### Průběh tahu
|
||||||
|
|
||||||
|
Na začátku tahu uvidíš, kdo je na tahu (s jeho skóre a cílem), a hod šesti
|
||||||
|
kostkami s písmennými pozicemi:
|
||||||
|
|
||||||
|
```
|
||||||
|
Na tahu je Anna (0/10000).
|
||||||
|
1, 5, 3, 2, 6, 4
|
||||||
|
^ ^ ^ ^ ^ ^
|
||||||
|
a b c d e f
|
||||||
|
```
|
||||||
|
|
||||||
|
Pak zvolíš jednu z akcí:
|
||||||
|
|
||||||
|
| Vstup | Akce |
|
||||||
|
| --- | --- |
|
||||||
|
| `pozice kostek` | Odložíš vybrané kostky k vyhodnocení – písmeny (např. `a`, `cd`, `abcdef`). Hodnoty na zvolených pozicích musí dohromady tvořit některou kombinaci z bodovací tabulky. |
|
||||||
|
| `h` | Hodíš znovu zbývajícími kostkami. Povoleno až poté, co v tomto tahu odložíš aspoň jednu bodující kombinaci. |
|
||||||
|
| `k` | Ukončíš tah, připíšeš si nasbírané skóre a předáš tah dalšímu hráči. |
|
||||||
|
| `exit` | Předčasně ukončíš celou hru. |
|
||||||
|
|
||||||
|
Odkládat můžeš i víc kombinací po sobě – po každém vyhodnocení pokračuješ se
|
||||||
|
zbývajícími kostkami a body se v rámci tahu sčítají.
|
||||||
|
|
||||||
|
### Smůla, hot dice, vynulování a výhra
|
||||||
|
|
||||||
|
- **Smůla (bust):** když čerstvý hod neobsahuje žádnou bodující kombinaci,
|
||||||
|
o body z tohoto tahu přijdeš a tah přechází na dalšího hráče.
|
||||||
|
- **Hot dice:** když se ti podaří odložit všech šest kostek, dostaneš čerstvý
|
||||||
|
hod šesti kostkami a pokračuješ ve stejném tahu.
|
||||||
|
- **Vynulování:** tři po sobě jdoucí nulové tahy vynulují tvé celkové skóre.
|
||||||
|
Počet aktuálních nul se vedle skóre ukazuje jako `x` / `xx`.
|
||||||
|
- **Výhra:** po dokončení každého kola vyhrává osamocený lídr nad cílovým
|
||||||
|
skóre; při shodě na první příčce se hraje dál. Na konci se vypíše výsledková
|
||||||
|
tabulka s pořadím všech hráčů.
|
||||||
|
|
||||||
|
## Bodování
|
||||||
|
|
||||||
|
Kompletní tabulka je v souboru [`kostky/hodnoty.csv`](kostky/hodnoty.csv).
|
||||||
|
Kombinace se vyhodnocuje podle hodnot odložených kostek – na jejich pořadí
|
||||||
|
nezáleží.
|
||||||
|
|
||||||
|
### Stejné kostky
|
||||||
|
|
||||||
|
| Kostka | ×1 | ×2 | ×3 | ×4 | ×5 | ×6 |
|
||||||
|
| --- | --- | --- | --- | --- | --- | --- |
|
||||||
|
| **1** | 100 | 200 | 1000 | 2000 | 4000 | 8000 |
|
||||||
|
| **2** | – | – | 200 | 400 | 800 | 1600 |
|
||||||
|
| **3** | – | – | 300 | 600 | 1200 | 2400 |
|
||||||
|
| **4** | – | – | 400 | 800 | 1600 | 3200 |
|
||||||
|
| **5** | 50 | 100 | 500 | 1000 | 2000 | 4000 |
|
||||||
|
| **6** | – | – | 600 | 1200 | 2400 | 4800 |
|
||||||
|
|
||||||
|
(„–“ = daná kombinace samostatně neboduje.)
|
||||||
|
|
||||||
|
### Postupky
|
||||||
|
|
||||||
|
| Kombinace | Body |
|
||||||
|
| --- | --- |
|
||||||
|
| 1-2-3-4-5 | 750 |
|
||||||
|
| 2-3-4-5-6 | 1000 |
|
||||||
|
| 1-2-3-4-5-6 | 1500 |
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
|
||||||
|
Projekt je licencovaný pod [GPL-3.0](LICENSE).
|
||||||
Whitespace-only changes.
@@ -0,0 +1,4 @@
|
|||||||
|
from kostky.kostky import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
444,400
|
444,400
|
||||||
2222,400
|
2222,400
|
||||||
333,300
|
333,300
|
||||||
11,200
|
|
||||||
222,200
|
222,200
|
||||||
1,100
|
1,100
|
||||||
5,50
|
5,50
|
||||||
|
500 Internal Server Error
An error occurred: An error occurred Gitea Version: 28.1.0 |