8000 feat: death mode (-d) — end the test on the first mistake by hindriix · Pull Request #28 · jrnxf/thokr · GitHub
[go: up one dir, main page]

Skip to content

feat: death mode (-d) — end the test on the first mistake - #28

Merged
jrnxf merged 6 commits into
jrnxf:mainfrom
hindriix:upstream-pr/death-mode
Oct 29, 2026
Merged

jrnxf merged 6 commits into
jrnxf:mainfrom
hindriix:upstream-pr/death-mode

Conversation

@hindriix
@hindriix hindriix commented Jul 22, 2026 •
Copy link
Copy Markdown
Contributor

What

Adds a death mode (-d / --death-mode): the test ends the instant you mistype a character.

This revives the idea from #18 (which has been open since early 2023) with a small, focused, tested implementation — happy to defer to the original author if they'd prefer to land theirs; just wanted to offer a ready-to-merge version.

Why

Practicing with zero tolerance for mistakes is a well-known way to build accuracy, which in turn builds real speed. It makes you slow down and commit to each keystroke.

How

  • thok: a death_mode flag on Thok; has_finished() returns early as soon as any input is Incorrect when it's set — checked ahead of the length/timer rules so it beats even a running timer.
  • main: -d flag wired through App::new / reset.
  • docs: README example + --help entry.

Verification

cargo test / clippy / fmt --check clean; unit tests cover: a mistake ends the test, death mode off tolerates mistakes, and death mode overrides a running timer. Also confirmed via a PTY run (one wrong key → straight to the results screen).

@hindriix hindriix mentioned this pull request Jul 22, 2026
5 of 6 tasks
Adds a `-d` / `--death-mode` flag. With it on, the test finishes the
instant an incorrect character is typed, checked ahead of the usual
length/timer rules so it beats even a running timer.

Practicing with zero tolerance for errors is a well-known way to build
accuracy (and, in turn, speed). This revives the idea from the
long-open PR jrnxf#18 with a focused implementation and tests.

- thok: `death_mode` flag on `Thok`; `has_finished` returns early on any
  incorrect input when it's set.
- main: `-d` flag wired through `App::new`/`reset`.
- docs: README example + `--help` entry.
- tests: mistake ends it, off tolerates mistakes, and it overrides a
  running timer.
jrnxf added 5 commits October 29, 2026 11:46
A run that dies after a fraction of a second would otherwise be logged as
an absurdly high wpm. Thok::died() is the one place that says a test ended
on a mistake; has_finished uses it, and save_if_finished skips the history
append for a died run. Clean runs in death mode still log.
Instead of the wpm results, a run that died shows a YOU DIED heading, the
expected character against the key pressed, the prompt around the mistake
with the word it was in underlined, and how far the run got in words,
characters and time. A clean death-mode run and a mistake outside death
mode keep the normal results screen. Retry and new-test keys are unchanged.
The block (heading, what went wrong, the prompt around it, how far the run
got) is centred on the screen, every line on one axis, with the key hints
bottom left where the results screen has them. The website's snapshot check
skips the death screen, which the page has no death mode to draw.
@jrnxf
jrnxf merged commit ef93e49 into jrnxf:main Oct 29, 2026
5 checks passed
@jrnxf
jrnxf commented Oct 29, 2026
Copy link
Copy Markdown
Owner

Thanks @hindriix, this is a great addition and exactly the kind of small focused PR that is easy to land.

I merged the current main into your branch and pushed these on top, with your commits left as they are:

  • Updated the death mode wiring for the refactored new_thok and has_finished in main.
  • A death-mode run that ends on a mistake now shows a centred skull screen (expected vs pressed key, the prompt around the mistake, and how far you got) instead of the wpm results.
  • A run that ends on a mistake is no longer written to the history log. Without this, a run that dies after a fraction of a second logged as an absurdly high wpm. Clean runs in death mode still log. There is a Thok::died() helper and a test for it.

Merged, thanks again!

@jrnxf
jrnxf commented Oct 29, 2026
Copy link
Copy Markdown
Owner

Shipped in v0.7.0. The death screen evolved a bit after merge (#42): the skull is gone, and the prompt now freezes in place with the missed character highlighted.

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.

2 participants

0