Extract game rules from Phaser scenes into testable modules

Aperta
#40 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
49/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
game-dev, testing

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
3
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TMHSDigital/GH-Arcade

Tutte le issue di TMHSDigital/GH-Arcade

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.