Extract game rules from Phaser scenes into testable modules

Aberta
#40 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
49/100
Tipo de issue
Refatoração
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
game-dev, testing

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
3
Forks
3
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TMHSDigital/GH-Arcade

Todas as issues de TMHSDigital/GH-Arcade

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.