Nine pages per language (home, description, install, one page per lecture step with its screenshot and what was gained, appendix) plus the sidebar. Doxygen now runs without warnings. The publish workflow is the framework template, unchanged. Task: MIL-005#1 Task: MIL-005#2 Task: MIL-005#3 Task: MIL-005#4 Task: MIL-005#5 Closes #24 Closes #25 Closes #26 Closes #27 Closes #28
1.2 KiB
1.2 KiB
Step 3: read the count
🌐 English · Dansk · Bahasa Melayu
get_cookie_count reads the first line of the counter and turns it into a whole number. The game writes 12,345 and, for big amounts, 1.234 million.
Screenshot
Function
def get_cookie_count(game: GamePort) -> int:
first_line = game.read_text(COOKIE_COUNTER_ID).strip().splitlines()[0]
return parse_game_number(first_line)
What we gained
- Parse the game's own number format. Commas group thousands and number words (
million,billion, up todecillion) scale the value. - Use
Decimal, notfloat. A first version usedfloatand3 decillioncame out wrong;Decimalis exact. A failing test found it. - Fail with a clear error. Text without a leading number raises
UnreadableNumberErrorinstead of returning a wrong value. - Test the edge cases. Empty text, a plural and a singular (
1 cookie), unknown words and rounding are all in the tests.
Next: Step 4: buy upgrades
