Move trophy definitions next to each game and type trophy ids

Abierto
#38 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript, vite

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
3
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/GH-Arcade

Todos los issues de TMHSDigital/GH-Arcade

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.