BareGit

Limit undo history to 1 step.

- Added MAX_UNDO_STEPS constant for easy configuration of undo depth.
- Updated saveHistory to enforce the undo limit by slicing the history stack.
Author: MetroWind <chris.corsair@gmail.com>
Date: Sat Jan 3 14:05:34 2026 -0800
Commit: b56d55762c4da7b47a5c38662cf4c525706a5567

Changes

diff --git a/main.js b/main.js
index c57029a..897e987 100644
--- a/main.js
+++ b/main.js
@@ -2,6 +2,7 @@ import { h, render, useState, useEffect, html } from 'https://unpkg.com/htm/prea
 
 // --- Constants ---
 const MAX_HP = 20;
+const MAX_UNDO_STEPS = 1;
 const SUITS = {
     HEARTS: { symbol: '♥', color: 'red', type: 'POTION' },
     DIAMONDS: { symbol: '♦', color: 'red', type: 'WEAPON' },
@@ -161,7 +162,8 @@ const App = () => {
         const { history, ...stateToSave } = currentState;
         // Basic deep copy for this simple state structure (arrays/objects)
         const snapshot = JSON.parse(JSON.stringify(stateToSave));
-        return [...history, snapshot];
+        // Limit history to MAX_UNDO_STEPS
+        return [...history, snapshot].slice(-MAX_UNDO_STEPS);
     };
 
     const undoLastMove = () => {