Dough Git

commit

Turn the jam into a staged lock chain with a power-cycle lock

commit
779cd65465cc38ba45489ba07b3b186c483098b0
author
Clove Twilight <[email protected]>
date
2026-11-20 00:20
- Store a numeric stage in localStorage: 0 rolls 25% for Konami,
  1 is the Konami lock, 2 rolls 20% for a power fault, 3 is the
  power lock, 4+ redirects
- Power lock hides the real cable among 6 shuffled decoys and
  requires the cable to stay unplugged for 3 seconds
- Migrate visitors jammed under the old redirectBroken key to stage 1

Co-Authored-By: Sandrone <[email protected]>

diff --git a/index.html b/index.html
index 7c4c21e..f7defd4 100644
--- a/index.html
+++ b/index.html
@@ -28,12 +28,12 @@
 
   <p class="working-only flavour" id="flavour"></p>
 
-  <div class="broken-only">
+  <div class="lock lock-konami">
     <p class="jammed" role="alert">
       Something jammed. Enter the Konami code to fix it.
     </p>
 
-    <div class="keypad">
+    <div class="controls keypad">
       <button type="button" data-key="ArrowUp" aria-label="Up">↑</button>
       <button type="button" data-key="ArrowDown" aria-label="Down">↓</button>
       <button type="button" data-key="ArrowLeft" aria-label="Left">←</button>
@@ -47,5 +47,20 @@
       <p>↑ ↑ ↓ ↓ ← → ← → B A</p>
     </details>
   </div>
+
+  <div class="lock lock-power">
+    <p class="jammed" role="alert">
+      The server lost power. Get it running again.
+    </p>
+
+    <div class="controls" id="power-panel"></div>
+
+    <p class="power-status" id="power-status" role="status"></p>
+
+    <details class="hint">
+      <summary>Hint</summary>
+      <p>Turn it off and on again, properly: unplug the power cable, wait a few seconds, then plug it back in.</p>
+    </details>
+  </div>
 </body>
 </html>
diff --git a/redirect.js b/redirect.js
index 03559f1..9ec9fac 100644
--- a/redirect.js
+++ b/redirect.js
@@ -5,10 +5,17 @@ const destination = "https://doughmination.gay";
 // How long the spinner shows before redirecting
 const delayMs = 1200;
 
-// Chance that a fresh visit jams the page
-const breakChance = 0.25;
+// Stages: 0 rolls for Konami, 1 is Konami, 2 rolls for power, 3 is power, 4+ redirects
+const stageKey = "redirectStage";
 
