Move trophy definitions next to each game and type trophy ids

Offen
#38 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Refactoring
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript, vite

Rechercherichtung

Start with shared/achievements.ts and games/registry.json to understand the trophy list and game registry, then read src/hub/trophies-panel.ts for how games without trophies are displayed. The issue proposes four steps, including adding tests despite noting that no test suite exists; first run npm run typecheck and npm run build to establish the baseline. Done means mistyped trophy IDs fail typechecking and adding a game no longer requires editing shared/achievements.ts.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

severity: medium tech-debt

Summary

All 43 trophies live in one hand-maintained list in a shared module, so every new game edits shared code, and the set of games is stated twice (registry and the trophy list). Trophy ids are bare strings at call sites.

Where

  • shared/achievements.ts:22-76, shared/achievements.ts:110-111, shared/achievements.ts:143-144
  • src/hub/trophies-panel.ts:26-27 (games with no trophies are skipped, hiding their stats)

Impact

  • A mistyped id in unlock('...') compiles and silently never unlocks.
  • A game added without trophies is excluded from the "play every game" trophy and from the stats panel.
  • shared/achievements.ts changes in every game-add commit.

Suggested fix

Each step leaves the build working:

  1. Add tests for unlock, addCounter, recordPlay and a registry consistency test.
  2. Derive a TrophyId union from the list (as const) and type unlock(id: TrophyId). No behaviour change.
  3. Move each game's rows to games/<slug>/trophies.ts and build the list with import.meta.glob (Phaser-free, so the hub still loads it cheaply).
  4. Derive the "play every game" set from the registry, and render a stats-only section for games with no trophies.

Acceptance criteria

  • A mistyped trophy id fails typecheck
  • Adding a game does not require editing shared/achievements.ts

Getting started

  • Relevant files: shared/achievements.ts, games/registry.json, src/hub/trophies-panel.ts
  • Run locally: npm install, then npm run dev
  • Checks: npm run typecheck and npm run build (there is no test suite yet)
  • Related docs: README.md

Related: #1


Filed by repo-audit/full-audit at b001f5d. Severity: medium. Effort: M. audit-key: tech-debt|shared/achievements.ts|TROPHIES

Vorherrschende Sprache
TypeScript
Sterne
3
Forks
3
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TMHSDigital/GH-Arcade

Alle Issues in TMHSDigital/GH-Arcade

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.