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

未关闭
#86 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
62/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
TypeScript
星标
3
派生
3
平均合并
10 小时 22 分钟
30 天内合并 PR
6

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/GH-Arcade 的其他 Issue

查看 TMHSDigital/GH-Arcade 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。