Extract game rules from Phaser scenes into testable modules

Abierto
#40 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
49/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
game-dev, testing

Línea de trabajo

Start with games/stack/logic.ts and its existing patterns, then inspect games/snake/scenes/GameScene.ts and games/maze/scenes/GameScene.ts; the issue recommends working one game per commit. First establish tests for Stack, then identify the rules and state transitions to extract from Snake and Maze without importing Phaser. Done when both games’ rules have unit tests and the trophy thresholds are checked through a shared helper.

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

Descripción

severity: medium tech-debt

Summary

Stack keeps its rules in a Phaser-free logic.ts. The other nine games keep state, rules, input, audio, HUD and drawing in one scene class, leaving no seam to test. These are the largest and most-changed files in the repo.

Where

  • games/maze/scenes/GameScene.ts:231-531 (movement, chaser targeting, scoring; 650 lines, 32 methods)
  • games/snake/scenes/GameScene.ts:226-374
  • games/stack/logic.ts:104-206 (the pattern to follow)

Details

Trophy score thresholds are also inline magic numbers duplicated against the trophy descriptions (for example games/maze/scenes/GameScene.ts:492 against shared/achievements.ts:66).

Suggested fix

One game per commit, starting with the most-changed:

  1. Add tests for games/stack/logic.ts first to prove the setup.
  2. Snake: extract step, turn buffer, growth, collision and speed-up into games/snake/logic.ts as pure functions with tests, then have the scene call them.
  3. Maze: extract chaser targeting, speed rules and catch detection into games/maze/chase.ts with tests.
  4. Move score thresholds next to the trophy definitions and check them through one shared helper.

Acceptance criteria

  • At least Snake and Maze rules are covered by unit tests that do not import Phaser

Getting started

  • Relevant files: games/stack/logic.ts, games/snake/scenes/GameScene.ts, games/maze/scenes/GameScene.ts, games/breakout/scenes/GameScene.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

Filed by repo-audit/full-audit at b001f5d. Severity: medium. Effort: L. audit-key: tech-debt|games/maze/scenes/GameScene.ts|GameScene

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.