Dough Git

commit

Add captcha, overheat and BIOS locks via a locks table

commit
1b944230d043b85818b7a0176fda4da4099bf12f
author
Clove Twilight <[email protected]>
date
2026-11-20 00:25
- Replace per-stage branches with a locks table: even stage 2n rolls
  for lock n, odd stage 2n+1 shows it
- Captcha: select all 9 gear squares, or claim to be an automaton
- Overheat: tap the fan to stay under 85C while the boot bar fills;
  100C resets the boot
- BIOS: full-screen setup screen, move Redirect Drive to the top of
  the boot order and save with F10; on-screen keys for touch

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

diff --git a/index.html b/index.html
index f7defd4..669edb8 100644
--- a/index.html
+++ b/index.html
@@ -62,5 +62,81 @@
       <p>Turn it off and on again, properly: unplug the power cable, wait a few seconds, then plug it back in.</p>
     </details>
   </div>
+
+  <div class="lock lock-captcha">
+    <p class="jammed" role="alert">
+      Suspicious traffic detected. Select every square that contains a gear.
+    </p>
+
+    <div class="captcha-grid" id="captcha-grid"></div>
+
+    <p class="lock-status" id="captcha-status" role="status"></p>
+
+    <div class="controls">
+      <button type="button" id="captcha-verify">Verify</button>
+      <button type="button" id="captcha-robot">I'm not a robot</button>
+      <button type="button" id="captcha-automaton">I am an automaton</button>
+    </div>
+
+    <details class="hint">
+      <summary>Hint</summary>
+      <p>Every square has a gear in it. Every single one.</p>
+    </details>
+  </div>
+
+  <div class="lock lock-overheat">
+    <p class="jammed" role="alert">
+      The server is overheating. Keep it cool while it boots.
+    </p>
+
+    <p class="temperature" id="overheat-temperature">70°C</p>
+
+    <progress id="overheat-progress" max="1" value="0" aria-label="Boot progress"></progress>
+
+    <p class="lock-status" id="overheat-status" role="status"></p>
+
+    <div class="controls">
+      <button type="button" id="overheat-fan">Spin the fan</button>
+    </div>
+
+    <details class="hint">
+      <summary>Hint</summary>
+      <p>Tap the fan button fast. Booting only moves while it's under 85°C, and it shuts down at 100°C.</p>
+    </details>
+  </div>
+
+  <div class="lock lock-bios">
+    <div id="bios-intro">
+      <p>Doughmination BIOS v1.0</p>
+      <p>Memory test: 640K OK</p>
+      <p>Detecting drives… done</p>
+      <p>&nbsp;</p>
+      <p role="alert">No bootable device found.</p>
+      <p>&nbsp;</p>
+      <button type="button" data-bios-action="setup">Press F2 to enter Setup</button>
+    </div>
+
+    <div id="bios-setup" hidden>
+      <p class="bios-title">BIOS SETUP UTILITY · Boot</p>
+      <p>Boot priority order:</p>
+
+      <div class="bios-boot-order" id="bios-boot-order"></div>
+
+      <p class="bios-status" id="bios-status" role="status"></p>
+
+      <div class="bios-footer">
+        <button type="button" data-bios-action="up" aria-label="Select up">↑</button>
+        <button type="button" data-bios-action="down" aria-label="Select down">↓</button>
+        <button type="button" data-bios-action="raise" aria-label="Move device up">+</button>
+        <button type="button" data-bios-action="lower" aria-label="Move device down">−</button>
+        <button type="button" data-bios-action="save">F10 Save &amp; Exit</button>
+      </div>
+
+      <details class="hint">
+        <summary>Hint</summary>
+        <p>Move Redirect Drive to the top with +, then Save &amp; Exit with F10.</p>
+      </details>
+    </div>
+  </div>
 </body>
 </html>
diff --git a/redirect.js b/redirect.js
index 9ec9fac..9328722 100644
--- a/redirect.js
+++ b/redirect.js
@@ -5,16 +5,42 @@ const destination = "https://doughmination.gay";
 // How long the spinner shows before redirecting
 const delayMs = 1200;
 
-// Stages: 0 rolls for Konami, 1 is Konami, 2 rolls for power, 3 is power, 4+ redirects
+// Even stage 2n rolls for lock n, odd stage 2n+1 shows lock n; see the locks table at the bottom
 const stageKey = "redirectStage";
 
