MIL-004: High score file #38

Merged
Tirsvad merged 6 commits from mil-004-high-score-file into main 2026-10-13 08:41:38 +02:00
Owner

Delivers MIL-004 (RC-007, code review RC-012; autonomous mode, not independent).

Closes #23
Closes #24
Closes #25
Closes #26
Closes #27
Closes #28
Closes #29

Changes from MIL-003

  • constants.py: HIGH_SCORE_FILE (data.txt), HIGH_SCORE_FILE_ENCODING, DEFAULT_HIGH_SCORE.
  • New high_score_file.py: read_high_score (with open, int; missing file created with 0; empty, non-numeric, negative or undecodable content reads as 0) and write_high_score (mode w).
  • Scoreboard(path=HIGH_SCORE_FILE): high_score is read at start; reset() writes the file only for a new high score.
  • Tests: conftest.py runs every test in a temporary folder; 149 -> 169 tests.
  • README: the high score file section.

Differences from the plan, for S01 to confirm

Task 5 says "a guard that fails a test that would open the default path". The guard is a chdir into a temporary folder for every test, so no test can reach a real data.txt; a test that used the default path is redirected, not failed. Every test of the file itself passes an explicit temporary path.

Checks run locally (fresh .venv)

  • pytest: 169 passed; ruff check and format --check: clean; mypy strict: clean; doxygen: 0 warnings
  • Real game from a temporary folder: first start created data.txt holding 0; with 7 in the file the game started and left it at 7.

Reaching a new high score and restarting in the real window is S01's check of Go/No-Go criterion 6; reading and writing are covered by the tests.

Delivers MIL-004 (RC-007, code review RC-012; autonomous mode, not independent). Closes #23 Closes #24 Closes #25 Closes #26 Closes #27 Closes #28 Closes #29 ## Changes from MIL-003 - `constants.py`: `HIGH_SCORE_FILE` (`data.txt`), `HIGH_SCORE_FILE_ENCODING`, `DEFAULT_HIGH_SCORE`. - New `high_score_file.py`: `read_high_score` (with `open`, `int`; missing file created with 0; empty, non-numeric, negative or undecodable content reads as 0) and `write_high_score` (mode `w`). - `Scoreboard(path=HIGH_SCORE_FILE)`: `high_score` is read at start; `reset()` writes the file only for a new high score. - Tests: `conftest.py` runs every test in a temporary folder; 149 -> 169 tests. - README: the high score file section. ## Differences from the plan, for S01 to confirm Task 5 says "a guard that fails a test that would open the default path". The guard is a `chdir` into a temporary folder for every test, so no test can reach a real `data.txt`; a test that used the default path is redirected, not failed. Every test of the file itself passes an explicit temporary path. ## Checks run locally (fresh .venv) - pytest: 169 passed; ruff check and format --check: clean; mypy strict: clean; doxygen: 0 warnings - Real game from a temporary folder: first start created `data.txt` holding `0`; with `7` in the file the game started and left it at `7`. Reaching a new high score and restarting in the real window is S01's check of Go/No-Go criterion 6; reading and writing are covered by the tests.
Tirsvad added 6 commits 2026-10-13 08:39:17 +02:00
Refs #23
Task: MIL-004#1
Refs #24
Refs #25
Refs #26
Task: MIL-004#2
Task: MIL-004#3
Task: MIL-004#4
Refs #27
Task: MIL-004#5
Refs #28
Task: MIL-004#6
Resolve pending commit links
CI / checks (push) Successful in 43s
CI / checks (pull_request) Successful in 47s
4ae80b1f95
Tirsvad merged commit 87e37c1dde into main 2026-10-13 08:41:38 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Tirsvad-Udemy-100-days-of-code/024-snake#38