-const brokenKey = "redirectBroken";
+const konamiChance = 0.25;
+
+const powerChance = 0.2;
+
+// The cable must stay out this long or the replug fails
+const minUnpluggedMs = 3000;
+
+const decoyCount = 6;
 
 const konamiCode = [
   "ArrowUp",
@@ -34,32 +41,96 @@ const flavourLines = [
   "Untangling the marionette strings…",
 ];
 
+const decoys = [
+  {
+    label: "Unplug network cable",
+    message: "The server is now very calm and very offline. Still no power.",
+  },
+  {
+    label: "Unplug monitor",
+    message: "It's dark now. Nothing else changed.",
+  },
+  {
+    label: "Press reset",
+    message: "The reset button was decorative.",
+  },
+  {
+    label: "Kick the rack",
+    message: "Ow. Still no power.",
+  },
+  {
+    label: "Blow on the cartridge",
+    message: "Wrong decade.",
+  },
+  {
+    label: "Turn fans to max",
+    message: "The fans can't spin without power, genius.",
+  },
+  {
+    label: "Unplug the toaster",
+    message: "Breakfast is cancelled. Server still dead.",
+  },
+  {
+    label: "Flip the breaker",
+    message: "Everyone in the building is upset with you now.",
+  },
+  {
+    label: "Hold power for 5s",
+    message: "Nothing. Someone glued the button.",
+  },
+  {
+    label: "Unplug keyboard",
+    message: "You can't type now. Bold strategy.",
+  },
+];
+
 // Keep the path and query, so fae.is-a.dev/foo goes to doughmination.gay/foo
 const target = destination + location.pathname + location.search + location.hash;
 
 document.getElementById("target").href = target;
 document.getElementById("origin").textContent = location.hostname || "this link";
-document.getElementById("flavour").textContent = flavourLines[Math.floor(Math.random() * flavourLines.length)];
+document.getElementById("flavour").textContent = pickRandom(flavourLines);
 
-// Storage can throw in private windows; the jam then lasts only this load
-function readBroken() {
+// Fallback when storage throws (private windows): stages last only this load
+let memoryStage = 0;
+
+function readStage() {
   try {
-    return localStorage.getItem(brokenKey) === "1";
+    // Visitors jammed by the first version keep their jam
+    if (localStorage.getItem("redirectBroken") === "1") {
+      localStorage.removeItem("redirectBroken");
+      return 1;
+    }
+
+    return Number(localStorage.getItem(stageKey)) || 0;
   } catch {
-    return false;
+    return memoryStage;
   }
 }
 
-function writeBroken(isBroken) {
+function writeStage(stage) {
+  memoryStage = stage;
+
   try {
-    if (isBroken) {
-      localStorage.setItem(brokenKey, "1");
-    } else {
-      localStorage.removeItem(brokenKey);
-    }
+    localStorage.setItem(stageKey, String(stage));
   } catch {}
 }
 
+function pickRandom(items) {
+  return items[Math.floor(Math.random() * items.length)];
+}
+
+function shuffle(items) {
+  const shuffled = [...items];
+
+  for (let index = shuffled.length - 1; index > 0; index--) {
+    const swapIndex = Math.floor(Math.random() * (index + 1));
+    [shuffled[index], shuffled[swapIndex]] = [shuffled[swapIndex], shuffled[index]];
+  }
+
+  return shuffled;
+}
+
 function startRedirect() {
   setTimeout(
     () => location.replace(target),
@@ -67,9 +138,8 @@ function startRedirect() {
   );
 }
 
-function jam() {
-  writeBroken(true);
-  document.body.classList.add("broken");
+function konamiLock(onSolved) {
+  document.body.dataset.lock = "konami";
 
   const listeners = new AbortController();
   const enteredKeys = [];
@@ -83,9 +153,7 @@ function jam() {
 
     if (enteredKeys.join() === konamiCode.join()) {
       listeners.abort();
-      writeBroken(false);
-      document.body.classList.remove("broken");
-      startRedirect();
+      onSolved();
     }
   }
 
@@ -104,8 +172,86 @@ function jam() {
   }
 }
 
-if (readBroken() || Math.random() < breakChance) {
-  jam();
-} else {
-  startRedirect();
+function powerLock(onSolved) {
+  document.body.dataset.lock = "power";
+
+  const panel = document.getElementById("power-panel");
+  const status = document.getElementById("power-status");
+  const cable = document.createElement("button");
+  let unpluggedAt = null;
+
+  function plugBackIn() {
+    unpluggedAt = null;
+    cable.textContent = "Unplug power cable";
+  }
+
+  cable.type = "button";
+  plugBackIn();
+
+  cable.addEventListener("click", () => {
+    if (unpluggedAt === null) {
+      unpluggedAt = Date.now();
+      cable.textContent = "Plug power cable back in";
+      status.textContent = "The server is off. Give it a moment…";
+      return;
+    }
+
+    if (Date.now() - unpluggedAt < minUnpluggedMs) {
+      plugBackIn();
+      status.textContent = "Too quick. The capacitors were still charged. Try again.";
+      return;
+    }
+
+    status.textContent = "It's booting…";
+    onSolved();
+  });
+
+  const decoyButtons = shuffle(decoys).slice(0, decoyCount).map((decoy) => {
+    const button = document.createElement("button");
+    button.type = "button";
+    button.textContent = decoy.label;
+
+    // Fiddling with anything else mid-cycle ruins the power cycle
+    button.addEventListener("click", () => {
+      plugBackIn();
+      status.textContent = decoy.message;
+    });
+
+    return button;
+  });
+
+  panel.replaceChildren(...shuffle([cable, ...decoyButtons]));
+}
+
+// Roll this stage's chance to jam, then show its lock or redirect
+function visit() {
+  let stage = readStage();
+
+  if (stage === 0 && Math.random() < konamiChance) {
+    stage = 1;
+  }
+
+  if (stage === 2 && Math.random() < powerChance) {
+    stage = 3;
+  }
+
+  writeStage(stage);
+
+  if (stage === 1) {
+    konamiLock(() => {
+      writeStage(2);
+      visit();
+    });
+  } else if (stage === 3) {
+    powerLock(() => {
+      writeStage(4);
+      visit();
+    });
+  } else {
+    // shortcut: stage 4+ just redirects, add the next lock here later
+    delete document.body.dataset.lock;
+    startRedirect();
+  }
 }
+
+visit();
diff --git a/style.css b/style.css
index 91eee59..dcacfc8 100644
--- a/style.css
+++ b/style.css
@@ -18,6 +18,7 @@
 
 body {
   margin: 0;
+  padding: 0 16px;
   min-height: 100vh;
   display: grid;
   place-content: center;
@@ -68,27 +69,36 @@ p {
   opacity: 0.75;
 }
 
-.broken-only {
+.lock {
   display: none;
+  max-width: 32rem;
 }
 
-body.broken .working-only {
+body[data-lock] .working-only {
   display: none;
 }
 
-body.broken .broken-only {
+body[data-lock="konami"] .lock-konami,
+body[data-lock="power"] .lock-power {
   display: grid;
   justify-items: center;
   gap: 1rem;
 }
 
-body.broken .spinner {
+body[data-lock="konami"] .spinner {
   border-top-color: var(--track);
   border-right-color: var(--accent);
   animation: jam 1.6s steps(1) infinite;
 }
 
-body.broken .jammed {
+/* Server is off: spinner goes dark */
+body[data-lock="power"] .spinner {
+  border-color: var(--track);
+  opacity: 0.4;
+  animation: none;
+}
+
+body[data-lock] .jammed {
   animation: glitch 2.4s steps(1) infinite;
 }
 
@@ -123,12 +133,19 @@ body.broken .jammed {
 }
 
 @media (prefers-reduced-motion: reduce) {
-  body.broken .spinner,
-  body.broken .jammed {
+  body[data-lock] .spinner,
+  body[data-lock] .jammed {
     animation: none;
   }
 }
 
+.controls {
+  display: flex;
+  flex-wrap: wrap;
+  justify-content: center;
+  gap: 0.5rem;
+}
+
 /* Touch screens only; keyboards type the code directly */
 .keypad {
   display: none;
@@ -137,27 +154,13 @@ body.broken .jammed {
 @media (hover: none) and (pointer: coarse) {
   .keypad {
     display: flex;
-    flex-wrap: wrap;
-    justify-content: center;
-    gap: 0.5rem;
   }
 }
 
-.hint summary {
-  color: var(--accent);
-  cursor: pointer;
-  text-align: center;
-}
-
-.hint p {
-  margin-top: 0.5rem;
-  font-weight: 600;
-  letter-spacing: 0.1em;
-}
-
-.keypad button {
+.controls button {
   min-width: 2.75rem;
   min-height: 2.75rem;
+  padding: 0 0.75rem;
   border: 2px solid var(--accent);
   border-radius: 0.5rem;
   background: var(--track);
@@ -167,12 +170,29 @@ body.broken .jammed {
   cursor: pointer;
 }
 
-.keypad button:active {
+.controls button:active {
   background: var(--accent);
   color: var(--background);
 }
 
-.keypad button:focus-visible {
+.controls button:focus-visible {
   outline: 3px solid var(--accent);
   outline-offset: 2px;
 }
+
+.power-status {
+  min-height: 1.5em;
+  font-style: italic;
+}
+
+.hint summary {
+  color: var(--accent);
+  cursor: pointer;
+  text-align: center;
+}
+
+.hint p {
+  margin-top: 0.5rem;
+  font-weight: 600;
+  letter-spacing: 0.05em;
+}