Let the player choose the promotion piece

未關閉
#51 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
55/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript

研究方向

Read js/game.js:221-228 and js/promotion.js:153-185 to trace how moves and the existing dialog work; check index.html:65-71 and js/config.js:14 for loading and configuration. Run npm test and npm run lint to establish the baseline. Done when players can choose all four pieces, keyboard users can operate the dialog, notation records the choice, and undo restores the pawn.

由索引模型根據 Issue 內容生成。

描述

enhancement severity: high

Summary

A pawn reaching the last rank always becomes a queen with no prompt, so underpromotion is impossible. A promotion dialog already exists in js/promotion.js but is never loaded or called.

Where

  • js/game.js:221-228 (auto-queen, // TODO: Implement choice?)
  • js/promotion.js:153-185 (showPromotionModal returns a Promise), js/promotion.js:57-64 (options are click-only divs)
  • index.html:65-71 (script not loaded), js/config.js:14 (PROMOTION_UI: false)

Proposal

Load promotion.js. When a pawn reaches the last rank, hold the move, show the dialog, then finish the move (notation, check detection, save) with the chosen piece. Block board input while the dialog is open. Make the options real <button> elements with labels so keyboard users can promote.

Open question: makeMove is synchronous and tests call it directly. An optional promotionType parameter, defaulting to queen, keeps tests and a future AI simple. See #31.

Who benefits

Every player whose game reaches promotion; knight promotions and rook or bishop promotions that avoid stalemate become possible.

Acceptance criteria

  • The player can choose queen, rook, bishop or knight
  • Notation shows the chosen piece (e8=N)
  • The dialog is usable by keyboard
  • Undo after a promotion restores the pawn

Getting started

  • Relevant files: js/game.js, js/promotion.js, index.html, js/config.js
  • How to run tests: npm install, then npm test and npm run lint
  • Related docs: docs/ARCHITECTURE.md, .github/CONTRIBUTING.md

Filed by repo-audit/full-audit at 8a2c86c. Severity: high. Effort: M. audit-key: enhancement|js/game.js|makeMove.promotion

主要語言
JavaScript
星號
4
分支
2
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Static_Chess 的其他 Issue

查看 TMHSDigital/Static_Chess 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。