feat(classic-games): 新增 Mini Onitama 小游戏#1241
Conversation
Made-with: Cursor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f215659cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| render(); | ||
| if (!gameOver && turn === "B") { | ||
| window.setTimeout(playComputerTurn, 350); |
There was a problem hiding this comment.
Cancel pending AI turns on reset
When the player clicks Reset during the 350ms “Blue is thinking” delay, this timeout still fires after resetGame() has restored turn to "R" and rebuilt the board. The stale playComputerTurn() then applies a blue move to the fresh game; because movePiece() swaps cards using the global turn, it tries to swap that blue card out of Red’s hand (indexOf is -1), corrupting the shared/hand state and scheduling another blue turn. Store and clear the pending timer on reset, or guard the callback with a turn/generation check.
Useful? React with 👍 / 👎.
Summary
project/classic-games/20260718-0824-onitama-lite.htmlValidation
freshBoard、orientMove、legalTargets、allMoves、swapCard、movePiece、chooseAiMove、playComputerTurn、handleCard、handleCell、renderCards、renderBoard、render、addEventListenernew Function(...)git diff --check -- project/classic-games/20260718-0824-onitama-lite.htmlAudit
run-audit.shOVERALL_EXIT=0/tmp/git-commit-audit-20260718-082858-87355Commit
bd4ec68dccf5495364dc49ee0c2990cfe92e293e8f215659cb0350f61a9d6ea846c896a92f71444f