Astro, Breakout, Pinball and Siege still keep their rules in the scene

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

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
62/100
Issue-Typ
Refactoring
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
game-dev, testing-qa

Rechercherichtung

Start with the reference pattern in games/pong/rules.ts and its tests, then open games/breakout/scenes/GameScene.ts, the suggested first candidate, and find pure functions for bounce angles, brick hits or level layout parsing. Move one game's functions into games/breakout/rules.ts with no Phaser import, add rules.test.ts, and have the scene call the module. Run npm test; done means the new tests pass and the scene behaves as before.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

severity: low tech-debt

Summary

Six games keep their rules in Phaser-free modules with unit tests (Stack, Snake, Maze, Runner, Hop and Pong). Astro Blaster, Neon Breakout, Neon Pinball and Star Siege still mix rules with input, audio and drawing in one scene class, so a rules regression in those four has no automated signal.

Where

  • games/astro/scenes/GameScene.ts (wave sizes, rock splitting, saucer timing and aim)
  • games/breakout/scenes/GameScene.ts (bounce angles, brick hits, power-up rolls, level layout parsing)
  • games/pinball/scenes/GameScene.ts (scoring and ball save, among others); the table data is already in games/pinball/table.ts
  • games/siege/scenes/GameScene.ts (formation movement, enemy fire selection, mothership scoring)
  • The pattern to follow: games/pong/rules.ts, games/hop/rules.ts, games/runner/rules.ts

Impact

Low. These games work today; the cost is that changes to them can only be checked by playing.

Suggested fix

One game per change, moving code rather than rewriting it, as was done for Pong:

  • Pick the functions that take plain numbers and return plain numbers (collision tests, scoring formulas, spawn rules).
  • Move them to games/<slug>/rules.ts with no Phaser import, passing a random function where the rule rolls dice.
  • Add rules.test.ts beside it and have the scene call the module.

Breakout is the best first candidate: its level layout parsing is also the first step of the level editor.

Acceptance criteria

  • Each of the four games has a Phaser-free rules module with unit tests
  • The scenes call the modules and behavior is unchanged

Getting started

  • Relevant files: the four scenes above and the three reference modules
  • How to run tests: npm test
  • Related docs: CONTRIBUTING.md ("Checks")

Related: #59, #40, #84


Filed by repo-audit/fix-issues at de2b25b. Severity: low. Effort: L. audit-key: tech-debt|games/astro/scenes/GameScene.ts|rules-extraction

Vorherrschende Sprache
TypeScript
Sterne
3
Forks
3
Ø Merge
10 Std. 22 Min.
Gemergte PRs (30 T.)
6

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.