feat(classic-games): 新增 Mini Turning Turtles 小游戏#1227
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: 2fd95586b1
ℹ️ 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".
| locked = true; | ||
| setMessage("AI is choosing a turtle..."); | ||
| render(); | ||
| window.setTimeout(runAiTurn, 260); |
There was a problem hiding this comment.
Cancel stale AI turns when resetting
When a player starts a new game while the 260 ms AI delay is pending, this timeout is neither canceled nor tied to a game generation, so the old callback runs against the newly reset turtles array. On a fresh all-up board chooseAiMove() can pick index 0 and immediately end the new game as an AI win, making reset unreliable during the AI's turn.
Useful? React with 👍 / 👎.
Summary
project/classic-games/20260718-0124-turning-turtles-lite.htmlValidation
startGame、legalMoves、applyMove、chooseCell、runAiTurn、chooseAiMove、scoreMove、finishIfSolved、render、addEventListenernew Function(...)git diff --check -- project/classic-games/20260718-0124-turning-turtles-lite.htmlAudit
run-audit.shOVERALL_EXIT=0/tmp/git-commit-audit-20260718-013129-60371Commit
fedf1e6a383128489c5055fcdc1af9ac12cc04a92fd95586b106c96c9b2e4df52709c0baba51c867