Regression: a game still ends through four separate code paths
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/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ệ
- javascript
Hướng nghiên cứu
Read the listed ending paths in js/game.js, the save inference in js/saved-game.js, and the related tests tests/unit/review-result.test.js and tests/unit/draws-promotion.test.js. Start by running npm test and tracing how each ending updates state, stops the clock, and starts scoring. Done means end-state fields are assigned in one function and the acceptance tests cover each listed ending and its expected state.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
#140 moved the rule decision into gameOutcome, but the end state of a game is still written in four places, and they already behave differently. A related hidden coupling: updateStatusDisplay, which is a render call, also records the players and starts scoring the finished game. Every game ending therefore depends on a redraw happening.
Where
js/game.js:725-745(endWith)js/game.js:856-881(endGameWithoutMove)js/game.js:1686-1694(importPGNsets the end-state fields inline)js/game.js:799-802(Undo reopens a game by hand)js/game.js:637-638,js/game.js:835-836,js/game.js:1760(each caller ofplayMovemust rememberendIfAutomaticDraw)js/saved-game.js:114-122(result inference for old saves)js/game.js:1576-1584(updateStatusDisplaycallsrecordPlayers()andscoreFinishedGame())
Details
importPGN writes the end state itself instead of using either helper:
if (ending) {
isGameOver = true;
gameResult = ending.result;
endedWithoutMove = true;
currentStatus = ending.status;
}
playMove itself decides only checkmate and stalemate. Each caller then has to call endIfAutomaticDraw for repetition, the fifty-move rule and insufficient material.
Impact
The paths already differ: an imported ending plays no sound, and its clock handling differs from endGameWithoutMove. Anything new that must happen when a game ends, such as #160's results record, has to be added to every path. A future caller of playMove that forgets endIfAutomaticDraw would let a game continue past threefold repetition. If a state change ever skips updateStatusDisplay, scoring and player recording are skipped without any error.
Suggested fix
- Add
markEnded(result, status, { withoutMove }). HaveendWith,endGameWithoutMoveandimportPGNall set the end state through it. - Add
playAndJudge(from, to, promo)(that is,playMovefollowed byendIfAutomaticDraw) and use it inmakeMoveandredoMove. KeepimportPGNon plainplayMove, with a comment explaining why. - Call
recordPlayers()andscoreFinishedGame()from these transition helpers, and remove them fromupdateStatusDisplayin a separate commit. - Once old saves without a result can be dropped, remove the inference in
saved-game.js.
Acceptance criteria
- Before starting: one end-to-end test per ending (mate, stalemate, threefold via redo, fifty-move via redo, resignation, agreed draw, flag fall, PGN result tag). Each asserts
gameResult,endedWithoutMove, the status text, that the clock timer stopped, and that scoring started. - The end-state fields are assigned in one function.
Getting started
- Relevant files:
js/game.js,js/saved-game.js,tests/unit/review-result.test.js,tests/unit/draws-promotion.test.js - How to run tests:
npm test
Regression of #140.
Filed by repo-audit/full-audit at 01c6a35. Severity: medium. Effort: M. audit-key: tech-debt|js/game.js|endWith
- Ngôn ngữ chính
- JavaScript
- Star
- 4
- Fork
- 2
- Merge trung bình
- 22 giờ 16 phút
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TMHSDigital/Static_Chess
-
enhancement help wanted severity: low
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
TMHSDigital/Static_Chess#184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement help wanted severity: low
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
TMHSDigital/Static_Chess#182 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
severity: medium tech-debt
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
TMHSDigital/Static_Chess#171 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
help wanted performance severity: medium
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
TMHSDigital/Static_Chess#168 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement help wanted severity: low
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 61/100
TMHSDigital/Static_Chess#161 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TMHSDigital/Static_Chess
Issue tương tự
-
priority: low server testing
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
blamechris/chroxy#9277 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
microsoft/playwright#44289 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Ionaru/easy-markdown-editor#657 ·
-
[source] Camera Blocking StageĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
TMHSDigital/Free-Game-Dev-Assets#320 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:webapp bug finding
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày