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

Đang mở
#86 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
62/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
game-dev, testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
3
Fork
3
Merge trung bình
10 giờ 22 phút
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/GH-Arcade

Tất cả issue của TMHSDigital/GH-Arcade

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.