-const konamiChance = 0.25;
-
-const powerChance = 0.2;
-
 // The cable must stay out this long or the replug fails
 const minUnpluggedMs = 3000;
 
+const captchaTileCount = 9;
+
+const captchaFailMessages = [
+  "Please try again.",
+  "You missed a gear.",
+  "Some of those squares are gears in disguise.",
+  "Select ALL squares with gears.",
+];
+
+const overheat = {
+  startTemperature: 70,
+  minTemperature: 40,
+  throttleTemperature: 85,
+  shutdownTemperature: 100,
+  heatPerSecond: 8,
+  coolingPerTap: 6,
+  bootSeconds: 10,
+  tickMs: 100,
+};
+
+const bootDevices = [
+  "Floppy Drive A:",
+  "CD-ROM Drive",
+  "Network Boot (PXE)",
+  "USB Toaster",
+  "Redirect Drive",
+];
+
+const targetDevice = "Redirect Drive";
+
 const decoyCount = 6;
 
 const konamiCode = [
@@ -102,7 +128,7 @@ function readStage() {
       return 1;
     }
 
-    return Number(localStorage.getItem(stageKey)) || 0;
+    return Math.floor(Number(localStorage.getItem(stageKey))) || 0;
   } catch {
     return memoryStage;
   }
