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 摘要。