Expand description
SyntaxBreaker — a zero-dependency terminal typing game.
You get 60 seconds to type code snippets as fast as you can. Type each snippet exactly (case-sensitive); it auto-submits once you have typed the full length. Speed earns the bonus, mistakes cost points, and a timeout on any single snippet forces a retry-or-skip decision.
The module is self-contained: terminal access goes through a small
GameKeyReader / GameWriter abstraction (backed by crossterm,
which is already a crate dependency) so the whole game loop is
unit-testable with [MockGameKeyReader], [CapturingGameWriter] and a
stepped GameClock.
High scores live in .limitless/arcade_scores.json (top 5, descending).
use limitless_cli::modules::arcade::score_attempt;
// Correct scrape, fast = 10 points + 5 bonus.
assert_eq!(score_attempt(true, true), 15);
// Correct but slow = base points only.
assert_eq!(score_attempt(true, false), 10);
// Missed attempt = flat penalty.
assert_eq!(score_attempt(false, false), -2);Structs§
- Arcade
Result - Summary of one finished game, before it is written to the leaderboard.
- Arcade
Scoreboard - Serialized top-5 leaderboard stored in
arcade_scores.json. - Stdout
Game Writer - Writer backed by the real standard output.
- Step
Clock - Deterministic test clock: each
now()call advances byPOLL_TIMEOUT, modelling one poll interval passing on a real machine. - System
Game Clock - Clock backed by the real system time.
- Terminal
Game KeyReader - Key reader backed by a real terminal via the
crosstermcrate.
Enums§
- GameKey
- A normalized key press the game understands.
- Status
Line - One line of the status area inside the game box.
Constants§
- ARCADE_
WIDTH - Fixed-width box used for every game frame.
- ATTEMPT_
LIMIT - A single snippet must be completed within this window.
- BONUS_
POINTS - Extra points when a snippet is completed in under
BONUS_WINDOW. - BONUS_
WINDOW - Completing faster than this earns the speed bonus.
- CORRECT_
POINTS - Points for a correctly typed snippet.
- GAME_
DURATION - How long one full game lasts.
- MAX_
SCORES - Max scores kept on the leaderboard.
- PENALTY
- Points lost per wrong character (and for a timed-out attempt).
- POLL_
TIMEOUT - How long the key reader waits for a key before the loop re-checks clocks.
- SCORE_
DIR - Directory (under the current working directory) holding game data.
- SCORE_
FILE - Score file name inside
SCORE_DIR. - SNIPPETS
- The snippet database the game draws from.
Traits§
- Game
Clock - Output stream for the game;
nowreturns the current instant. - Game
KeyReader - Abstraction over the terminal so the game can be driven by mock input.
- Game
Writer - Abstraction over the output stream so the game can capture its frames.
Functions§
- is_
new_ high_ score - Whether
scorebeats the previous best, i.e. every score strictly aboveprevious_topdeserves the 🏆 banner (the very first game counts). - render_
frame_ plain - Renders one full frame of the game (ANSI-free).
- render_
scoreboard - The little leaderboard shown before a game starts.
- run_
arcade - CLI entry point behind
limit arcade. - run_
typing_ game - Plays a full 60-second game on the real terminal, then persists and ranks the score, printing the final tally and leaderboard.
- score_
attempt - Scores one completed attempt.
- score_
file_ path - Where the leaderboard lives:
.limitless/arcade_scores.jsonin the CWD. - shuffled_
with - Shuffles the snippet pool with
seedso every game draws a fresh order.