Past games with the same moves merge, losing the newer game's date and opponent

未关闭 适合新手
#148 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
frontend, game-dev

调研方向

从 js/game-store.js 中的 addToArchive 和 js/game-ui.js 中的归档加载流程(handleArchiveClick)开始;js/notation.js 定义了着法文本的比较方式。阅读 tests/unit/archive.test.js 并运行 npm test,检查现有的归档行为。完成标准是:着法相同的不同对局仍然彼此独立;重新打开并归档某个对局时,会替换该对局自己的条目,即使该对局已经结束也如此。

由索引模型根据 Issue 内容生成。

描述

bug good first issue severity: low

Summary

addToArchive treats two past games as the same game when their FEN and their movetext match. The merge is meant for a game that was opened from the list and put back. But separate games with identical moves also merge, and the newer game's date and opponent are lost.

Where

  • js/game-store.js:79-83 (addToArchive)
  • js/notation.js:203 (pgnMovetext)

Details

const same = (entry) => pgnMovetext(entry.pgn) === pgnMovetext(game.pgn);
const entry = archive.find(same) || game;   // the older entry wins

The comparison ignores the player names, the date and the time control.

Impact

  • Short games merge: every game abandoned after 1. e4, a quick resignation, or the same short line against different levels. The list shows one entry, with the first game's date and opponent.
  • In the other direction, a game archived while unfinished (*) and later reopened and finished stays in the list twice, because the movetext differs.

Steps to reproduce

  1. Start a game, play 1.e4, then press New Game twice to discard it.
  2. Change the opponent level and repeat.
  3. Open Load. There is one "1 move" entry, with the first game's opponent and date.

Suggested fix

Remember which archive entry a game was opened from, for example by keeping that entry's date in gameStart when handleArchiveClick loads it. Merge only with that entry, and replace it, so a finished version replaces its unfinished copy. As a simpler alternative, add the White/Black tags and the date to the comparison key.

Acceptance criteria

  • Two separate games with the same moves are kept as two entries
  • A game opened from the list and put back replaces its own entry (also when it was finished meanwhile)

Getting started

  • Relevant files: js/game-store.js, js/game-ui.js (handleArchiveClick), tests/unit/archive.test.js
  • How to run tests: npm ci && npm test

Filed by repo-audit/full-audit at 73cd279. Severity: low. Effort: S. audit-key: bug|js/game-store.js|addToArchive

主要语言
JavaScript
星标
4
派生
2
平均合并
6 小时 13 分钟
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/Static_Chess 的其他 Issue

查看 TMHSDigital/Static_Chess 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。