Extract a shared endRun helper for the game-over handoff

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
57/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
game-dev

调研方向

Start with shared/scenes.ts and shared/pause.ts, then inspect the listed GameScene.ts examples and locate the other game-over call sites. Trace how each game guards the end of a run and builds restart data; migrate the ten games to the typed helper and run npm run typecheck and npm run build. Done when all ten use the helper and both checks pass.

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

描述

severity: low tech-debt

Summary

Every game repeats the same end-of-run code: set a private "over" flag, wait, then scene.start('GameOver', { gameId, score, ... }) with an unchecked object literal.

Where

  • shared/scenes.ts:72-79 (GameOverData is exported but imported by no game)
  • For example games/astro/scenes/GameScene.ts:486-490, games/breakout/scenes/GameScene.ts:432-441, games/siege/scenes/GameScene.ts:541-547, games/stack/scenes/GameScene.ts:447-453

Details

  • The payload is untyped at all ten call sites, so a misspelled field compiles.
  • The "over" flag has five spellings (over, levelDone, alive, phase === 'over', state === 'over'), and only Siege guards against a double call.
  • Restart data is stated twice per game, once for the pause menu and once for game over.
  • Scene keys are bare strings in the shared modules and every scene constructor.

Suggested fix

  1. Add endRun(scene, data: GameOverData, delayMs) to shared/scenes.ts with a once-only guard, and export scene-key constants.
  2. Migrate one game per commit.
  3. Let PauseController and endRun read restart data from one place.

Acceptance criteria

  • All ten games end a run through one typed helper

Getting started

  • Relevant files: shared/scenes.ts, shared/pause.ts, games/*/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: low. Effort: M. audit-key: tech-debt|shared/scenes.ts|GameOverData

主要语言
TypeScript
星标
3
派生
3
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、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 摘要。