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

オープン 初心者向け
#148 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TMHSDigital/Static_Chess のほかの issue

TMHSDigital/Static_Chess の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。