Snake daily: first food depends on the previous run, so the board differs per player
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1 小時以內
- 新手友好度
- 84/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- game-dev
研究方向
從 games/snake/scenes/GameScene.ts 開始:init()(約第 105-123 行)會重置每一局的狀態,但沒有重置 this.food;create()(第 141 行)呼叫 randomFreeCell()(第 462-468 行),它仍然會看到上一局的食物。將 food 宣告為 private food: Cell | undefined,並在 init() 中清空它。接著檢查 games/snake/logic.ts 中的 freeCells 以及 shared/rng.ts 中帶種子的選取是否與 issue 描述的行為一致。完成標準是:全新載入、PLAY AGAIN 和 RESTART 之後,第一個每日食物格子保持一致;一般模式不受影響;npm test 通過。
由索引模型根據 Issue 內容生成。
描述
Summary
In Neon Snake's daily challenge, where the first food appears depends on the last food of the previous run played on the same page. The board is supposed to be the same for everyone who steers the same way, but it isn't.
Where
games/snake/scenes/GameScene.ts:105-123(init, never resetsfood)games/snake/scenes/GameScene.ts:141(create,this.food = this.randomFreeCell())games/snake/scenes/GameScene.ts:462-468(randomFreeCell)
Details
Phaser reuses the scene instance, and init() resets bonus, score, eaten and the rest, but not this.food. On the second and later runs on a page, create() calls randomFreeCell() while this.food still holds the previous run's last food cell:
private randomFreeCell(): Cell {
const taken = this.players.flatMap((p) => p.segments);
if (this.food) taken.push(this.food);
if (this.bonus) taken.push(this.bonus.cell);
const free = freeCells(taken);
return this.cellRng ? this.cellRng.pick(free) : Phaser.Utils.Array.GetRandom(free);
}
freeCells() lists cells in row-major order, so excluding one extra cell shifts every index after it. The seeded cellRng.pick(free) then lands on a different cell, and every later pick follows from that different board.
Impact
Daily scores are not comparable. A player who played a normal run, a previous daily run, or pressed RESTART before the daily gets a different food sequence from a player who opened the daily fresh. Replaying the daily on the same page is not the same board either.
Steps to reproduce
- Open
games/snake/?mode=daily, start DAILY, and note the first food cell. Then die. - Choose PLAY AGAIN.
- The first food cell is often different (whenever the previous run's last food sat before the picked index).
Suggested fix
Clear this.food in init() (declare it as private food: Cell | undefined), so the first randomFreeCell() of every run sees only the snake.
Acceptance criteria
- The first daily food cell is the same on a fresh page load and after PLAY AGAIN, RESTART or a normal run.
- Normal mode behaviour is unchanged.
Getting started
- Relevant files:
games/snake/scenes/GameScene.ts,games/snake/logic.ts(freeCells),shared/rng.ts(dailyRng) - How to run tests:
npm test - Related: #78 (Snake daily mode)
Filed by repo-audit/full-audit at de2b25b. Severity: medium. Effort: S. audit-key: bug|games/snake/scenes/GameScene.ts|randomFreeCell
- 主要語言
- TypeScript
- 星號
- 3
- 分支
- 3
- 平均合併
- 8 小時 13 分鐘
- 30 天內合併 PR
- 2
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TMHSDigital/GH-Arcade 的其他 Issue
-
ci good first issue severity: low
難度 2/5 1-3 小時 新手友好度 68/100
TMHSDigital/GH-Arcade#111 ·
-
bug good first issue severity: low
難度 1/5 1 小時以內 新手友好度 88/100
TMHSDigital/GH-Arcade#105 ·
-
bug good first issue severity: low
難度 2/5 1-3 小時 新手友好度 72/100
TMHSDigital/GH-Arcade#104 ·
-
accessibility enhancement severity: low
難度 4/5 3-5 天 新手友好度 40/100
TMHSDigital/GH-Arcade#114 ·
-
enhancement severity: low
難度 4/5 3-5 天 新手友好度 35/100
TMHSDigital/GH-Arcade#113 ·
查看 TMHSDigital/GH-Arcade 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
steelbrain/node-ssh#487 ·
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundaries未關閉
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難度 1/5 1 小時以內 新手友好度 62/100
lingdojo/kana-dojo#34127 · 1 則留言 · 5 個 reaction ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 68/100
osmlab/name-suggestion-index#13104 ·
維護者通常 1 天內回覆