diff options
| author | srdusr <[email protected]> | 2025-12-06 00:58:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-12-06 00:58:00 +0200 |
| commit | 24f1eb6cc611f458c45f0ac4046efce51211d7d3 (patch) | |
| tree | 3cd2193d9439921737d57bf3c8452d275faae100 /web/src/keyStats.js | |
| parent | 076f29369e51dfb5798f70099a330ebeb1b66a4e (diff) | |
| download | typerpunk-24f1eb6cc611f458c45f0ac4046efce51211d7d3.tar.gz typerpunk-24f1eb6cc611f458c45f0ac4046efce51211d7d3.zip | |
Fix content packs, seed the leaderboard, and add the missing site furniture
Naming
- "Typing Test" removed from the browser tab, the crate description and the
READMEs. The scope outgrew it: solo practice, live races, code drills and
adaptive weak-key training.
Content
- Movies was prose *about* film, not film quotes - the same mistake the
programming pack had. Replaced with 28 attributed lines. New anime pack,
28 lines across 24 series.
- This follows the model TypeRacer states outright ("type quotes from popular
music, songs, anime, comic books and more"): short excerpts attributed to
the work they came from. The scalable half of their approach is user
submission with moderation, which is a feature this does not have yet.
Leaderboard
- An empty board tells a new player nobody is here. Bots now race the eight
fixed-length leaderboard modes, seeded with a fortnight of backdated results
on first run and one new result every 90 seconds after.
- They are ordinary users carrying is_bot, returned by the same query and
labelled "bot" in the UI. Seeding a board is reasonable; passing synthetic
scores off as human results is not, so the flag travels with the row.
- Seeding is checked per mode. A single result from the live ticker used to
satisfy an "any bot results" guard and leave every other mode empty forever.
Stats
- The per-key accuracy data Practice mode is built on was computed, used to
generate text, and never shown. The screen now ranks your weakest keys with
the error rate and pause length behind each one.
- Added recent form against your lifetime average, best accuracy, and tests
this week.
Multiplayer standings
- Now place, racer, WPM, accuracy and time, with column labels - the columns
TypeRacer and 10FastFingers both show.
Site furniture
- Share (Web Share where available, clipboard otherwise - no third-party
button, no tracking script), a GitHub link, and a real privacy page written
from what the code actually stores rather than from a template.
Button hierarchy
- Everything was an outlined box of roughly equal weight, so a screen's one
real action, a settings toggle and a filter chip looked alike. Three tiers
now: primary (filled, one per screen), default (outlined), quiet (toggles
and filters, bordered only when hovered or active).
Diffstat (limited to 'web/src/keyStats.js')
| -rw-r--r-- | web/src/keyStats.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/web/src/keyStats.js b/web/src/keyStats.js index 9db0106..94d2a9f 100644 --- a/web/src/keyStats.js +++ b/web/src/keyStats.js @@ -37,12 +37,17 @@ export function recordKeystroke(char, isCorrect, latencyMs) { // rate weighted heaviest, since a mistake matters more than being merely // slow) and returns the worst `limit`. Empty until enough real typing has // happened - callers should fall back to plain random text until then. -export function getWeakChars(limit = 12) { +// The scoring behind both the practice generator and the stats screen. Split +// out because the screen needs the numbers, not just which characters won -- +// they were being computed and thrown away. +function scoreChars() { const data = load(); const scored = Object.entries(data) .filter(([, e]) => e.attempts >= MIN_SAMPLES) .map(([char, e]) => ({ char, + attempts: e.attempts, + errors: e.errors, errorRate: e.errors / e.attempts, avgLatency: e.totalLatency / e.attempts, })); @@ -51,7 +56,23 @@ export function getWeakChars(limit = 12) { const maxLatency = Math.max(...scored.map(s => s.avgLatency), 1); scored.forEach(s => { s.score = s.errorRate * 0.7 + (s.avgLatency / maxLatency) * 0.3; }); scored.sort((a, b) => b.score - a.score); - return scored.slice(0, limit).map(s => s.char); + return scored; +} + +export function getWeakChars(limit = 12) { + return scoreChars().slice(0, limit).map(s => s.char); +} + +/// The same ranking with the figures kept, for showing the player *why* a key +/// is considered weak rather than only that it is. +export function getWeakCharDetails(limit = 8) { + return scoreChars().slice(0, limit); +} + +/// The steadiest keys, for the other end of the same list. +export function getStrongCharDetails(limit = 4) { + const scored = scoreChars(); + return scored.slice(-limit).reverse(); } export function hasEnoughData() { |