debugfest/two-zero-four-eight

Feature Request: Add Multi-Level Undo Functionality

Offen

#1 geöffnet am 11.10.2025

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (5 Forks)auto 404
enhancementgood first issuehacktoberfest

Repository-Metriken

Stars
 (0 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

The current game (if undo exists) typically allows only a single undo, limiting flexibility for players who accidentally make multiple misclicks. This restriction can frustrate both casual and strategic players who wish to experiment with different move sequences.

🎯 Proposed Solution

  • Extend undo capability to store and revert the last 3–5 moves.
  • Maintain a stack of previous game states (board, score, move count).
  • Implement keyboard shortcut (e.g., Ctrl + Z) or on-screen Undo button.
  • Limit undo count per game (configurable setting to avoid abuse).

✅ Expected Behavior

  • Players can revert multiple consecutive moves.
  • Undo is smooth, instantaneous, and doesn’t affect game performance.
  • Undo history resets when a new game starts.

💻 Technical Notes

  • Use a stack data structure to store snapshots of game states.
  • Each state includes: tile positions, score, and move history.
  • Manage memory efficiently — discard old states beyond the limit.

🧪 Test Steps

  1. Play a game and make several moves.
  2. Press Undo repeatedly → verify previous states restore correctly.
  3. Ensure score and animations revert as expected.
  4. Start a new game → undo history clears.

Contributor Guide