@@ -139,8 +165,6 @@ function startRedirect() {
 }
 
 function konamiLock(onSolved) {
-  document.body.dataset.lock = "konami";
-
   const listeners = new AbortController();
   const enteredKeys = [];
 
@@ -173,8 +197,6 @@ function konamiLock(onSolved) {
 }
 
 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");
@@ -223,32 +245,244 @@ function powerLock(onSolved) {
   panel.replaceChildren(...shuffle([cable, ...decoyButtons]));
 }
 
+function captchaLock(onSolved) {
+  const grid = document.getElementById("captcha-grid");
+  const status = document.getElementById("captcha-status");
+
+  const tiles = Array.from({ length: captchaTileCount }, () => {
+    const tile = document.createElement("button");
+    tile.type = "button";
+    tile.className = "captcha-tile";
+    tile.textContent = "⚙";
+    tile.setAttribute("aria-label", "Square");
+    tile.setAttribute("aria-pressed", "false");
+
+    // Random tilt and size so the tiles look like different photos
+    tile.style.setProperty("--tilt", `${Math.floor(Math.random() * 360)}deg`);
+    tile.style.setProperty("--size", `${(1.5 + Math.random() * 1.5).toFixed(2)}rem`);
+
+    tile.addEventListener("click", () => {
+      const isPressed = tile.getAttribute("aria-pressed") === "true";
+      tile.setAttribute("aria-pressed", String(!isPressed));
+    });
+
+    return tile;
+  });
+
+  grid.replaceChildren(...tiles);
+
+  document.getElementById("captcha-verify").addEventListener("click", () => {
+    if (tiles.every((tile) => tile.getAttribute("aria-pressed") === "true")) {
+      onSolved();
+    } else {
+      status.textContent = pickRandom(captchaFailMessages);
+    }
+  });
+
+  document.getElementById("captcha-robot").addEventListener("click", () => {
+    status.textContent = "That's exactly what a robot would say.";
+  });
+
+  document.getElementById("captcha-automaton").addEventListener("click", onSolved);
+}
+
+function overheatLock(onSolved) {
+  const fan = document.getElementById("overheat-fan");
+  const readout = document.getElementById("overheat-temperature");
+  const progress = document.getElementById("overheat-progress");
+  const status = document.getElementById("overheat-status");
+  const tickSeconds = overheat.tickMs / 1000;
+  let temperature = overheat.startTemperature;
+  let bootedSeconds = 0;
+
+  fan.addEventListener("click", () => {
+    temperature = Math.max(
+      overheat.minTemperature,
+      temperature - overheat.coolingPerTap,
+    );
+  });
+
+  const timer = setInterval(() => {
+    temperature += overheat.heatPerSecond * tickSeconds;
+
+    if (temperature >= overheat.shutdownTemperature) {
+      temperature = overheat.startTemperature;
+      bootedSeconds = 0;
+      status.textContent = "Thermal shutdown! Boot restarted.";
+    } else if (temperature < overheat.throttleTemperature) {
+      bootedSeconds += tickSeconds;
+      status.textContent = "Booting…";
+    } else {
+      status.textContent = "Throttling: too hot to boot.";
+    }
+
+    readout.textContent = `${Math.round(temperature)}°C`;
+    readout.dataset.hot = String(temperature >= overheat.throttleTemperature);
+    progress.value = bootedSeconds / overheat.bootSeconds;
+
+    if (bootedSeconds >= overheat.bootSeconds) {
+      clearInterval(timer);
+      onSolved();
+    }
+  }, overheat.tickMs);
+}
+
+function biosLock(onSolved) {
+  const intro = document.getElementById("bios-intro");
+  const setup = document.getElementById("bios-setup");
+  const list = document.getElementById("bios-boot-order");
+  const status = document.getElementById("bios-status");
+  const listeners = new AbortController();
+  const order = shuffle(bootDevices);
+  let selected = 0;
+  let inSetup = false;
+
+  // Never start already solved
+  if (order[0] === targetDevice) {
+    order.push(order.shift());
+  }
+
+  function render() {
+    const rows = order.map((device, index) => {
+      const row = document.createElement("button");
+      row.type = "button";
+      row.textContent = `${index + 1}. ${device}`;
+      row.setAttribute("aria-pressed", String(index === selected));
+
+      row.addEventListener("click", () => {
+        selected = index;
+        render();
+      });
+
+      return row;
+    });
+
+    list.replaceChildren(...rows);
+  }
+
+  function moveDevice(step) {
+    const other = selected + step;
+
+    if (other < 0 || other >= order.length) {
+      return;
+    }
+
+    [order[selected], order[other]] = [order[other], order[selected]];
+    selected = other;
+    render();
+  }
+
+  const actions = {
+    setup: () => {
+      inSetup = true;
+      intro.hidden = true;
+      setup.hidden = false;
+      render();
+    },
+    up: () => {
+      selected = Math.max(0, selected - 1);
+      render();
+    },
+    down: () => {
+      selected = Math.min(order.length - 1, selected + 1);
+      render();
+    },
+    raise: () => moveDevice(-1),
+    lower: () => moveDevice(1),
+    save: () => {
+      if (order[0] === targetDevice) {
+        listeners.abort();
+        onSolved();
+      } else {
+        status.textContent = `Booting from ${order[0]}… Reboot and select proper boot device.`;
+      }
+    },
+  };
+
+  // "=" is "+" without shift
+  const keyActions = {
+    F2: "setup",
+    Enter: "setup",
+    ArrowUp: "up",
+    ArrowDown: "down",
+    "+": "raise",
+    "=": "raise",
+    "-": "lower",
+    F10: "save",
+  };
+
+  document.addEventListener(
+    "keydown",
+    (event) => {
+      const action = keyActions[event.key];
+      const isAllowed = inSetup ? action !== "setup" : action === "setup";
+
+      if (!action || !isAllowed) {
+        return;
+      }
+
+      event.preventDefault();
+      actions[action]();
+    },
+    { signal: listeners.signal },
+  );
+
+  for (const button of document.querySelectorAll("[data-bios-action]")) {
+    button.addEventListener(
+      "click",
+      () => actions[button.dataset.biosAction](),
+      { signal: listeners.signal },
+    );
+  }
+}
+
+const locks = [
+  {
+    name: "konami",
+    chance: 0.25,
+    run: konamiLock,
+  },
+  {
+    name: "power",
+    chance: 0.2,
+    run: powerLock,
+  },
+  {
+    name: "captcha",
+    chance: 0.2,
+    run: captchaLock,
+  },
+  {
+    name: "overheat",
+    chance: 0.2,
+    run: overheatLock,
+  },
+  {
+    name: "bios",
+    chance: 0.2,
+    run: biosLock,
+  },
+];
+
 // Roll this stage's chance to jam, then show its lock or redirect
 function visit() {
   let stage = readStage();
+  const lock = locks[Math.floor(stage / 2)];
 
-  if (stage === 0 && Math.random() < konamiChance) {
-    stage = 1;
-  }
-
-  if (stage === 2 && Math.random() < powerChance) {
-    stage = 3;
+  if (lock && stage % 2 === 0 && Math.random() < lock.chance) {
+    stage += 1;
   }
 
   writeStage(stage);
 
-  if (stage === 1) {
-    konamiLock(() => {
-      writeStage(2);
-      visit();
-    });
-  } else if (stage === 3) {
-    powerLock(() => {
-      writeStage(4);
+  if (lock && stage % 2 === 1) {
+    document.body.dataset.lock = lock.name;
+
+    lock.run(() => {
+      writeStage(stage + 1);
       visit();
     });
   } else {
-    // shortcut: stage 4+ just redirects, add the next lock here later
     delete document.body.dataset.lock;
     startRedirect();
   }
diff --git a/style.css b/style.css
index dcacfc8..12e02bd 100644
--- a/style.css
+++ b/style.css
@@ -5,6 +5,7 @@
   --text: #3b0a2a;
   --track: #f9d0e4;
   --accent: #db2777;
+  --hot: #dc2626;
 }
 
 @media (prefers-color-scheme: dark) {
@@ -13,6 +14,7 @@
     --text: #fce7f3;
     --track: #3b1730;
     --accent: #f472b6;
+    --hot: #f87171;
   }
 }
 
@@ -79,12 +81,19 @@ body[data-lock] .working-only {
 }
 
 body[data-lock="konami"] .lock-konami,
-body[data-lock="power"] .lock-power {
+body[data-lock="power"] .lock-power,
+body[data-lock="captcha"] .lock-captcha,
+body[data-lock="overheat"] .lock-overheat {
   display: grid;
   justify-items: center;
   gap: 1rem;
 }
 
+body[data-lock="captcha"] .spinner,
+body[data-lock="overheat"] .spinner {
+  animation-play-state: paused;
+}
+
 body[data-lock="konami"] .spinner {
   border-top-color: var(--track);
   border-right-color: var(--accent);
@@ -180,11 +189,126 @@ body[data-lock] .jammed {
   outline-offset: 2px;
 }
 
-.power-status {
+.power-status,
+.lock-status {
   min-height: 1.5em;
   font-style: italic;
 }
 
+.captcha-grid {
+  display: grid;
+  grid-template-columns: repeat(3, 4.5rem);
+  gap: 0.375rem;
+}
+
+.captcha-tile {
+  aspect-ratio: 1;
+  border: 2px solid var(--track);
+  border-radius: 0.25rem;
+  background: var(--track);
+  color: var(--text);
+  font-size: var(--size);
+  cursor: pointer;
+  transform: rotate(var(--tilt));
+}
+
+.captcha-tile[aria-pressed="true"] {
+  border-color: var(--accent);
+  background: var(--accent);
+  color: var(--background);
+}
+
+.captcha-tile:focus-visible {
+  outline: 3px solid var(--accent);
+  outline-offset: 2px;
+}
+
+.temperature {
+  font-size: 2.5rem;
+  font-weight: 700;
+  font-variant-numeric: tabular-nums;
+}
+
+.temperature[data-hot="true"] {
+  color: var(--hot);
+}
+
+#overheat-progress {
+  width: min(16rem, 80vw);
+  accent-color: var(--accent);
+}
+
+/* Fake BIOS takes over the whole screen, same colours in light and dark */
+.lock-bios {
+  position: fixed;
+  inset: 0;
+  max-width: none;
+  padding: 16px;
+  overflow: auto;
+  background: #0000aa;
+  color: #c0c0c0;
+  font-family: ui-monospace, "Courier New", monospace;
+}
+
+body[data-lock="bios"] .lock-bios {
+  display: block;
+}
+
+.lock-bios p {
+  text-align: left;
+}
+
+.lock-bios button {
+  margin: 0.25rem 0.25rem 0 0;
+  padding: 0.25rem 0.5rem;
+  border: 1px solid #c0c0c0;
+  background: none;
+  color: #ffffff;
+  font: inherit;
+  cursor: pointer;
+}
+
+.lock-bios button:focus-visible {
+  outline: 2px solid #ffff55;
+  outline-offset: 2px;
+}
+
+.bios-title {
+  margin-bottom: 1rem;
+  background: #c0c0c0;
+  color: #0000aa;
+  font-weight: 700;
+}
+
+.bios-boot-order {
+  display: grid;
+  justify-items: start;
+  margin: 0.5rem 0 1rem;
+}
+
+.bios-boot-order button {
+  border-color: transparent;
+}
+
+.bios-boot-order button[aria-pressed="true"] {
+  background: #c0c0c0;
+  color: #0000aa;
+}
+
+.bios-status {
+  min-height: 1.5em;
+  color: #ffff55;
+}
+
+.bios-footer {
+  margin: 1rem 0;
+}
+
+.lock-bios .hint summary {
+  color: #ffff55;
+  text-align: left;
+}
+
 .hint summary {
   color: var(--accent);
   cursor: pointer;