Skip to content

Show the score in the graphical UI, and scope format.sh to skip vendored code - #125

Merged
dmccoystephenson merged 3 commits into
mainfrom
feature/run-scoped-score-and-hud-display
Aug 8, 2026
Merged

Show the score in the graphical UI, and scope format.sh to skip vendored code#125
dmccoystephenson merged 3 commits into
mainfrom
feature/run-scoped-score-and-hud-display

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Not included: #122

Issue #122 was investigated and is not reproducible as described; it has been left open with the evidence posted as a comment there, because deciding what should happen instead is a design call rather than a bug fix. In short: checkForLevelProgressAndReinitialize() is only ever reached from restartRun() and the collision branch of moveEntity(), both of which call recordCurrentRun() first, so a run is always exactly one level and the score is never discarded mid-run.

Test plan

  • python3 -m pytest — 223 passed (217 on main)
  • python3 -m compileall src — clean
  • python3 -m black --check src tests — clean, and src/lib is left untouched
  • New coverage: formatScoreLabel at a neutral, doubled and fractional multiplier, and the graphical HUD's score line both with and without a multiplier running
  • README controls table and usage commands re-checked against handleKeyDownEvent and the --text-ui argparse flag

Closes #120
Closes #124

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

dmccoystephenson and others added 2 commits August 8, 2026 01:59
… pass

black now reads its exclusion from a new pyproject.toml [tool.black] section
and autoflake is given --exclude lib, so neither rewrites the vendored
graphik/py_env_lib copies under src/lib. The eight non-vendored files that had
drifted out of black's style are reformatted here in one pass, so subsequent
diffs stay scoped to their actual change.

Closes #120

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The score was read only by the end-of-run console summary, the save record
and the text UI's stats block, so a player in the default graphical UI had no
way to see it while playing - and the score-multiplier power-up's "(x2)"
annotation had no line to attach to there.

drawHud now leads with the score alongside the currency it already drew.
Whether and how a multiplier is annotated moves into
scoring.formatScoreLabel, which the text renderer reads too, so the rule
lives in one place rather than being restated per UI.

Closes #124

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dmccoystephenson
dmccoystephenson force-pushed the feature/run-scoped-score-and-hud-display branch from 52e2341 to 4e8cfa6 Compare August 8, 2026 02:14
@dmccoystephenson dmccoystephenson changed the title Record and display the score across a whole run, and scope format.sh Show the score in the graphical UI, and scope format.sh to skip vendored code Aug 8, 2026
Matches tests/ui/test_banner.py's drawText stub, so the assertion is about
the string drawn rather than about drawText's exact remaining parameters.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review

The full diff was read against this repository's conventions. Nothing blocking was found. Three judgment calls are worth a reviewer's attention, and one finding was applied before this comment was posted.

Applied

tests/rendering/test_hud_and_banner.py:41 — the drawText stub captured the drawn string via a lambda that spelled out every one of graphik's five positional parameters, which would break on any caller that passed one by keyword. It now takes (text, *args), matching the stub already used in tests/ui/test_banner.py:70. Fixed in d301e0f.

For a reviewer to confirm

src/textui/textrenderer.py:8 — this adds the text renderer's first import of a non-stdlib project module (from scoring.scoring import formatScoreLabel). The decoupling asked for in PR #95 was read as "gameplay must not reach into a UI package, and a UI package must not reach into gameplay state"; scoring/scoring.py holds pure functions over plain numbers with no game object, no state and no UI dependency, the same shape as progression/obituary.py's formatObituaryScreen, which gameplay already imports for display lines. The alternative — restating the (x2) rule inside drawHud as well — is the duplication that PRs #92, #95 and #99 were each cleaning up, so sharing the function was preferred. Should the boundary be read more strictly than that, the fallback is for renderStats to accept an already-formatted label from Ophidian.getScoreLabel(), at the cost of a signature change to a method three existing tests call by keyword.

src/scoring/scoring.py:62 — the annotation triggers on multiplier > 1, so a hypothetical multiplier below 1 would render unannotated. This is the pre-existing renderStats behaviour moved verbatim rather than a new decision, and no such power-up exists today (getScoreMultiplier returns 1.0 or 2.0), so it was left alone rather than widened speculatively.

src/ophidian.py:322 — the score shares the first HUD line with the currency (Score: 125 | Currency: 42) because graphik.drawText centres each string on the x it is handed, so two centred strings on one row would overlap. A long score plus a long currency balance could therefore run wide on a narrow window. The upgrades line directly below already has that property, so no new mechanism was introduced for it; issue #72 is where a dedicated HUD area is being tracked.

Checked and clean

  • format.sh's exclusion was verified to take effect, not just to be declared: black --check src tests reports 9 files before the change and 8 after, with src/lib/pyenvlib/environment.py dropping out, and src/lib is unmodified in the diff.
  • The formatting-only commit was confirmed to be formatting-only — it is separated from the functional commit precisely so that can be read at a glance.
  • The # /bin/bash line added to format.sh is a comment rather than a shebang, matching test.sh exactly; both scripts are run as ./x.sh and fall back to the invoking shell, so behaviour is unchanged.
  • The README controls table was re-checked key by key against handleKeyDownEvent (w/a/s/d and arrows, F11 graphical-only, l, c, p, r, q), and the usage commands against the --text-ui argparse flag. Only the multiplier-annotation sentence needed correcting.
  • python3 -m pytest: 223 passed, against 217 on main.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

@dmccoystephenson
dmccoystephenson merged commit fa51cfe into main Aug 8, 2026
@dmccoystephenson
dmccoystephenson deleted the feature/run-scoped-score-and-hud-display branch August 8, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Graphical UI never displays the score, while the text UI shows it live format.sh reformats 9 unrelated files, and would rewrite the vendored src/lib

1 participant