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

Offen Anfängerfreundlich
#148 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
84/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript
Bereich
frontend, game-dev

Rechercherichtung

Beginne mit addToArchive in js/game-store.js und dem Ablauf zum Laden des Archivs in js/game-ui.js (handleArchiveClick); js/notation.js definiert den Vergleich des Zugtexts. Lies tests/unit/archive.test.js und führe npm test aus, um das bestehende Archivverhalten zu prüfen. Das Ziel ist erreicht, wenn separate Partien mit identischen Zügen getrennt bleiben und das erneute Öffnen und Archivieren einer Partie ihren eigenen Eintrag ersetzt, auch nachdem sie beendet wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
JavaScript
Sterne
4
Forks
2
Ø Merge
6 Std. 13 Min.
Gemergte PRs (30 T.)
4

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TMHSDigital/Static_Chess

Alle Issues in TMHSDigital/Static_Chess

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.