feat(classic-games): 新增 Mini Euclid's Game 小游戏#1228
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: 18fadd9fe5
ℹ️ 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".
| turnCount.textContent = moves.H + moves.A; | ||
| choices.innerHTML = ""; | ||
|
|
||
| const legalMoves = legalMovesFor(); |
There was a problem hiding this comment.
Stop rendering legal moves after a pile reaches zero
When either player makes a winning move, finishIfWon() sets done and immediately calls render(), but render() still calls legalMovesFor() with a pile value of 0. In that state low is 0, so Math.floor(high / low) becomes Infinity and Array.from({ length: Infinity }) throws a RangeError; the game crashes exactly when a user or AI wins instead of showing the final state. Guard this path before generating legal moves for completed games.
Useful? React with 👍 / 👎.
Summary
project/classic-games/20260718-0154-euclid-game-lite.htmlValidation
startGame、legalMovesFor、applyMove、chooseMove、runAiTurn、chooseAiMove、scoreMove、finishIfWon、render、addEventListenernew Function(...)git diff --check -- project/classic-games/20260718-0154-euclid-game-lite.htmlAudit
run-audit.shOVERALL_EXIT=0/tmp/git-commit-audit-20260718-015705-62217Commit
fe1cc0f2d8b3b8ae42bf3ddab8d488e52249bc0118fadd9fe53b5ce9b7948d81c5c9d7104654dcac