Spaces:
Running
Running
Deploy delvewren
Browse files- .gitattributes +1 -0
- README.md +26 -4
- arena.js +290 -0
- cmx.js +276 -0
- core.js +214 -0
- fun.css +95 -0
- funpass.js +428 -0
- game.js +465 -0
- icon-192.png +0 -0
- icon-512.png +0 -0
- icon-maskable.png +0 -0
- icon.svg +1 -0
- index.html +84 -18
- manifest.webmanifest +47 -0
- offer.js +2 -0
- og.png +0 -0
- shot-phone.png +3 -0
- style.css +29 -28
- sw.js +25 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
shot-phone.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,10 +1,32 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: gray
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: "Dig Drone: Dig-down idle upgrade game (hold to drill, upgrades, daily dig, share depth)"
|
| 3 |
+
emoji: 🎮
|
| 4 |
colorFrom: gray
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
license: other
|
| 9 |
+
thumbnail: https://cybermaxtools.com/games/dig-drone/og.png
|
| 10 |
+
short_description: "Hold to dig, slide to steer, upgrade and dig deeper"
|
| 11 |
+
tags:
|
| 12 |
+
- game
|
| 13 |
+
- html5
|
| 14 |
+
- browser-game
|
| 15 |
+
- pwa
|
| 16 |
+
- cybermax
|
| 17 |
---
|
| 18 |
+
**Dig Drone**: Hold to dig, slide to steer, upgrade and dig deeper. A free daily game from CyberMax: the same challenge for everyone each day, a shareable result, works offline and installs on your phone (no app store, no sign-up).
|
| 19 |
|
| 20 |
+
Play it full screen: https://cybermaxtools.com/games/dig-drone/?utm_source=huggingface
|
| 21 |
+
|
| 22 |
+

|
| 23 |
+
|
| 24 |
+
**Embed it free on your site** (works on phones, keeps a small link to CyberMax):
|
| 25 |
+
|
| 26 |
+
```html
|
| 27 |
+
<iframe src="https://cybermaxtools.com/embed/delvewren/" width="480" height="720" style="border:0;max-width:100%;aspect-ratio:2/3;height:auto" title="Dig Drone: free game by CyberMax" loading="lazy" allowfullscreen></iframe>
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
The optional **CyberMax Fun Pass** ($2.99/month, $19/year or $29.99 for life) adds extra packs, the full archive of past dailies and colour themes in every CyberMax game: https://cybermaxtools.com/games/?utm_source=huggingface
|
| 31 |
+
|
| 32 |
+
More free games: https://cybermaxtools.com/games/ · © 2026 CyberMax. All rights reserved.
|
arena.js
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// CyberMax Arena: the cheap social layer of the CyberMax games (31 Oct 2026). Copied into each game by
|
| 2 |
+
// scripts/games/sync_kit.py (web/arena.js, or src/arena.js for bundled games), so every game stays self-contained.
|
| 3 |
+
// Goal: a game can go viral without breaking anything or running up Worker requests (docs/ceo/games-scale-2026-10-31.md).
|
| 4 |
+
// * counts: summed on the device, ONE beacon per session (on hide/close), sampled 1-in-w in high-traffic modes
|
| 5 |
+
// with the weight sent along, so the totals stay right
|
| 6 |
+
// * boards: read at most once per 5/15/60 minutes per device (normal/high/surge), else from this device's copy,
|
| 7 |
+
// else from the static snapshot on cybermaxtools.com (free), else "offline"; the game never waits on it
|
| 8 |
+
// * posts: skipped on the device when the score can't reach the top 20 (and no friend group needs it), queued on the
|
| 9 |
+
// device in surge mode or when the board is busy, and sent later by drain(); never an error for the player
|
| 10 |
+
// * friend groups (6-letter code, no accounts), weekly cups (ISO week, the week's Monday course), head-to-head records
|
| 11 |
+
// Nothing personal: a random device tag (for friend boards), the name the player typed, scores. (c) 2026 CyberMax.
|
| 12 |
+
|
| 13 |
+
export const ARENA_API = 'https://toys.cybermaxtools.com';
|
| 14 |
+
export const POLICY = {
|
| 15 |
+
normal: { w: 1, board: 5 * 60e3 },
|
| 16 |
+
high: { w: 10, board: 15 * 60e3 },
|
| 17 |
+
surge: { w: 100, board: 60 * 60e3 },
|
| 18 |
+
};
|
| 19 |
+
export const BOARD_SIZE = 20;
|
| 20 |
+
const G = globalThis;
|
| 21 |
+
const CODE_RX = /^[A-HJ-NP-Z2-9]{6}$/;
|
| 22 |
+
const CODE_ABC = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
| 23 |
+
|
| 24 |
+
// ------------------------------------------------------------------ storage (never throws: private mode, blocked storage)
|
| 25 |
+
export function ls(key, val) {
|
| 26 |
+
try {
|
| 27 |
+
if (val === undefined) return JSON.parse(G.localStorage.getItem(key) || 'null');
|
| 28 |
+
if (val === null) G.localStorage.removeItem(key); else G.localStorage.setItem(key, JSON.stringify(val));
|
| 29 |
+
} catch { /* private mode */ }
|
| 30 |
+
return val;
|
| 31 |
+
}
|
| 32 |
+
const now = () => Date.now();
|
| 33 |
+
const host = () => { try { return G.location.hostname || ''; } catch { return ''; } };
|
| 34 |
+
/** Our own test runs and local copies send nothing (tests opt in with window.__cmxBeaconTest). */
|
| 35 |
+
export function quiet() {
|
| 36 |
+
if (G.__cmxBeaconTest) return false;
|
| 37 |
+
if (G.__cmxNoBeacon) return true; // portals that allow no outside analytics (set by the platform adapter)
|
| 38 |
+
return /^(localhost|127\.|0\.0\.0\.0|\[::1\])/.test(host()) || !!(G.navigator && G.navigator.webdriver);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
// ------------------------------------------------------------------ traffic mode hint
|
| 42 |
+
/** The mode this device last heard (from a board answer or the static /games/traffic.json), else normal. */
|
| 43 |
+
export function traffic() {
|
| 44 |
+
const h = ls('cmx-traffic');
|
| 45 |
+
return h && h.until > now() && POLICY[h.mode] ? h.mode : 'normal';
|
| 46 |
+
}
|
| 47 |
+
export function noteMode(mode, ttl = 30 * 60e3) {
|
| 48 |
+
if (!POLICY[mode]) return;
|
| 49 |
+
const h = ls('cmx-traffic');
|
| 50 |
+
if (h && h.forced && h.until > now()) return; // a forced mode from the static file wins until it expires
|
| 51 |
+
ls('cmx-traffic', { mode, until: now() + ttl });
|
| 52 |
+
}
|
| 53 |
+
/** Reads /games/traffic.json at most every 6 hours (a free static file; the owner or an agent can force a mode there). */
|
| 54 |
+
export async function loadTraffic(base = '') {
|
| 55 |
+
try {
|
| 56 |
+
if (!G.__cmxTrafficBase && !/(^|\.)cybermaxtools\.com$/.test(host())) return traffic();
|
| 57 |
+
const seen = ls('cmx-traffic-file');
|
| 58 |
+
if (seen && now() - seen < 6 * 3600e3) return traffic();
|
| 59 |
+
ls('cmx-traffic-file', now());
|
| 60 |
+
const r = await G.fetch(`${G.__cmxTrafficBase || base || ''}/games/traffic.json`, { cache: 'no-cache', signal: timeout(3000) });
|
| 61 |
+
const j = r.ok ? await r.json() : null;
|
| 62 |
+
if (j && POLICY[j.mode]) ls('cmx-traffic', { mode: j.mode, until: now() + 6 * 3600e3, forced: true });
|
| 63 |
+
} catch { /* offline: keep what we had */ }
|
| 64 |
+
return traffic();
|
| 65 |
+
}
|
| 66 |
+
const timeout = (ms) => (G.AbortSignal && G.AbortSignal.timeout ? G.AbortSignal.timeout(ms) : undefined);
|
| 67 |
+
|
| 68 |
+
// ------------------------------------------------------------------ counts: one beacon per session
|
| 69 |
+
const pend = new Map(); // game -> { "ev:ch": n }
|
| 70 |
+
let pendN = 0, hooked = false;
|
| 71 |
+
export const sent = []; // beacons sent by this page (tests read it)
|
| 72 |
+
const cleanCh = (c) => String(c || '').toLowerCase().replace(/[^a-z0-9-]/g, '').slice(0, 40);
|
| 73 |
+
/** Count one event. Free: nothing leaves the device until the page is hidden or closed (or 60 events pile up). */
|
| 74 |
+
export function tally(game, ev, ch = '') {
|
| 75 |
+
const c = cleanCh(ch);
|
| 76 |
+
try { G.dispatchEvent && G.dispatchEvent(new G.CustomEvent('cmx:count', { detail: { game, ev, ch: c } })); } catch { /* old browser */ }
|
| 77 |
+
if (quiet()) return;
|
| 78 |
+
const k = `${ev}:${cleanCh((G.__cmxChPrefix || '') + c)}`;
|
| 79 |
+
const m = pend.get(game) || {};
|
| 80 |
+
m[k] = (m[k] || 0) + 1;
|
| 81 |
+
pend.set(game, m);
|
| 82 |
+
pendN++;
|
| 83 |
+
if (!hooked && G.addEventListener) {
|
| 84 |
+
hooked = true;
|
| 85 |
+
G.addEventListener('pagehide', () => flush('pagehide'));
|
| 86 |
+
if (G.document) G.document.addEventListener('visibilitychange', () => { if (G.document.visibilityState === 'hidden') flush('hidden'); });
|
| 87 |
+
}
|
| 88 |
+
if (pendN >= 60) flush('full');
|
| 89 |
+
}
|
| 90 |
+
export const pending = () => Object.fromEntries([...pend].map(([g, m]) => [g, { ...m }]));
|
| 91 |
+
/** Send what is pending: one beacon per game, kept with probability 1/w and weighted by w (unbiased totals). */
|
| 92 |
+
export function flush(why = '') {
|
| 93 |
+
let n = 0;
|
| 94 |
+
const w = POLICY[traffic()].w;
|
| 95 |
+
for (const [game, m] of pend) {
|
| 96 |
+
if (!Object.keys(m).length) continue;
|
| 97 |
+
if ((G.__cmxRandom || Math.random)() * w < 1) {
|
| 98 |
+
const body = JSON.stringify({ t: game, n: m, w });
|
| 99 |
+
try {
|
| 100 |
+
const ok = G.navigator && G.navigator.sendBeacon && G.navigator.sendBeacon(`${ARENA_API}/eb`, new G.Blob([body], { type: 'text/plain' }));
|
| 101 |
+
if (!ok) G.fetch(`${ARENA_API}/eb`, { method: 'POST', body, keepalive: true, mode: 'no-cors', headers: { 'content-type': 'text/plain' } }).catch(() => {});
|
| 102 |
+
} catch { /* never break the game */ }
|
| 103 |
+
sent.push({ game, n: { ...m }, w, why });
|
| 104 |
+
n++;
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
pend.clear();
|
| 108 |
+
pendN = 0;
|
| 109 |
+
return n;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
// ------------------------------------------------------------------ weeks (same maths as the toys Worker, social.js)
|
| 113 |
+
export function weekOf(iso) {
|
| 114 |
+
const [y, m, d] = iso.split('-').map(Number);
|
| 115 |
+
const t = new Date(Date.UTC(y, m - 1, d));
|
| 116 |
+
t.setUTCDate(t.getUTCDate() - ((t.getUTCDay() + 6) % 7) + 3);
|
| 117 |
+
const wy = t.getUTCFullYear();
|
| 118 |
+
return `${wy}-W${String(Math.floor((t - Date.UTC(wy, 0, 1)) / 864e5 / 7) + 1).padStart(2, '0')}`;
|
| 119 |
+
}
|
| 120 |
+
export function mondayOf(wk) {
|
| 121 |
+
const y = +wk.slice(0, 4), w = +wk.slice(6);
|
| 122 |
+
const jan4 = Date.UTC(y, 0, 4), dow = (new Date(jan4).getUTCDay() + 6) % 7;
|
| 123 |
+
return new Date(jan4 - dow * 864e5 + (w - 1) * 7 * 864e5).toISOString().slice(0, 10);
|
| 124 |
+
}
|
| 125 |
+
/** Cup number: #1 = the week of 2 Nov 2026 (the first full week after launch). */
|
| 126 |
+
export const cupNumber = (wk) => Math.round((Date.parse(mondayOf(wk)) - Date.parse('2026-11-02')) / (7 * 864e5)) + 1;
|
| 127 |
+
function stillOpen(d, today) {
|
| 128 |
+
const t = Date.parse(today);
|
| 129 |
+
if (/^\d{4}-\d{2}-\d{2}$/.test(d)) return Math.abs(Date.parse(d) - t) <= 864e5;
|
| 130 |
+
const day = (o) => new Date(t + o * 864e5).toISOString().slice(0, 10);
|
| 131 |
+
return [day(-1), day(0), day(1)].some((x) => weekOf(x) === d);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
// ------------------------------------------------------------------ boards (read through this device's copy)
|
| 135 |
+
const slim = (j) => ({ top: (j.top || []).slice(0, BOARD_SIZE).map((e) => ({ name: e.name, score: e.score })), cut: j.cut || 0,
|
| 136 |
+
ghost: j.ghost && typeof j.ghost.taps === 'string' && j.ghost.taps.length <= 12000 ? j.ghost : null, mode: j.mode || '' });
|
| 137 |
+
const cutOf = (j) => (j && j.top && j.top.length >= BOARD_SIZE ? (j.cut || j.top[j.top.length - 1].score) : 0);
|
| 138 |
+
export function cachedBoard(game, d) { const c = ls(`cmx-board:${game}:${d}`); return c ? { ...c.j, at: c.at } : null; }
|
| 139 |
+
function keepBoard(game, d, j) {
|
| 140 |
+
ls(`cmx-board:${game}:${d}`, { at: now(), j: slim(j) });
|
| 141 |
+
// keep at most 8 board copies on the device
|
| 142 |
+
try {
|
| 143 |
+
const keys = []; for (let i = 0; i < G.localStorage.length; i++) { const k = G.localStorage.key(i); if (k && k.startsWith('cmx-board:')) keys.push(k); }
|
| 144 |
+
if (keys.length > 8) keys.map((k) => [k, (ls(k) || {}).at || 0]).sort((a, b) => a[1] - b[1]).slice(0, keys.length - 8).forEach(([k]) => ls(k, null));
|
| 145 |
+
} catch { /* storage blocked */ }
|
| 146 |
+
}
|
| 147 |
+
/** A board: { top, cut, ghost, mode, src: live|cache|snapshot|stale } or null when nothing is reachable. */
|
| 148 |
+
export async function board(game, d, { fresh = false, wait = 4500 } = {}) {
|
| 149 |
+
const c = ls(`cmx-board:${game}:${d}`);
|
| 150 |
+
if (!fresh && c && now() - c.at < POLICY[traffic()].board) return { ...c.j, src: 'cache' };
|
| 151 |
+
try {
|
| 152 |
+
const r = await G.fetch(`${ARENA_API}/api/board?g=${encodeURIComponent(game)}&d=${encodeURIComponent(d)}`, { signal: timeout(wait) });
|
| 153 |
+
if (r.ok) {
|
| 154 |
+
const j = await r.json();
|
| 155 |
+
if (j.mode) noteMode(j.mode);
|
| 156 |
+
keepBoard(game, d, j);
|
| 157 |
+
return { ...slim(j), src: 'live' };
|
| 158 |
+
}
|
| 159 |
+
} catch { /* offline or capped: fall through */ }
|
| 160 |
+
const snap = await snapshot(game, d);
|
| 161 |
+
if (snap) return { ...snap, src: 'snapshot' };
|
| 162 |
+
return c ? { ...c.j, src: 'stale' } : null;
|
| 163 |
+
}
|
| 164 |
+
/** The static board snapshot written at site build (scripts/games/board_snapshot.py), free to read. */
|
| 165 |
+
async function snapshot(game, d) {
|
| 166 |
+
try {
|
| 167 |
+
if (!G.__cmxSnapshotBase && !/(^|\.)cybermaxtools\.com$/.test(host())) return null;
|
| 168 |
+
const r = await G.fetch(`${G.__cmxSnapshotBase || ''}/games/boards/${game}.json`, { signal: timeout(3000) });
|
| 169 |
+
const j = r.ok ? await r.json() : null;
|
| 170 |
+
const b = j && j.boards && j.boards[d];
|
| 171 |
+
return b ? slim(b) : null;
|
| 172 |
+
} catch { return null; }
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
// ------------------------------------------------------------------ device tag, friend groups
|
| 176 |
+
export function tag() {
|
| 177 |
+
let p = ls('cmx-p');
|
| 178 |
+
if (!/^[a-z0-9]{8}$/.test(p || '')) { p = ''; for (let i = 0; i < 8; i++) p += 'abcdefghijkmnpqrstuvwxyz23456789'[Math.floor(Math.random() * 32)]; ls('cmx-p', p); }
|
| 179 |
+
return p;
|
| 180 |
+
}
|
| 181 |
+
export const cleanNick = (n) => String(n || '').replace(/[^A-Za-z0-9 ]/g, '').replace(/\s+/g, ' ').trim().slice(0, 10);
|
| 182 |
+
export const myGroups = () => (Array.isArray(ls('cmx-groups')) ? ls('cmx-groups').filter((g) => CODE_RX.test(g.code)) : []);
|
| 183 |
+
export function joinGroup(code) {
|
| 184 |
+
code = String(code || '').toUpperCase();
|
| 185 |
+
if (!CODE_RX.test(code)) return false;
|
| 186 |
+
const gs = myGroups().filter((g) => g.code !== code);
|
| 187 |
+
gs.unshift({ code, at: now() });
|
| 188 |
+
ls('cmx-groups', gs.slice(0, 3)); // at most 3 groups per device
|
| 189 |
+
return true;
|
| 190 |
+
}
|
| 191 |
+
export function leaveGroup(code) { ls('cmx-groups', myGroups().filter((g) => g.code !== code)); }
|
| 192 |
+
export function newGroup() {
|
| 193 |
+
let c = ''; for (let i = 0; i < 6; i++) c += CODE_ABC[Math.floor(Math.random() * CODE_ABC.length)];
|
| 194 |
+
joinGroup(c);
|
| 195 |
+
return c;
|
| 196 |
+
}
|
| 197 |
+
/** ?fg=CODE in the link joins that group (returns the code, or ''). */
|
| 198 |
+
export function groupFromUrl(search) {
|
| 199 |
+
try { const c = new URLSearchParams(search ?? G.location.search).get('fg'); return c && joinGroup(c) ? c.toUpperCase() : ''; } catch { return ''; }
|
| 200 |
+
}
|
| 201 |
+
export function groupLink(url, code) { const u = new URL(url); u.searchParams.set('fg', code); return u.toString(); }
|
| 202 |
+
export async function groupBoard(game, code, d, { fresh = false } = {}) {
|
| 203 |
+
const key = `cmx-group:${game}:${code}:${d}`, c = ls(key);
|
| 204 |
+
if (!fresh && c && now() - c.at < POLICY[traffic()].board) return { ...c.j, src: 'cache' };
|
| 205 |
+
try {
|
| 206 |
+
const r = await G.fetch(`${ARENA_API}/api/group?g=${encodeURIComponent(game)}&d=${encodeURIComponent(d)}&code=${code}`, { signal: timeout(4500) });
|
| 207 |
+
if (r.ok) { const j = await r.json(); if (j.mode) noteMode(j.mode); const v = { top: (j.top || []).slice(0, 50) }; ls(key, { at: now(), j: v }); return { ...v, src: 'live' }; }
|
| 208 |
+
} catch { /* offline */ }
|
| 209 |
+
return c ? { ...c.j, src: 'stale' } : null;
|
| 210 |
+
}
|
| 211 |
+
const gbestKey = (game, code, d) => `${game}|${code}|${d}`;
|
| 212 |
+
function gbest(game, code, d, score) {
|
| 213 |
+
const m = ls('cmx-gbest') || {};
|
| 214 |
+
if (score === undefined) return m[gbestKey(game, code, d)] || 0;
|
| 215 |
+
m[gbestKey(game, code, d)] = score;
|
| 216 |
+
const ks = Object.keys(m); if (ks.length > 60) for (const k of ks.slice(0, ks.length - 60)) delete m[k];
|
| 217 |
+
ls('cmx-gbest', m);
|
| 218 |
+
return score;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
// ------------------------------------------------------------------ posting (gated, queued, never an error)
|
| 222 |
+
/**
|
| 223 |
+
* Post a run to the daily (d = YYYY-MM-DD) or weekly (d = YYYY-Www) board and the player's friend groups.
|
| 224 |
+
* Returns { state: posted|skipped|queued|refused, rank, score, message, groups }.
|
| 225 |
+
*/
|
| 226 |
+
export async function post(game, d, { name, taps, score, nick = '', groups = true, today = '' } = {}) {
|
| 227 |
+
const gs = groups ? myGroups().map((g) => g.code).filter((code) => score > gbest(game, code, d)) : [];
|
| 228 |
+
const c = cachedBoard(game, d);
|
| 229 |
+
const cut = cutOf(c);
|
| 230 |
+
if (cut && score <= cut && !gs.length) return { state: 'skipped', rank: 0, score, cut, message: `Saved on this device. The top 20 starts at ${cut.toLocaleString('en-US')}.` };
|
| 231 |
+
const item = { game, d, name, taps, score, nick: cleanNick(nick) || name, gs, at: now(), today };
|
| 232 |
+
if (traffic() === 'surge') return queue(item, 'Busy moment on the board: saved, and it posts on its own later.');
|
| 233 |
+
return send(item);
|
| 234 |
+
}
|
| 235 |
+
async function send(item) {
|
| 236 |
+
let r;
|
| 237 |
+
try {
|
| 238 |
+
r = await G.fetch(`${ARENA_API}/api/board`, { method: 'POST', headers: { 'content-type': 'application/json' }, signal: timeout(8000),
|
| 239 |
+
body: JSON.stringify({ g: item.game, d: item.d, name: item.name, taps: item.taps, s: item.score, groups: item.gs, p: item.gs.length ? tag() : undefined, nick: item.nick }) });
|
| 240 |
+
} catch { return queue(item, 'Offline for now: saved, and it posts on its own later.'); }
|
| 241 |
+
let j = null; try { j = await r.json(); } catch { /* not JSON */ }
|
| 242 |
+
if (r.ok && j && j.ok) {
|
| 243 |
+
if (j.mode) noteMode(j.mode);
|
| 244 |
+
if (Array.isArray(j.top)) keepBoard(item.game, item.d, j);
|
| 245 |
+
for (const g of j.groups || []) if (g && g.best) gbest(item.game, g.code, item.d, g.best);
|
| 246 |
+
return { state: 'posted', rank: j.rank || 0, score: j.score ?? item.score, groups: j.groups || [], checked: j.checked !== false,
|
| 247 |
+
message: j.rank ? `Posted! You're #${j.rank}.` : 'Posted! Not in the top 20 yet. Keep going.' };
|
| 248 |
+
}
|
| 249 |
+
if (r.status === 422 || r.status === 400) return { state: 'refused', rank: 0, score: item.score, message: (j && j.message) || 'That run could not be posted.' };
|
| 250 |
+
return queue(item, 'The board is busy: saved, and it posts on its own later.');
|
| 251 |
+
}
|
| 252 |
+
function queue(item, message) {
|
| 253 |
+
const q = (ls('cmx-q') || []).filter((x) => !(x.game === item.game && x.d === item.d && x.score >= item.score));
|
| 254 |
+
if (!q.some((x) => x.game === item.game && x.d === item.d)) q.push(item);
|
| 255 |
+
else for (let i = 0; i < q.length; i++) if (q[i].game === item.game && q[i].d === item.d) q[i] = item;
|
| 256 |
+
ls('cmx-q', q.slice(-10));
|
| 257 |
+
return { state: 'queued', rank: 0, score: item.score, message };
|
| 258 |
+
}
|
| 259 |
+
export const queued = (game) => (ls('cmx-q') || []).filter((x) => !game || x.game === game);
|
| 260 |
+
/** Send at most ONE queued post for this game (call once at boot); drops posts whose day or week has closed. */
|
| 261 |
+
export async function drain(game, today) {
|
| 262 |
+
if (traffic() === 'surge') return null;
|
| 263 |
+
const q = ls('cmx-q') || [];
|
| 264 |
+
const keep = q.filter((x) => stillOpen(x.d, today || new Date().toISOString().slice(0, 10)));
|
| 265 |
+
const i = keep.findIndex((x) => x.game === game);
|
| 266 |
+
if (i < 0) { ls('cmx-q', keep); return null; }
|
| 267 |
+
const [item] = keep.splice(i, 1);
|
| 268 |
+
ls('cmx-q', keep);
|
| 269 |
+
return send(item);
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
// ------------------------------------------------------------------ head-to-head records (challenge links, on the device)
|
| 273 |
+
/** Record one finished challenge (id = the challenge link's run id); returns the record against that rival. */
|
| 274 |
+
export function h2hRecord(game, rival, id, mine, theirs) {
|
| 275 |
+
const all = ls('cmx-h2h') || {};
|
| 276 |
+
const g = all[game] || (all[game] = {});
|
| 277 |
+
const key = cleanNick(rival).toLowerCase() || 'friend';
|
| 278 |
+
const r = g[key] || (g[key] = { name: cleanNick(rival) || 'Friend', c: {} });
|
| 279 |
+
const prev = r.c[id];
|
| 280 |
+
if (!prev || mine > prev.mine) r.c[id] = { mine, theirs };
|
| 281 |
+
const ids = Object.keys(r.c); if (ids.length > 50) for (const k of ids.slice(0, ids.length - 50)) delete r.c[k];
|
| 282 |
+
ls('cmx-h2h', all);
|
| 283 |
+
return h2h(game, rival);
|
| 284 |
+
}
|
| 285 |
+
export function h2h(game, rival) {
|
| 286 |
+
const r = ((ls('cmx-h2h') || {})[game] || {})[cleanNick(rival).toLowerCase() || 'friend'];
|
| 287 |
+
const out = { name: r ? r.name : cleanNick(rival), w: 0, l: 0, t: 0 };
|
| 288 |
+
if (r) for (const { mine, theirs } of Object.values(r.c)) { if (mine > theirs) out.w++; else if (mine < theirs) out.l++; else out.t++; }
|
| 289 |
+
return out;
|
| 290 |
+
}
|
cmx.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// CyberMax Fun kit: shared browser helpers for the CyberMax games (copied into each game's web/ folder by
|
| 2 |
+
// scripts/games/sync_kit.py, so every game stays self-contained and sellable on its own).
|
| 3 |
+
// Counter beacon (game + event + channel only: no cookies, no IDs, nothing personal), daily seed, share, PWA install.
|
| 4 |
+
// (c) 2026 CyberMax. All rights reserved.
|
| 5 |
+
import { tally } from './arena.js';
|
| 6 |
+
|
| 7 |
+
export const SITE = 'https://cybermaxtools.com';
|
| 8 |
+
export const API = 'https://toys.cybermaxtools.com';
|
| 9 |
+
export const EPOCH = Date.UTC(2026, 9, 2); // 2 Oct 2026 = puzzle #1 for every CyberMax daily game
|
| 10 |
+
|
| 11 |
+
/** Today's date in the player's own time zone as YYYY-MM-DD (everyone gets a new puzzle at their local midnight). */
|
| 12 |
+
export function today(d = new Date()) {
|
| 13 |
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
| 14 |
+
}
|
| 15 |
+
/** Puzzle number for a YYYY-MM-DD date (#1 = 2026-10-02). */
|
| 16 |
+
export function dayNumber(iso) {
|
| 17 |
+
const [y, m, d] = iso.split('-').map(Number);
|
| 18 |
+
return Math.round((Date.UTC(y, m - 1, d) - EPOCH) / 864e5) + 1;
|
| 19 |
+
}
|
| 20 |
+
export function dateOf(n) {
|
| 21 |
+
const t = new Date(EPOCH + (n - 1) * 864e5);
|
| 22 |
+
return t.toISOString().slice(0, 10);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/** 32-bit string hash (FNV-1a) and a small fast PRNG (mulberry32): the same seed gives the same game everywhere. */
|
| 26 |
+
export function hash(str) {
|
| 27 |
+
let h = 0x811c9dc5;
|
| 28 |
+
for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 0x01000193); }
|
| 29 |
+
return h >>> 0;
|
| 30 |
+
}
|
| 31 |
+
export function rng(seed) {
|
| 32 |
+
let a = typeof seed === 'string' ? hash(seed) : seed >>> 0;
|
| 33 |
+
return function () {
|
| 34 |
+
a = (a + 0x6d2b79f5) >>> 0;
|
| 35 |
+
let t = a;
|
| 36 |
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
| 37 |
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
| 38 |
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
| 39 |
+
};
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Count one event (play, win, share, install, pro, cta). Never breaks the page; skipped on localhost and in tests.
|
| 44 |
+
* 31 Oct 2026 (scale fix): events are summed on the device and sent as ONE beacon per session (arena.js tally), sampled
|
| 45 |
+
* with a weight in high-traffic modes, instead of one Worker request per event. It still fires a "cmx:count" event.
|
| 46 |
+
*/
|
| 47 |
+
export function count(game, ev, ch = '') {
|
| 48 |
+
try { tally(game, ev, ch); } catch { /* never break the game */ }
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
export function store(key, val) {
|
| 52 |
+
try {
|
| 53 |
+
if (val === undefined) return JSON.parse(localStorage.getItem(key) || 'null');
|
| 54 |
+
localStorage.setItem(key, JSON.stringify(val));
|
| 55 |
+
} catch { /* private mode */ }
|
| 56 |
+
return val;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
export function toast(msg, ms = 2400) {
|
| 60 |
+
let t = document.getElementById('toast');
|
| 61 |
+
if (!t) { t = document.createElement('div'); t.id = 'toast'; t.setAttribute('role', 'status'); document.body.appendChild(t); }
|
| 62 |
+
t.textContent = msg;
|
| 63 |
+
t.classList.add('on');
|
| 64 |
+
clearTimeout(t._h);
|
| 65 |
+
t._h = setTimeout(() => t.classList.remove('on'), ms);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/** The link people share: the canonical game page with UTM tags the site view counter reads. */
|
| 69 |
+
export function shareLink(path, channel, game) {
|
| 70 |
+
const u = new URL(SITE + path);
|
| 71 |
+
u.searchParams.set('utm_source', channel);
|
| 72 |
+
u.searchParams.set('utm_medium', 'share');
|
| 73 |
+
u.searchParams.set('utm_campaign', `game-${game}`);
|
| 74 |
+
return u.toString();
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Share a result: native share sheet on phones (text + optional PNG card), else copy to clipboard.
|
| 79 |
+
* text = Wordle-style text block; path = the game's path on the CyberMax site; blob = optional PNG card.
|
| 80 |
+
*/
|
| 81 |
+
export async function share(game, text, path, blob, filename) {
|
| 82 |
+
const url = shareLink(path, 'share', game);
|
| 83 |
+
const full = `${text}\n${url}`;
|
| 84 |
+
if (navigator.share) {
|
| 85 |
+
try {
|
| 86 |
+
const file = blob ? new File([blob], filename || `${game}.png`, { type: 'image/png' }) : null;
|
| 87 |
+
const data = file && navigator.canShare && navigator.canShare({ files: [file] }) ? { files: [file], text: full } : { text: full };
|
| 88 |
+
await navigator.share(data);
|
| 89 |
+
count(game, 'share', 'native');
|
| 90 |
+
return 'shared';
|
| 91 |
+
} catch (e) {
|
| 92 |
+
if (e && e.name === 'AbortError') return 'cancelled';
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
try { await navigator.clipboard.writeText(full); toast('Result copied. Paste it anywhere.'); } catch { prompt('Copy your result:', full); }
|
| 96 |
+
count(game, 'share', 'copy');
|
| 97 |
+
return 'copied';
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
export function intents(game, text, path) {
|
| 101 |
+
const u = (ch) => shareLink(path, ch, game);
|
| 102 |
+
return {
|
| 103 |
+
x: `https://x.com/intent/post?text=${encodeURIComponent(text)}&url=${encodeURIComponent(u('x'))}`,
|
| 104 |
+
bsky: `https://bsky.app/intent/compose?text=${encodeURIComponent(`${text}\n${u('bsky')}`)}`,
|
| 105 |
+
whatsapp: `https://wa.me/?text=${encodeURIComponent(`${text}\n${u('whatsapp')}`)}`,
|
| 106 |
+
};
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
export function download(blob, filename) {
|
| 110 |
+
const a = document.createElement('a');
|
| 111 |
+
a.href = URL.createObjectURL(blob);
|
| 112 |
+
a.download = filename;
|
| 113 |
+
document.body.appendChild(a);
|
| 114 |
+
a.click();
|
| 115 |
+
setTimeout(() => { URL.revokeObjectURL(a.href); a.remove(); }, 1500);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Installable app: registers the service worker (offline play) and shows an "Add to Home Screen" button.
|
| 120 |
+
* Chrome/Edge/Android: the real install prompt. iPhone/iPad Safari: a short Share → Add to Home Screen hint.
|
| 121 |
+
* The button only appears after the first finished round (offer(): never on first load) and never once installed.
|
| 122 |
+
*/
|
| 123 |
+
export function pwa(game, btn) {
|
| 124 |
+
if ('serviceWorker' in navigator && (location.protocol === 'https:' || location.hostname === 'localhost')) {
|
| 125 |
+
navigator.serviceWorker.register('sw.js').catch(() => {});
|
| 126 |
+
}
|
| 127 |
+
const standalone = matchMedia('(display-mode: standalone)').matches || navigator.standalone;
|
| 128 |
+
if (standalone) { count(game, 'play', 'app'); return { offer() {} }; }
|
| 129 |
+
let deferred = null;
|
| 130 |
+
let wanted = false;
|
| 131 |
+
const ios = /iphone|ipad|ipod/i.test(navigator.userAgent) && !/crios|fxios/i.test(navigator.userAgent);
|
| 132 |
+
window.addEventListener('beforeinstallprompt', (e) => { e.preventDefault(); deferred = e; if (wanted && btn && !store(`cmx-install-no:${game}`)) btn.hidden = false; });
|
| 133 |
+
window.addEventListener('appinstalled', () => { count(game, 'install', 'prompt'); if (btn) btn.hidden = true; });
|
| 134 |
+
if (btn) {
|
| 135 |
+
btn.addEventListener('click', async () => {
|
| 136 |
+
if (deferred) {
|
| 137 |
+
deferred.prompt();
|
| 138 |
+
const r = await deferred.userChoice.catch(() => null);
|
| 139 |
+
if (r && r.outcome === 'accepted') btn.hidden = true;
|
| 140 |
+
else if (r && r.outcome === 'dismissed') { store(`cmx-install-no:${game}`, 1); btn.hidden = true; } // "Not now" is remembered
|
| 141 |
+
deferred = null;
|
| 142 |
+
} else if (ios) {
|
| 143 |
+
toast('Tap the Share button, then "Add to Home Screen".', 5000);
|
| 144 |
+
count(game, 'install', 'ios-hint');
|
| 145 |
+
store(`cmx-install-no:${game}`, 1);
|
| 146 |
+
}
|
| 147 |
+
});
|
| 148 |
+
}
|
| 149 |
+
return {
|
| 150 |
+
offer() {
|
| 151 |
+
wanted = true;
|
| 152 |
+
if (btn && (deferred || ios) && !store(`cmx-install-no:${game}`)) btn.hidden = false;
|
| 153 |
+
},
|
| 154 |
+
};
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/** Rounded rectangle path for canvas cards. */
|
| 158 |
+
export function rr(ctx, x, y, w, h, r) {
|
| 159 |
+
ctx.beginPath();
|
| 160 |
+
ctx.moveTo(x + r, y);
|
| 161 |
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
| 162 |
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
| 163 |
+
ctx.arcTo(x, y + h, x, y, r);
|
| 164 |
+
ctx.arcTo(x, y, x + w, y, r);
|
| 165 |
+
ctx.closePath();
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
export const canvasBlob = (canvas) => new Promise((res) => canvas.toBlob(res, 'image/png'));
|
| 169 |
+
|
| 170 |
+
/** Theme toggle shared by every page (light/dark, remembered). */
|
| 171 |
+
export function themeToggle(btn) {
|
| 172 |
+
if (!btn) return;
|
| 173 |
+
btn.addEventListener('click', () => {
|
| 174 |
+
const r = document.documentElement;
|
| 175 |
+
const c = r.dataset.theme || 'dark'; // games default to the dark arcade look (fun.css)
|
| 176 |
+
const n = c === 'dark' ? 'light' : 'dark';
|
| 177 |
+
r.dataset.theme = n;
|
| 178 |
+
store('cm-theme-v', n);
|
| 179 |
+
try { localStorage.setItem('cm-theme', n); } catch { /* private mode */ }
|
| 180 |
+
});
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
// ------------------------------------------------------------------ first-touch attribution on buy links
|
| 184 |
+
// First-sale review (29 Oct 2026, docs/ceo/first-sale-2026-10-27.md): the first paid order could be traced to the page
|
| 185 |
+
// that sold it but not to where the buyer came from. So the first time this browser opens a CyberMax page, one short tag
|
| 186 |
+
// is kept in localStorage (no cookie, no id, never sent on its own): where it came from (utm_source + utm_campaign, s=,
|
| 187 |
+
// the referrer's host or "direct") and the landing page, e.g. "ft-youtube-brimbloom-at-games-brimbloom". A Buy click
|
| 188 |
+
// carries it: s=<source>--<tag> on data.cybermaxtools.com/buy links (the Worker copies s into client_reference_id
|
| 189 |
+
// "data_<s>"), client_reference_id=<id>--<tag> on buy.stripe.com links. No extra request, page view or Worker call.
|
| 190 |
+
// The same code is in shared/convert-kit/convert.js (site pages), so the tag is shared across cybermaxtools.com.
|
| 191 |
+
const FT_KEY = 'cmx-ft';
|
| 192 |
+
const FT_DAYS = 90;
|
| 193 |
+
const ftSlug = (x, n) => String(x || '').toLowerCase().replace(/^www\./, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+/, '').slice(0, n).replace(/-+$/, '');
|
| 194 |
+
// words collect.py reads as "our own test" (TEST_MARK) never appear in a buyer's tag
|
| 195 |
+
const ftClean = (t) => t.replace(/(^|-)(test|e2e|check|probe|audit|lane\d*|internal)(?=-|$)/g, '$1x');
|
| 196 |
+
export function ftCompute(loc, referrer) {
|
| 197 |
+
const q = new URLSearchParams(loc.search || '');
|
| 198 |
+
const us = q.get('utm_source'), uc = q.get('utm_campaign'), s = q.get('s');
|
| 199 |
+
let ch;
|
| 200 |
+
if (us) ch = ftSlug(us, 14) + (uc ? `-${ftSlug(String(uc).replace(/^\d{4}-\d{2}-\d{2}-(\d+-)?/, ''), 18)}` : ''); // post ids start with a date
|
| 201 |
+
else if (s) ch = `s-${ftSlug(s, 24)}`;
|
| 202 |
+
else {
|
| 203 |
+
let host = '';
|
| 204 |
+
try { host = referrer ? new URL(referrer).hostname.toLowerCase() : ''; } catch { host = 'other'; }
|
| 205 |
+
ch = !host ? 'direct' : /(^|\.)cybermaxtools\.com$|cybermax-tools/.test(host) ? `site-${ftSlug(host.split('.')[0], 12)}` : `r-${ftSlug(host, 24)}`;
|
| 206 |
+
}
|
| 207 |
+
const segs = String(loc.pathname || '/').toLowerCase().split('/').filter((x) => x && !/^index\.html?$/.test(x));
|
| 208 |
+
const land = ftSlug(segs.slice(-2).join('-'), 18) || 'home';
|
| 209 |
+
return ftClean(`ft-${ch || 'direct'}-at-${land}`).slice(0, 48).replace(/-+$/, '');
|
| 210 |
+
}
|
| 211 |
+
/** The first-touch tag of this browser ('' when storage is blocked). Recorded once, kept FT_DAYS days. */
|
| 212 |
+
export function firstTouch() {
|
| 213 |
+
try {
|
| 214 |
+
const old = JSON.parse(localStorage.getItem(FT_KEY) || 'null');
|
| 215 |
+
if (old && old.t && Date.now() - old.at < FT_DAYS * 864e5) return old.t;
|
| 216 |
+
const t = ftCompute(location, document.referrer);
|
| 217 |
+
localStorage.setItem(FT_KEY, JSON.stringify({ t, at: Date.now() }));
|
| 218 |
+
return t;
|
| 219 |
+
} catch { return ''; }
|
| 220 |
+
}
|
| 221 |
+
/** href with the first-touch tag added (data /buy links: s; Stripe links: client_reference_id). Pure, for tests too. */
|
| 222 |
+
export function ftTagUrl(href, t) {
|
| 223 |
+
if (!t) return href;
|
| 224 |
+
try {
|
| 225 |
+
const u = new URL(href);
|
| 226 |
+
if (u.hostname === 'data.cybermaxtools.com' && u.pathname.startsWith('/buy/')) {
|
| 227 |
+
const s = (u.searchParams.get('s') || 'unknown').toLowerCase().replace(/[^a-z0-9-]/g, '');
|
| 228 |
+
if (s.includes('--ft-')) return href;
|
| 229 |
+
u.searchParams.set('s', `${s}--${t}`.slice(0, 80).replace(/-+$/, '')); // the Worker keeps s to 80 chars of [a-z0-9-]
|
| 230 |
+
return u.toString();
|
| 231 |
+
}
|
| 232 |
+
if (u.hostname === 'buy.stripe.com') {
|
| 233 |
+
const c = u.searchParams.get('client_reference_id') || 'data_unknown';
|
| 234 |
+
if (c.includes('--ft-')) return href;
|
| 235 |
+
u.searchParams.set('client_reference_id', `${c}--${t}`.slice(0, 200)); // Stripe: 200 chars of letters, digits, - and _
|
| 236 |
+
return u.toString();
|
| 237 |
+
}
|
| 238 |
+
} catch { /* not a URL */ }
|
| 239 |
+
return href;
|
| 240 |
+
}
|
| 241 |
+
if (typeof document !== 'undefined' && typeof location !== 'undefined' && !window.__cmxFt) {
|
| 242 |
+
window.__cmxFt = 1;
|
| 243 |
+
firstTouch();
|
| 244 |
+
// capture phase, registered before funpass.js/skins.js add their direct-checkout handler (they import this module)
|
| 245 |
+
document.addEventListener('click', (e) => {
|
| 246 |
+
const a = e.target && e.target.closest && e.target.closest('a[href*="data.cybermaxtools.com/buy/"],a[href*="buy.stripe.com/"]');
|
| 247 |
+
if (a) { const t = firstTouch(); if (t) a.href = ftTagUrl(a.href, t); }
|
| 248 |
+
}, true);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
// ------------------------------------------------------------------ calm play focus (7 Nov 2026 quality pass)
|
| 252 |
+
// "Calm screens in every game": on a phone, a touch on the board (the stage canvas or board inside section.game) sets
|
| 253 |
+
// html.cmx-focus, and fun.css then hides the shop/skin/pass buttons, the swatches and the "Get more" row until the round
|
| 254 |
+
// ends. A results panel appearing (#over, #win, #done, .win, .over) or a touch outside the game clears it; a touch on the board sets it again even if old results stay on screen. Pure CSS
|
| 255 |
+
// hooks: a game without section.game is untouched.
|
| 256 |
+
export const FOCUS_END = '#over,#win,#done,.win,.over,[data-cmx-end]';
|
| 257 |
+
export function focusWatch(doc = document) {
|
| 258 |
+
const game = doc.querySelector('section.game');
|
| 259 |
+
if (!game || doc.documentElement.dataset.cmxFocus === 'off') return null;
|
| 260 |
+
const root = doc.documentElement;
|
| 261 |
+
const stage = (t) => t && t.closest && t.closest('canvas,#board,#arena,.board-wrap,.stage,#stage,[class$="-wrap"]') && game.contains(t);
|
| 262 |
+
const shown = () => new Set([...game.querySelectorAll(FOCUS_END)].filter((e) => !e.hidden && e.offsetParent !== null));
|
| 263 |
+
const set = (on) => root.classList.toggle('cmx-focus', !!on);
|
| 264 |
+
let was = shown();
|
| 265 |
+
// a touch on the board starts (or keeps) the focus, even when last round's results stay on screen below it
|
| 266 |
+
doc.addEventListener('pointerdown', (e) => { if (stage(e.target)) { set(true); was = shown(); } else if (!game.contains(e.target)) set(false); }, true);
|
| 267 |
+
// a results panel that newly appears ends it
|
| 268 |
+
new MutationObserver(() => { const now = shown(); if ([...now].some((x) => !was.has(x))) set(false); was = now; })
|
| 269 |
+
.observe(game, { subtree: true, attributes: true, attributeFilter: ['hidden', 'class'] });
|
| 270 |
+
return { set, shown };
|
| 271 |
+
}
|
| 272 |
+
if (typeof document !== 'undefined' && !window.__cmxFocus) {
|
| 273 |
+
window.__cmxFocus = 1;
|
| 274 |
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => focusWatch(), { once: true });
|
| 275 |
+
else focusWatch();
|
| 276 |
+
}
|
core.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Dig Drone core: a dig-down upgrade game, no DOM (runs in the page and in node tests).
|
| 2 |
+
// Hold to drill down, slide to steer, ores pay coins, coins buy upgrades between runs, a drone digs while you're away.
|
| 3 |
+
// Fixed 60 Hz ticks; the ground is a pure function of (seed, row), so the Daily Dig is the same for everyone.
|
| 4 |
+
// (c) 2026 CyberMax. All rights reserved.
|
| 5 |
+
|
| 6 |
+
export const HZ = 60;
|
| 7 |
+
export const COLS = 9;
|
| 8 |
+
export const TS = 40; // tile size in world units (the view is 360 wide)
|
| 9 |
+
export const VIEW_W = COLS * TS, VIEW_H = 540;
|
| 10 |
+
export const BIOME_ROWS = 40;
|
| 11 |
+
export const T = { AIR: 0, SOIL: 1, ROCK: 2, BOULDER: 3, COPPER: 4, SILVER: 5, GOLD: 6, GEM: 7, FUEL: 8 };
|
| 12 |
+
export const ORE = { 4: 1, 5: 3, 6: 8, 7: 25 }; // coins per ore (before the Value upgrade)
|
| 13 |
+
const HP = { 1: 1, 2: 3, 3: 9, 4: 1.4, 5: 1.6, 6: 1.8, 7: 2, 8: 0.8 };
|
| 14 |
+
export const BIOMES = [
|
| 15 |
+
{ name: 'Meadow Soil', soil: '#C98A4B', rock: '#9C7A5B', deep: '#8A5A2E' },
|
| 16 |
+
{ name: 'Clay Bank', soil: '#E58A55', rock: '#B66A45', deep: '#A2502A' },
|
| 17 |
+
{ name: 'Sandstone', soil: '#EFC266', rock: '#C9A15A', deep: '#B9822E' },
|
| 18 |
+
{ name: 'Slate Deep', soil: '#7FA9CC', rock: '#5E7F9E', deep: '#47668A' },
|
| 19 |
+
{ name: 'Crystal Caves', soil: '#B49BF5', rock: '#8C74D6', deep: '#6F55BE' },
|
| 20 |
+
{ name: 'Ember Rock', soil: '#F2836B', rock: '#C95F4E', deep: '#A8433A' },
|
| 21 |
+
{ name: 'Golden Core', soil: '#F7CF5C', rock: '#E0A93B', deep: '#C98A1E' },
|
| 22 |
+
];
|
| 23 |
+
export const LAYER_EMOJI = ['🟫', '🟧', '🟨', '🟦', '🟪', '🟥', '⭐'];
|
| 24 |
+
export const biomeOf = (row) => Math.min(BIOMES.length - 1, Math.max(0, Math.floor((row - 1) / BIOME_ROWS)));
|
| 25 |
+
|
| 26 |
+
function hash(str) {
|
| 27 |
+
let h = 0x811c9dc5;
|
| 28 |
+
for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 0x01000193); }
|
| 29 |
+
return h >>> 0;
|
| 30 |
+
}
|
| 31 |
+
export function rng(seed) {
|
| 32 |
+
let a = typeof seed === 'string' ? hash(seed) : seed >>> 0;
|
| 33 |
+
return function () {
|
| 34 |
+
a = (a + 0x6d2b79f5) >>> 0;
|
| 35 |
+
let t = a;
|
| 36 |
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
| 37 |
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
| 38 |
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
| 39 |
+
};
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/** One row of ground: COLS tile types. Row 0 is the grassy surface. Pure: the same (seed, row) always gives the same row. */
|
| 43 |
+
export function genRow(seed, row) {
|
| 44 |
+
if (row <= 0) return new Array(COLS).fill(T.SOIL);
|
| 45 |
+
const r = rng(`delvewren:${seed}:${row}`);
|
| 46 |
+
const b = biomeOf(row);
|
| 47 |
+
const out = [];
|
| 48 |
+
for (let c = 0; c < COLS; c++) {
|
| 49 |
+
const x = r();
|
| 50 |
+
let p = 0, t = T.SOIL;
|
| 51 |
+
const pick = (q, type) => { if (t === T.SOIL && x >= p && x < p + q) t = type; p += q; };
|
| 52 |
+
pick(row > 3 ? 0.05 : 0, T.AIR);
|
| 53 |
+
pick(row > 6 ? 0.03 + 0.02 * b : 0, T.BOULDER);
|
| 54 |
+
pick(0.14 + 0.03 * b, T.ROCK);
|
| 55 |
+
pick(0.07, T.COPPER);
|
| 56 |
+
pick(b >= 1 ? 0.035 : 0.01, T.SILVER);
|
| 57 |
+
pick(b >= 2 ? 0.025 : 0, T.GOLD);
|
| 58 |
+
pick(b >= 3 ? 0.014 : 0, T.GEM);
|
| 59 |
+
pick(row > 8 ? 0.009 : 0, T.FUEL);
|
| 60 |
+
out.push(t);
|
| 61 |
+
}
|
| 62 |
+
// fairness: never more than 3 boulders in a row, so there is always a way down
|
| 63 |
+
let bould = out.reduce((n, t) => n + (t === T.BOULDER), 0);
|
| 64 |
+
for (let c = 0; c < COLS && bould > 3; c++) if (out[c] === T.BOULDER) { out[c] = T.ROCK; bould--; }
|
| 65 |
+
return out;
|
| 66 |
+
}
|
| 67 |
+
export const hpOf = (type, row) => (HP[type] || 0) * (1 + 0.35 * biomeOf(row));
|
| 68 |
+
|
| 69 |
+
// ------------------------------------------------------------------ upgrades (the "idle" depth between runs)
|
| 70 |
+
export const UPGRADES = {
|
| 71 |
+
drill: { name: 'Drill', icon: '⛏️', what: 'Digs faster, cracks boulders', base: 15, mult: 1.62, max: 25 },
|
| 72 |
+
tank: { name: 'Fuel tank', icon: '⛽', what: 'Longer runs', base: 15, mult: 1.62, max: 25 },
|
| 73 |
+
magnet: { name: 'Magnet', icon: '🧲', what: 'Pulls ores from side columns', base: 60, mult: 2.4, max: 3 },
|
| 74 |
+
value: { name: 'Polish', icon: '💎', what: '+25% coins per ore', base: 30, mult: 1.7, max: 10 },
|
| 75 |
+
};
|
| 76 |
+
export const DAILY_RIG = { drill: 4, tank: 4, magnet: 1, value: 0 }; // the Daily Dig: the same rig for everyone
|
| 77 |
+
export const upgradeCost = (kind, lvl) => (lvl >= UPGRADES[kind].max ? Infinity : Math.round(UPGRADES[kind].base * Math.pow(UPGRADES[kind].mult, lvl)));
|
| 78 |
+
export function rig(lv = {}) {
|
| 79 |
+
const l = (k) => Math.max(0, Math.min(UPGRADES[k].max, lv[k] | 0));
|
| 80 |
+
return { power: 5 * Math.pow(1.22, l('drill')), fuel: 20 + 3 * l('tank'), magnet: l('magnet'), value: 1 + 0.25 * l('value') };
|
| 81 |
+
}
|
| 82 |
+
/** Coins the helper drone digs while you're away: up to 8 hours, more the deeper your best dig. Nothing under 10 minutes. */
|
| 83 |
+
export function idleCoins(ms, bestDepth = 0) {
|
| 84 |
+
if (!(ms > 10 * 60e3)) return 0;
|
| 85 |
+
const h = Math.min(8, ms / 3.6e6);
|
| 86 |
+
return Math.floor(h * (6 + bestDepth * 0.4));
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// ------------------------------------------------------------------ one run
|
| 90 |
+
/**
|
| 91 |
+
* makeRun(seed, levels) -> run. The page calls run.tick({ hold, col }) 60 times a second:
|
| 92 |
+
* hold = finger/mouse/key down, col = the column under the finger (0..COLS-1, float) or null.
|
| 93 |
+
*/
|
| 94 |
+
export function makeRun(seed, levels = {}) {
|
| 95 |
+
const R = rig(levels);
|
| 96 |
+
const rows = new Map(); // row -> { t: types[], hp: number[] }
|
| 97 |
+
const run = {
|
| 98 |
+
seed, rig: R, t: 0, x: Math.floor(COLS / 2), y: 0, tx: null, vy: 0, fuel: R.fuel, maxFuel: R.fuel,
|
| 99 |
+
coins: 0, depth: 0, ores: { 4: 0, 5: 0, 6: 0, 7: 0 }, fuelCans: 0, layers: [0], state: 'run', events: [], streak: 0, lastOre: -999,
|
| 100 |
+
holding: false, digging: null, stall: 0,
|
| 101 |
+
};
|
| 102 |
+
run.row = (r) => {
|
| 103 |
+
let o = rows.get(r);
|
| 104 |
+
if (!o) { const t = genRow(seed, r); o = { t, hp: t.map((k) => hpOf(k, r)) }; rows.set(r, o); }
|
| 105 |
+
return o;
|
| 106 |
+
};
|
| 107 |
+
run.tile = (c, r) => (c < 0 || c >= COLS ? -1 : r < 0 ? T.AIR : run.row(r).t[c]);
|
| 108 |
+
run.crack = (c, r) => { if (c < 0 || c >= COLS || r < 0) return 0; const o = run.row(r); const full = hpOf(o.t[c], r); return full ? 1 - o.hp[c] / full : 0; };
|
| 109 |
+
run.cell = () => Math.floor(run.y + 1e-6);
|
| 110 |
+
run.meters = () => run.depth;
|
| 111 |
+
|
| 112 |
+
function collect(c, r, type, how) {
|
| 113 |
+
const o = run.row(r);
|
| 114 |
+
o.t[c] = T.AIR; o.hp[c] = 0;
|
| 115 |
+
if (ORE[type]) {
|
| 116 |
+
const v = Math.max(1, Math.round(ORE[type] * R.value));
|
| 117 |
+
run.coins += v; run.ores[type]++;
|
| 118 |
+
run.streak = run.t - run.lastOre < 90 ? run.streak + 1 : 1; run.lastOre = run.t;
|
| 119 |
+
run.events.push({ type: 'ore', c, r, ore: type, v, how, streak: run.streak });
|
| 120 |
+
} else if (type === T.FUEL) {
|
| 121 |
+
run.fuel = Math.min(run.maxFuel, run.fuel + 3); run.fuelCans++;
|
| 122 |
+
run.events.push({ type: 'fuel', c, r });
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
function damage(c, r, dt) {
|
| 126 |
+
const o = run.row(r), type = o.t[c];
|
| 127 |
+
if (type === T.AIR || type < 0) return true;
|
| 128 |
+
o.hp[c] -= R.power * dt;
|
| 129 |
+
run.digging = { c, r, type };
|
| 130 |
+
if (o.hp[c] <= 0) {
|
| 131 |
+
run.events.push({ type: 'break', c, r, tile: type, biome: biomeOf(r) });
|
| 132 |
+
collect(c, r, type, 'dig');
|
| 133 |
+
return true;
|
| 134 |
+
}
|
| 135 |
+
return false;
|
| 136 |
+
}
|
| 137 |
+
function enterRow(r) {
|
| 138 |
+
if (r > run.depth) {
|
| 139 |
+
const b0 = biomeOf(run.depth), b1 = biomeOf(r);
|
| 140 |
+
run.depth = r;
|
| 141 |
+
if (b1 !== b0) { run.layers.push(b1); run.events.push({ type: 'biome', biome: b1, row: r }); }
|
| 142 |
+
}
|
| 143 |
+
for (let d = 1; d <= R.magnet; d++) for (const c of [run.x - d, run.x + d]) {
|
| 144 |
+
const k = run.tile(c, r);
|
| 145 |
+
if (ORE[k]) collect(c, r, k, 'magnet');
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
run.tick = (inp = {}) => {
|
| 150 |
+
if (run.state !== 'run') return;
|
| 151 |
+
const dt = 1 / HZ;
|
| 152 |
+
run.t++;
|
| 153 |
+
run.digging = null;
|
| 154 |
+
run.holding = !!inp.hold && run.fuel > 0;
|
| 155 |
+
const r0 = run.cell();
|
| 156 |
+
const below = run.tile(run.x, r0 + 1);
|
| 157 |
+
const aligned = Math.abs(run.y - r0) < 1e-6 && run.tx === null;
|
| 158 |
+
// 1) falling through air
|
| 159 |
+
if (below === T.AIR || !aligned && run.tx === null) {
|
| 160 |
+
run.vy = Math.min(14, run.vy + 40 * dt);
|
| 161 |
+
let ny = run.y + run.vy * dt;
|
| 162 |
+
const nr = Math.floor(ny + 1e-6);
|
| 163 |
+
for (let r = r0 + 1; r <= nr; r++) enterRow(r);
|
| 164 |
+
if (run.tile(run.x, nr + 1) !== T.AIR) {
|
| 165 |
+
if (ny > nr) { ny = nr; if (run.vy > 6) run.events.push({ type: 'thud', v: run.vy }); run.vy = 0; }
|
| 166 |
+
}
|
| 167 |
+
run.y = ny;
|
| 168 |
+
} else if (run.tx !== null) { // 2) sliding sideways into an open cell
|
| 169 |
+
const d = run.tx - run.x;
|
| 170 |
+
run.sx = (run.sx || 0) + Math.sign(d) * 7 * dt;
|
| 171 |
+
if (Math.abs(run.sx) >= 1) { run.x = run.tx; run.tx = null; run.sx = 0; enterRow(r0); }
|
| 172 |
+
} else if (run.holding) { // 3) drilling
|
| 173 |
+
const want = inp.col == null ? run.x : Math.max(0, Math.min(COLS - 1, Math.round(inp.col)));
|
| 174 |
+
const dir = Math.sign(want - run.x);
|
| 175 |
+
if (dir !== 0) {
|
| 176 |
+
if (damage(run.x + dir, r0, dt)) { run.tx = run.x + dir; run.sx = 0; }
|
| 177 |
+
} else if (damage(run.x, r0 + 1, dt)) {
|
| 178 |
+
run.vy = 2;
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
// fuel: drilling burns 1/s, waiting 0.25/s
|
| 182 |
+
run.fuel = Math.max(0, run.fuel - (run.holding ? 1 : 0.25) * dt);
|
| 183 |
+
if (run.fuel <= 0 && run.tx === null && run.tile(run.x, run.cell() + 1) !== T.AIR && Math.abs(run.y - run.cell()) < 1e-6) {
|
| 184 |
+
run.state = 'done'; run.events.push({ type: 'done' });
|
| 185 |
+
}
|
| 186 |
+
};
|
| 187 |
+
return run;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/** Spoiler-free share text: depth, the layers you passed (one emoji each) and the ore haul. */
|
| 191 |
+
export function shareText(run, label) {
|
| 192 |
+
const lines = [`Dig Drone ${label} · ⛏️ ${run.depth} m`, run.layers.map((b) => LAYER_EMOJI[b]).join('')];
|
| 193 |
+
const haul = [];
|
| 194 |
+
if (run.ores[7]) haul.push(`💎×${run.ores[7]}`);
|
| 195 |
+
if (run.ores[6]) haul.push(`🥇×${run.ores[6]}`);
|
| 196 |
+
haul.push(`🪙 ${run.coins}`);
|
| 197 |
+
lines.push(haul.join(' '));
|
| 198 |
+
return lines.join('\n');
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/** Test/bot helper: the column to steer to (an ore in the next rows if close, else the softest way down). */
|
| 202 |
+
export function botCol(run) {
|
| 203 |
+
const r = run.cell();
|
| 204 |
+
let best = run.x, score = -Infinity;
|
| 205 |
+
for (let c = 0; c < COLS; c++) {
|
| 206 |
+
let s = -Math.abs(c - run.x) * 1.2;
|
| 207 |
+
for (let d = 1; d <= 4; d++) {
|
| 208 |
+
const k = run.tile(c, r + d);
|
| 209 |
+
s += (ORE[k] || 0) / d + (k === T.FUEL ? 3 / d : 0) - (k === T.BOULDER ? 4 / d : k === T.ROCK ? 0.8 / d : 0) + (k === T.AIR ? 0.6 / d : 0);
|
| 210 |
+
}
|
| 211 |
+
if (s > score) { score = s; best = c; }
|
| 212 |
+
}
|
| 213 |
+
return best;
|
| 214 |
+
}
|
fun.css
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* CyberMax Fun kit: shared look for CyberMax games (copied into each game). Mobile first. 2026 look: soft dusk by default (7 Nov 2026: lifted from near-black after "too dark"),
|
| 2 |
+
dark arcade (glass panels, a glow in each game's own colours behind the stage), light on request. (c) 2026 CyberMax. */
|
| 3 |
+
:root{--bg:#161B2E;--bg2:#1E2440;--card:rgba(40,47,74,.72);--card-solid:#252B45;--ink:#F4F2FA;--muted:#B7BCD0;--line:rgba(255,255,255,.14);--chip:rgba(255,255,255,.08);--acc:#FF6A3D;--acc-ink:#11141B;--ok:#2FD3A0;--bad:#FF7A5C;--game:#5CF2FF;--game2:#FF4D9A;--shadow:0 1px 0 rgba(255,255,255,.04) inset,0 18px 50px rgba(0,0,0,.45);color-scheme:dark}
|
| 4 |
+
:root[data-theme=light]{--bg:#F6F3EC;--bg2:#EFEADF;--card:#fff;--card-solid:#fff;--ink:#11141B;--muted:#565C6B;--line:#E2DCD0;--chip:#ECE6DA;--ok:#0B7F5E;--bad:#C2361B;--shadow:0 1px 2px rgba(17,20,27,.06),0 10px 30px rgba(17,20,27,.08);color-scheme:light}
|
| 5 |
+
*{box-sizing:border-box}[hidden]{display:none!important}html{-webkit-text-size-adjust:100%}
|
| 6 |
+
body{margin:0;background:radial-gradient(1100px 620px at 50% -12%,color-mix(in srgb,var(--game) 26%,transparent),transparent 70%),radial-gradient(800px 520px at 105% 38%,color-mix(in srgb,var(--game2) 16%,transparent),transparent 70%),radial-gradient(700px 500px at -8% 70%,color-mix(in srgb,var(--game) 9%,transparent),transparent 70%),linear-gradient(180deg,var(--bg),var(--bg2));background-attachment:fixed;color:var(--ink);font:16px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;overflow-x:hidden;min-height:100vh}
|
| 7 |
+
:root[data-theme=light] body{background:var(--bg)}
|
| 8 |
+
a{color:inherit}img,canvas{max-width:100%}
|
| 9 |
+
.wrap{max-width:760px;margin:0 auto;padding:0 16px}
|
| 10 |
+
.top{display:flex;align-items:center;gap:6px;padding:12px 0}
|
| 11 |
+
.top .brand{display:flex;align-items:center;gap:8px;font-weight:800;text-decoration:none;font-size:18px;margin-right:auto}.top .brand svg{width:28px;height:28px}
|
| 12 |
+
.top nav a,.top .icon{color:var(--muted);text-decoration:none;padding:8px 10px;border-radius:10px;font-size:15px;background:none;border:0;font-family:inherit;cursor:pointer;min-height:40px}
|
| 13 |
+
.top nav a:hover,.top .icon:hover{color:var(--ink);background:var(--chip)}
|
| 14 |
+
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:10px 18px;border-radius:12px;border:0;background:var(--acc);color:var(--acc-ink);font:inherit;font-weight:800;font-size:16px;cursor:pointer;text-decoration:none;touch-action:manipulation}
|
| 15 |
+
.btn:hover{filter:brightness(1.08)}.btn:not(.ghost){box-shadow:0 6px 22px color-mix(in srgb,var(--acc) 35%,transparent)}.btn.ghost{background:transparent;color:var(--ink);border:1.5px solid var(--line)}.btn.sm{min-height:40px;padding:6px 14px;font-size:15px}
|
| 16 |
+
.btn.pass{background:linear-gradient(135deg,#FFB547,#FF6A3D);color:#11141B}
|
| 17 |
+
.row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
|
| 18 |
+
.chips{display:flex;gap:6px;flex-wrap:wrap}
|
| 19 |
+
.chip{border:1.5px solid var(--line);background:var(--chip);color:var(--ink);border-radius:999px;padding:6px 12px;font:inherit;font-size:14px;font-weight:700;cursor:pointer;min-height:36px}
|
| 20 |
+
.chip[aria-pressed=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}.chip .lock{opacity:.7;font-size:12px}
|
| 21 |
+
.panel{background:var(--card);border:1px solid var(--line);border-radius:20px;padding:16px;box-shadow:var(--shadow)}
|
| 22 |
+
.muted{color:var(--muted)}.small{font-size:14px}
|
| 23 |
+
h1{font-size:clamp(28px,6.4vw,46px);font-weight:900;line-height:1.05;letter-spacing:-.025em;margin:0 0 6px;text-wrap:balance}
|
| 24 |
+
h2{font-size:21px;letter-spacing:-.01em;margin:30px 0 8px}
|
| 25 |
+
.seo h3{font-size:17px;margin:18px 0 4px}.seo p,.seo li{color:var(--muted)}
|
| 26 |
+
.more{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:10px;margin:12px 0}
|
| 27 |
+
.more a{display:block;padding:12px 14px;border:1px solid var(--line);border-radius:14px;background:var(--card);text-decoration:none;transition:transform .15s,border-color .15s}.more a:hover{transform:translateY(-2px);border-color:color-mix(in srgb,var(--game) 50%,var(--line))}.more a b{display:block}.more a span{color:var(--muted);font-size:14px}
|
| 28 |
+
footer{color:var(--muted);font-size:14px;padding:26px 0 40px;border-top:1px solid var(--line);margin-top:36px}
|
| 29 |
+
#toast{position:fixed;left:50%;bottom:22px;transform:translate(-50%,40px);opacity:0;background:var(--ink);color:var(--bg);padding:12px 16px;border-radius:12px;font-weight:700;transition:.25s;z-index:99;max-width:calc(100% - 32px);text-align:center;pointer-events:none}
|
| 30 |
+
#toast.on{transform:translate(-50%,0);opacity:1}
|
| 31 |
+
.nudge{display:flex;gap:10px;align-items:center;justify-content:space-between;flex-wrap:wrap;border:1.5px dashed var(--line);border-radius:14px;padding:10px 12px;margin-top:12px;font-size:15px}
|
| 32 |
+
html.cmx-pro .nudge{display:none}
|
| 33 |
+
.pro-badge{display:none;font-size:12px;font-weight:800;background:linear-gradient(135deg,#FFB547,#FF6A3D);color:#11141B;border-radius:999px;padding:2px 8px;vertical-align:middle}
|
| 34 |
+
html.cmx-pro .pro-badge{display:inline-block}
|
| 35 |
+
dialog.funpass{border:0;padding:0;border-radius:20px;max-width:min(520px,calc(100% - 24px));width:100%;background:var(--card-solid);color:var(--ink);box-shadow:0 20px 60px rgba(0,0,0,.35)}
|
| 36 |
+
dialog.funpass::backdrop{background:rgba(10,12,18,.55)}
|
| 37 |
+
.fp{padding:22px 20px 18px;position:relative}.fp h2{margin:2px 0 10px;font-size:24px}
|
| 38 |
+
.fp-x{position:absolute;right:10px;top:8px;border:0;background:none;color:var(--muted);font-size:28px;cursor:pointer;width:44px;height:44px}
|
| 39 |
+
.fp-kick{margin:0;color:var(--acc);font-weight:800;font-size:13px;letter-spacing:.06em;text-transform:uppercase}
|
| 40 |
+
.fp-perks{margin:0 0 14px;padding-left:20px}.fp-perks li{margin:2px 0}
|
| 41 |
+
.fp-plans{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
|
| 42 |
+
.fp-plan{position:relative;display:flex;flex-direction:column;gap:2px;padding:14px 10px 12px;border:1.5px solid var(--line);border-radius:14px;text-decoration:none;text-align:center;background:var(--bg2)}
|
| 43 |
+
.fp-plan:hover{border-color:var(--acc)}.fp-plan.best{border-color:var(--acc);box-shadow:0 0 0 2px var(--acc) inset}
|
| 44 |
+
.fp-plan i{position:absolute;top:-10px;left:50%;transform:translateX(-50%);background:var(--acc);color:#11141B;font-style:normal;font-size:11px;font-weight:800;padding:2px 8px;border-radius:999px;white-space:nowrap}
|
| 45 |
+
.fp-plan b{font-size:14px}.fp-price{font-size:22px;font-weight:900}.fp-price small{font-size:12px;font-weight:600;color:var(--muted)}.fp-note{font-size:12px;color:var(--muted)}
|
| 46 |
+
.fp-small{font-size:13px;color:var(--muted);margin:10px 0 4px}
|
| 47 |
+
.fp-code{display:block;user-select:all;word-break:break-all;background:var(--chip);padding:8px;border-radius:8px;font-size:12px}
|
| 48 |
+
.fp details{margin-top:6px;font-size:14px}.fp-form{display:flex;gap:6px;margin-top:8px}.fp-form input{flex:1;min-width:0;font:inherit;font-size:14px;padding:8px 10px;border-radius:10px;border:1.5px solid var(--line);background:var(--bg);color:var(--ink)}
|
| 49 |
+
@media (max-width:420px){.fp-plans{grid-template-columns:1fr}.fp-plan{flex-direction:row;align-items:center;justify-content:space-between;text-align:left;padding:12px}.fp-plan i{left:auto;right:10px;transform:none}}
|
| 50 |
+
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
|
| 51 |
+
@media (max-width:560px){.chips{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;margin:0 -16px;padding:2px 16px 4px}.chips::-webkit-scrollbar{display:none}.chip{flex:0 0 auto}}
|
| 52 |
+
@media (min-width:760px){dialog.funpass{max-width:720px}.fp-perks{columns:2;column-gap:28px}}
|
| 53 |
+
.fp-after{margin:14px 0 0;padding:12px 14px;border:1px solid var(--line, rgba(127,127,127,.35));border-radius:14px;text-align:left}.fp-after p{margin:0 0 8px}.fp-after .fp-row{display:flex;gap:8px;flex-wrap:wrap}.fp-after .fp-pv{font-size:13px;opacity:.85}
|
| 54 |
+
.fp-game{border-color:var(--acc);display:grid;grid-template-columns:1fr auto;align-items:center;text-align:left;gap:2px 12px;padding:14px 14px 12px;margin:0 0 6px}.fp-game b{font-size:16px}.fp-game .fp-price{grid-row:span 2}.fp-game .fp-note{grid-column:1}
|
| 55 |
+
.fp-or{margin:12px 0 8px;font-size:14px}
|
| 56 |
+
|
| 57 |
+
.top{position:relative;z-index:2}.top .brand{letter-spacing:-.01em}
|
| 58 |
+
/* 3D games on wide screens: a bigger stage, centred header (2026 upgrade) */
|
| 59 |
+
@media (min-width:1100px){.wrap:has(.cmx3d-wrap){max-width:1080px}.wrap:has(.cmx3d-wrap) .seo,.wrap:has(.cmx3d-wrap) footer{max-width:760px;margin-left:auto;margin-right:auto}
|
| 60 |
+
.wrap:has(.cmx3d-wrap) section.game>.headline{text-align:center}.wrap:has(.cmx3d-wrap) section.game>.headline .tag{margin-left:auto;margin-right:auto;max-width:640px}
|
| 61 |
+
.wrap:has(.cmx3d-wrap) section.game>.chips{justify-content:center}.wrap:has(.cmx3d-wrap) section.game>.lv-goal,.wrap:has(.cmx3d-wrap) section.game>#goal{text-align:center;justify-content:center}
|
| 62 |
+
.wrap:has(.cmx3d-wrap) section.game>.panel{max-width:760px;margin-left:auto;margin-right:auto}}
|
| 63 |
+
/* living background: two slow glows in the game's colours drift behind the page (dark theme; off for reduced motion) */
|
| 64 |
+
body::before,body::after{content:"";position:fixed;z-index:-1;width:60vmax;height:60vmax;border-radius:50%;opacity:.16;pointer-events:none;animation:cmx-drift 26s ease-in-out infinite alternate}
|
| 65 |
+
body::before{left:-20vmax;top:-25vmax;background:radial-gradient(closest-side,var(--game),transparent)}body::after{right:-25vmax;bottom:-30vmax;background:radial-gradient(closest-side,var(--game2),transparent);animation-duration:34s;animation-direction:alternate-reverse}
|
| 66 |
+
:root[data-theme=light] body::before,:root[data-theme=light] body::after{display:none}
|
| 67 |
+
@keyframes cmx-drift{from{transform:translate(0,0) scale(1)}to{transform:translate(12vmax,8vmax) scale(1.15)}}
|
| 68 |
+
.panel{transition:border-color .2s,box-shadow .2s}.panel:hover{border-color:color-mix(in srgb,var(--game) 28%,var(--line))}
|
| 69 |
+
.fp-rbx{font-size:13px;color:var(--muted);margin:10px 0 0;text-align:center}.fp-rbx a{color:inherit;font-weight:700}
|
| 70 |
+
/* Shop (29 Oct 2026): one Shop button on the title/menu screen, one quiet one on results, one sheet with every item */
|
| 71 |
+
.cmx-shopbtn{background:linear-gradient(135deg,#FFD15C,#FF8A3D)!important;color:#11141B!important;font-weight:900;letter-spacing:.01em;gap:8px;border:0}
|
| 72 |
+
.cmx-shopbtn small{font-size:.78em;font-weight:700;opacity:.8;white-space:nowrap}.cmx-shopres small{font-size:.85em;opacity:.8}
|
| 73 |
+
html.cmx-noshop [data-cmx-shop]:not([data-cmx-keep]){display:none!important}
|
| 74 |
+
.cmxshop .sh-list{list-style:none;margin:10px 0 6px;padding:0;display:grid;gap:8px}
|
| 75 |
+
.cmxshop .sh-i{display:grid;grid-template-columns:56px 1fr auto;gap:12px;align-items:center;padding:10px;border:1.5px solid var(--line);border-radius:14px;background:var(--bg2)}
|
| 76 |
+
.cmxshop .sh-own{font-weight:800;color:var(--ok);font-size:14px;white-space:nowrap}
|
| 77 |
+
.cmxshop .sh-pv{position:relative;width:56px;height:56px;border-radius:12px;overflow:hidden;display:grid;place-items:center;font-size:26px}
|
| 78 |
+
.cmxshop .sh-pv i{font-style:normal}.cmxshop .sh-pv img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
|
| 79 |
+
.cmxshop .sh-t{min-width:0;display:flex;flex-direction:column;gap:2px}.cmxshop .sh-t b{font-size:16px}
|
| 80 |
+
.cmxshop .sh-w{font-size:13px;color:var(--muted);line-height:1.35}.cmxshop .sh-w em{font-style:normal;font-weight:700;color:var(--ink)}
|
| 81 |
+
.cmxshop .sh-alt{font-size:13px;color:var(--muted)}.cmxshop .sh-alt a{color:var(--ink);font-weight:700}
|
| 82 |
+
.cmxshop .sh-buy{min-width:84px;white-space:nowrap}.cmxshop .sh-buy small{font-size:11px;font-weight:600}
|
| 83 |
+
.cmxshop .sh-code{border:0;background:none;color:var(--ink);font:inherit;font-weight:700;text-decoration:underline;cursor:pointer;padding:0}
|
| 84 |
+
@media (max-width:460px){.cmxshop .sh-i{grid-template-columns:44px 1fr;gap:8px 10px}.cmxshop .sh-pv{width:44px;height:44px;font-size:20px}.cmxshop .sh-buy,.cmxshop .sh-own{grid-column:2;justify-self:start}}
|
| 85 |
+
dialog.cmxshop{max-height:calc(100dvh - 16px);overflow:auto}
|
| 86 |
+
.cmx-shop-top{min-height:38px;padding:5px 12px;font-size:14px;border-radius:999px;margin:0 4px;white-space:nowrap;flex:0 0 auto;gap:6px}
|
| 87 |
+
@media (max-width:430px){header.top:has(.cmx-shop-top:not([hidden])) nav{display:none}header.top:has(.cmx-shop-top:not([hidden])) .brand{font-size:0;gap:0}.cmx-shop-top{padding:5px 10px;font-size:13px;margin:0 2px}.cmx-shop-top small{font-size:11px}}
|
| 88 |
+
/* Calm play focus (7 Nov 2026 quality pass, "Calm screens in every game"): on a phone, once the player touches the board,
|
| 89 |
+
the shop, skin and pass buttons, the theme swatches, the stats/theme icons and the "Get more" row step aside until the
|
| 90 |
+
round ends (cmx.js adds html.cmx-focus; a results panel or a tap outside the game brings them back). Above the board
|
| 91 |
+
only visibility changes, so nothing moves under the player's finger. */
|
| 92 |
+
@media (max-width:560px){
|
| 93 |
+
html.cmx-focus header.top .cmx-shop-top,html.cmx-focus header.top #stats-btn,html.cmx-focus header.top #theme,html.cmx-focus header.top nav{visibility:hidden}
|
| 94 |
+
html.cmx-focus section.game .row.skins,html.cmx-focus section.game #skins-btn,html.cmx-focus section.game #pass-btn,html.cmx-focus section.game #install,
|
| 95 |
+
html.cmx-focus section.game .row [data-cmx-shop],html.cmx-focus section.game>.nudge,html.cmx-focus .cmx-gm{display:none!important}}
|
funpass.js
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// CyberMax games checkout: the per-game "full game" unlock + the Fun Pass (every game), copied into each game's web/ folder.
|
| 2 |
+
// Model (games lane GM, 9 Oct 2026; evidence docs/ceo/games-monetization-2026-10-09.md):
|
| 3 |
+
// - Free demo: every game's daily challenge stays free for everyone, plus the first levels (OFFER.demo once the per-game
|
| 4 |
+
// unlock is live; levels 1-20 until then). A level the player has opened is never locked again.
|
| 5 |
+
// - Full game: ONE payment per game (OFFER.price, Stripe pack revenue/packs/stripe/<game>-full) unlocks every level,
|
| 6 |
+
// mode, the daily archive and themes in that game, for good. Shown only when OFFER.live is true (owner-approved).
|
| 7 |
+
// - Fun Pass = the all-games bundle: Monthly $2.99 · Yearly $19 · Lifetime $29.99 (pack revenue/packs/stripe/fun-pass).
|
| 8 |
+
// - Portal builds (scripts/games/portals.py) never show a checkout; where the portal SDK offers rewarded ads, the player
|
| 9 |
+
// may watch one to open the full game for an hour (shared/portal-adapter/cmx-portal.js CMXPortal.rewarded()).
|
| 10 |
+
// Buy: counted redirect https://data.cybermaxtools.com/buy/st-<pack>-<plan>?s=game-<id> -> Stripe checkout.
|
| 11 |
+
// After checkout the data Worker (/unlock/fun-pass or /unlock/<game>-full) checks the Checkout Session and returns with
|
| 12 |
+
// #cmx-pro=<code> (the full-game return adds ?unlock=full). The code on the receipt page unlocks any other device.
|
| 13 |
+
// No account, no cookies, nothing personal stored. (c) 2026 CyberMax. All rights reserved.
|
| 14 |
+
import { count, store, toast } from './cmx.js';
|
| 15 |
+
import { OFFER } from './offer.js'; // written by scripts/games/sync_kit.py from products/fun-pass/games.json
|
| 16 |
+
export { OFFER };
|
| 17 |
+
|
| 18 |
+
const DATA = 'https://data.cybermaxtools.com';
|
| 19 |
+
const KEY = 'cmx-pro:fun-pass';
|
| 20 |
+
const SID = /^(cmxk1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|cs_(live|test)_[A-Za-z0-9]{10,200}|[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})$/i; // Stripe order code or Gumroad licence key
|
| 21 |
+
const RECHECK = 3 * 864e5; // subscriptions are re-checked every 3 days; a cancelled pass turns off by itself
|
| 22 |
+
export const PLANS = [
|
| 23 |
+
{ id: 'monthly', label: 'Monthly', price: '$2.99', per: '/month', note: 'Cancel any time' },
|
| 24 |
+
{ id: 'yearly', label: 'Yearly', price: '$19', per: '/year', note: 'Save 47%', best: true },
|
| 25 |
+
{ id: 'unlock', label: 'Lifetime', price: '$29.99', per: ' once', note: 'Pay once, keep forever' },
|
| 26 |
+
];
|
| 27 |
+
export const COMMON_PERKS = ['Every paid level, chapter and mode in every CyberMax game', 'The full archive of past dailies', 'New games and new chapters included as they launch', 'Custom colour themes'];
|
| 28 |
+
const FULL_KEY = `cmx-full:${OFFER.game}`;
|
| 29 |
+
const REWARD_KEY = `cmx-reward:${OFFER.game}`;
|
| 30 |
+
const REWARD_MS = 60 * 60 * 1000; // one rewarded ad on a portal build opens the full game for an hour
|
| 31 |
+
|
| 32 |
+
let state = store(KEY);
|
| 33 |
+
let full = store(FULL_KEY);
|
| 34 |
+
const listeners = [];
|
| 35 |
+
let cfg = { game: 'games', name: 'CyberMax games', perks: [] };
|
| 36 |
+
// Per-game offer naming (17 Oct 2026 conversion fix): games whose one-time unlock is not a "full game" (no levels, every
|
| 37 |
+
// mode free) pass init({ title: 'Stoop Dice Crew Pass', exact: true, free: '...' }): the sheet then names the offer exactly
|
| 38 |
+
// as the Stripe product, lists only its own perks and states what stays free, instead of "every level / bonus mode".
|
| 39 |
+
const fullTitle = () => cfg.title || `Full ${OFFER.name}`;
|
| 40 |
+
|
| 41 |
+
const passOn = () => !!(state && state.code);
|
| 42 |
+
export const ownsGame = () => !!(full && full.code);
|
| 43 |
+
const rewardOn = () => { const r = store(REWARD_KEY); return !!(r && Date.now() - r.at < REWARD_MS); };
|
| 44 |
+
/** True when this player may use everything in this game: Fun Pass, this game's full unlock, or a portal reward hour. */
|
| 45 |
+
export const isPro = () => passOn() || ownsGame() || rewardOn();
|
| 46 |
+
/** Free levels in this game's demo: OFFER.demo once the per-game unlock is live, else the game's current number. */
|
| 47 |
+
export const freeLevels = (current = 20) => (OFFER.live && OFFER.demo ? Math.min(current, OFFER.demo) : current);
|
| 48 |
+
const portal = () => (typeof window !== 'undefined' && window.CMXPortal && window.CMXPortal.portal) || '';
|
| 49 |
+
export function onChange(fn) { listeners.push(fn); fn(isPro()); }
|
| 50 |
+
// The header pass button names the real price (convert lane, 15 Oct 2026): "Full game $2.99" where this game sells its
|
| 51 |
+
// own unlock, else the Fun Pass monthly price. Pass holders see the button's own label.
|
| 52 |
+
function priceButton() {
|
| 53 |
+
const btn = typeof document !== 'undefined' && document.getElementById('pass-btn');
|
| 54 |
+
if (!btn) return;
|
| 55 |
+
if (!btn.dataset.label) btn.dataset.label = btn.textContent;
|
| 56 |
+
btn.textContent = isPro() || portal() ? btn.dataset.label : sellsGame() ? `✨ ${cfg.title ? cfg.short || cfg.title : 'Full game'} ${OFFER.price}` : `✨ Fun Pass ${PLANS[0].price}/mo`;
|
| 57 |
+
}
|
| 58 |
+
function emit() {
|
| 59 |
+
document.documentElement.classList.toggle('cmx-pro', isPro());
|
| 60 |
+
priceButton();
|
| 61 |
+
paintShop();
|
| 62 |
+
listeners.forEach((fn) => { try { fn(isPro()); } catch { /* game hook */ } });
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
// Offline Pro keys (17 Oct 2026): "cmxk1.<payload>.<Ed25519 signature>" from data.cybermaxtools.com/unlock is verified here
|
| 66 |
+
// with WebCrypto and this public key, so an unlock needs no Worker call. Expired, foreign-signed or unverifiable keys fall
|
| 67 |
+
// back to the online check of the order code inside them, as before.
|
| 68 |
+
const CMX_PUB = 'u0FDxbu0d9B9Sz5-yLT6AuL5IagyTlFcbBgEDqZxWtk';
|
| 69 |
+
const b64d = (s) => { s = s.replace(/-/g, '+').replace(/_/g, '/'); while (s.length % 4) s += '='; return Uint8Array.from(atob(s), (c) => c.charCodeAt(0)); };
|
| 70 |
+
async function cmxKeyOk(k, app, online) {
|
| 71 |
+
const [tag, body, sig] = k.split('.');
|
| 72 |
+
let p;
|
| 73 |
+
try { p = JSON.parse(new TextDecoder().decode(b64d(body))); } catch { return false; }
|
| 74 |
+
if (!p || p.a !== app) return false;
|
| 75 |
+
try {
|
| 76 |
+
const key = await crypto.subtle.importKey('raw', b64d(CMX_PUB), { name: 'Ed25519' }, false, ['verify']);
|
| 77 |
+
if (await crypto.subtle.verify({ name: 'Ed25519' }, key, b64d(sig), new TextEncoder().encode(tag + '.' + body)) && (!p.x || p.x * 1000 > Date.now())) return true;
|
| 78 |
+
} catch { /* no Ed25519 here: online check below */ }
|
| 79 |
+
return p.c ? online(p.c) : false;
|
| 80 |
+
}
|
| 81 |
+
async function check(code, what = 'fun-pass') {
|
| 82 |
+
if (/^cmxk1\./.test(code)) return cmxKeyOk(code, what, (c) => checkOnline(c, what));
|
| 83 |
+
return checkOnline(code, what);
|
| 84 |
+
}
|
| 85 |
+
async function checkOnline(code, what = 'fun-pass') {
|
| 86 |
+
try {
|
| 87 |
+
const r = await fetch(`${DATA}/unlock/${what}?json=1&session_id=${encodeURIComponent(code)}`);
|
| 88 |
+
const j = await r.json();
|
| 89 |
+
return j && typeof j.pro === 'boolean' ? j.pro : null;
|
| 90 |
+
} catch { return null; }
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/** Turn on a full-game code for this game (receipt code of the <game>-full Payment Link). */
|
| 94 |
+
export async function unlockGame(code) {
|
| 95 |
+
const ok = await check(code, `${OFFER.game}-full`);
|
| 96 |
+
if (ok) {
|
| 97 |
+
full = store(FULL_KEY, { code, at: new Date().toISOString() });
|
| 98 |
+
count(cfg.game, 'pro', 'full-unlocked');
|
| 99 |
+
toast(cfg.title ? `${cfg.title} is on. Thank you for supporting CyberMax games!` : `${OFFER.name}: the full game is on. Thank you for supporting CyberMax games!`, 3500);
|
| 100 |
+
emit(); render();
|
| 101 |
+
} else if (ok === false) toast('That code is not a full-game order for this game.', 3500);
|
| 102 |
+
else toast('Could not reach the unlock check. Try again in a minute.', 3500);
|
| 103 |
+
return ok;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/** Turn on a pasted or returned code: a Fun Pass code, or (where this game sells its own unlock) a full-game code. */
|
| 107 |
+
export async function unlock(code) {
|
| 108 |
+
const ok = await check(code);
|
| 109 |
+
if (ok) {
|
| 110 |
+
state = store(KEY, { code, at: new Date().toISOString(), checked: Date.now() });
|
| 111 |
+
count(cfg.game, 'pro', 'unlocked');
|
| 112 |
+
toast('Fun Pass is on. Thank you for supporting CyberMax games!', 3500);
|
| 113 |
+
emit();
|
| 114 |
+
render();
|
| 115 |
+
return ok;
|
| 116 |
+
}
|
| 117 |
+
if (sellsGame() && (await check(code, `${OFFER.game}-full`))) return unlockGame(code);
|
| 118 |
+
if (ok === false) toast('That code is not an active Fun Pass.', 3500);
|
| 119 |
+
else toast('Could not reach the pass check. Try again in a minute.', 3500);
|
| 120 |
+
return ok;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
async function recheck() {
|
| 124 |
+
if (!passOn() || Date.now() - (state.checked || 0) < RECHECK) return; // only a Fun Pass is re-checked (a full-game or Founder owner has no pass state)
|
| 125 |
+
const ok = await check(state.code);
|
| 126 |
+
if (ok === false) { state = null; try { localStorage.removeItem(KEY); } catch { /* */ } emit(); render(); toast('Your Fun Pass has ended. Everything free is still here.', 4000); }
|
| 127 |
+
else if (ok) state = store(KEY, { ...state, checked: Date.now() });
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
| 131 |
+
const buyUrl = (plan) => `${DATA}/buy/st-fun-pass-${plan}?s=game-${cfg.game}`;
|
| 132 |
+
const gameUrl = (from = '') => `${DATA}/buy/st-${OFFER.game}-full-unlock?s=game-${cfg.game}${from ? `-${from}` : ''}`;
|
| 133 |
+
const sellsGame = () => !!(OFFER.live && OFFER.price && OFFER.game !== 'games');
|
| 134 |
+
|
| 135 |
+
function dialog() {
|
| 136 |
+
let d = document.getElementById('funpass');
|
| 137 |
+
if (!d) {
|
| 138 |
+
d = document.createElement('dialog');
|
| 139 |
+
d.id = 'funpass';
|
| 140 |
+
d.className = 'funpass';
|
| 141 |
+
document.body.appendChild(d);
|
| 142 |
+
d.addEventListener('click', (e) => { if (e.target === d || e.target.closest('[data-close]')) d.close(); });
|
| 143 |
+
}
|
| 144 |
+
return d;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
const planHtml = () => PLANS.map((p) => `<a class="fp-plan${p.best ? ' best' : ''}" href="${buyUrl(p.id)}" rel="nofollow" data-plan="${p.id}">${p.best ? '<i>Best value</i>' : ''}<b>${p.label}</b><span class="fp-price">${p.price}<small>${p.per}</small></span><span class="fp-note">${p.note}</span></a>`).join('');
|
| 148 |
+
const codeForm = `<details><summary>Already bought?</summary><form class="fp-form"><input aria-label="Order code" autocomplete="off" placeholder="Receipt code (cs_live_…) or Gumroad licence key"><button class="btn sm" type="submit">Turn on</button></form></details>`;
|
| 149 |
+
|
| 150 |
+
function render() {
|
| 151 |
+
const d = dialog();
|
| 152 |
+
const perks = [...(cfg.perks || []), ...COMMON_PERKS.filter((p) => !(cfg.perks || []).some((q) => q.split(' ')[0] === p.split(' ')[0]))].slice(0, 6);
|
| 153 |
+
if (isPro()) {
|
| 154 |
+
const what = passOn() ? 'The Fun Pass is on in this browser for every CyberMax game' : ownsGame() ? (cfg.title ? `You own the ${esc(cfg.title)}` : `You own the full ${esc(OFFER.name)}`) : 'The full game is open for the next hour (rewarded ad)';
|
| 155 |
+
const code = passOn() ? state.code : ownsGame() ? full.code : '';
|
| 156 |
+
d.innerHTML = `<div class="fp"><button class="fp-x" data-close aria-label="Close">×</button><p class="fp-kick">${passOn() ? 'CyberMax Fun Pass' : esc(OFFER.name)}</p><h2>Everything is open. Thank you!</h2>
|
| 157 |
+
<p>${what}: ${perks.map(esc).join(' · ')}.</p>
|
| 158 |
+
${code ? `<p class="fp-small">Your code (paste it on another device to turn it on there):</p><code class="fp-code">${esc(code)}</code>` : ''}
|
| 159 |
+
${passOn() ? '<p class="fp-small">Manage or cancel a subscription any time from the link in your Stripe receipt email.</p>' : ''}</div>`;
|
| 160 |
+
return;
|
| 161 |
+
}
|
| 162 |
+
if (portal()) { // portal build: no outside checkout; a rewarded ad (when the portal offers one) opens the game for an hour
|
| 163 |
+
d.innerHTML = `<div class="fp"><button class="fp-x" data-close aria-label="Close">×</button><p class="fp-kick">${esc(OFFER.name || 'Full game')}</p>
|
| 164 |
+
<h2>Open the full game for an hour</h2><ul class="fp-perks">${perks.slice(0, 4).map((p) => `<li>${esc(p)}</li>`).join('')}</ul>
|
| 165 |
+
<p><button class="btn" type="button" data-reward>▶ Watch a short ad</button></p>
|
| 166 |
+
<p class="fp-small">Optional. The daily challenge and the free levels stay free without ads.</p></div>`;
|
| 167 |
+
d.querySelector('[data-reward]').addEventListener('click', async () => {
|
| 168 |
+
count(cfg.game, 'cta', 'reward-ad');
|
| 169 |
+
const ok = await window.CMXPortal.rewarded().catch(() => false);
|
| 170 |
+
if (ok) { store(REWARD_KEY, { at: Date.now() }); count(cfg.game, 'pro', 'reward-hour'); toast('Everything is open for the next hour. Have fun!', 3000); emit(); d.close(); }
|
| 171 |
+
else toast('No ad is available right now. Try again later.', 3000);
|
| 172 |
+
});
|
| 173 |
+
return;
|
| 174 |
+
}
|
| 175 |
+
const allGames = `${OFFER.games || 'every'} CyberMax games`;
|
| 176 |
+
const own = cfg.perks || [];
|
| 177 |
+
const gamePerks = cfg.exact ? own.slice(0, 6) : [...own, ...(own.some((p) => /archive/i.test(p)) ? [] : ['The full archive of past dailies']), 'Every bonus mode in this game'].slice(0, 6);
|
| 178 |
+
const freeLine = cfg.free || `The daily challenge and ${OFFER.levels === false ? 'the free modes stay' : `the first ${OFFER.demo || ''} levels stay`} free for everyone.`;
|
| 179 |
+
d.innerHTML = sellsGame()
|
| 180 |
+
? `<div class="fp"><button class="fp-x" data-close aria-label="Close">×</button><p class="fp-kick">${esc(OFFER.name)} · ${cfg.title ? 'one payment' : 'full game'}</p>
|
| 181 |
+
<h2>${cfg.title ? `Get the ${esc(cfg.title)}` : `Unlock the full ${esc(OFFER.name)}`}</h2>
|
| 182 |
+
<ul class="fp-perks">${gamePerks.map((p) => `<li>${esc(p)}</li>`).join('')}</ul>
|
| 183 |
+
<a class="fp-plan fp-game" href="${gameUrl()}" rel="nofollow" data-game><i>This game only</i><b>${esc(fullTitle())}</b><span class="fp-price">${esc(OFFER.price)}<small> once</small></span><span class="fp-note">Pay once, keep it forever. No subscription.</span></a>
|
| 184 |
+
<p class="fp-or"><b>Or get all ${esc(allGames)}</b> with the Fun Pass (a separate pass for every game):</p>
|
| 185 |
+
<div class="fp-plans">${planHtml()}</div>
|
| 186 |
+
<p class="fp-small">Secure checkout by Stripe (shown as Link) · turns on as soon as you pay · your code works on any device · 14-day fix-or-refund if it doesn't work as described (<a href="https://cybermaxtools.com/terms#payments" target="_blank" rel="noopener">terms</a>). ${esc(freeLine)} Prices in USD; tax for your country is added at checkout.</p>
|
| 187 |
+
${codeForm}</div>`
|
| 188 |
+
: `<div class="fp"><button class="fp-x" data-close aria-label="Close">×</button><p class="fp-kick">CyberMax Fun Pass</p>
|
| 189 |
+
<h2>One pass. Every game. More to play.</h2>
|
| 190 |
+
<ul class="fp-perks">${perks.map((p) => `<li>${esc(p)}</li>`).join('')}</ul>
|
| 191 |
+
<div class="fp-plans">${planHtml()}</div>
|
| 192 |
+
<p class="fp-small">Secure checkout by Stripe (shown as Link; card, Apple Pay, Google Pay) · turns on as soon as you pay · cancel any time from your receipt email · 14-day fix-or-refund if it doesn't work as described (<a href="https://cybermaxtools.com/terms#payments" target="_blank" rel="noopener">terms</a>). Prices in USD, + tax where applicable. Works in every CyberMax game. The daily challenges and the free levels stay free for everyone.</p>
|
| 193 |
+
${codeForm}</div>`;
|
| 194 |
+
d.querySelector('.fp-form').addEventListener('submit', (e) => {
|
| 195 |
+
e.preventDefault();
|
| 196 |
+
const c = e.target.querySelector('input').value.trim();
|
| 197 |
+
if (SID.test(c)) unlock(c); else toast('Paste the code from your receipt page (cs_live_…) or your Gumroad licence key.', 3500);
|
| 198 |
+
});
|
| 199 |
+
d.querySelectorAll('[data-plan]').forEach((a) => a.addEventListener('click', () => count(cfg.game, 'cta', `pass-${a.dataset.plan}`)));
|
| 200 |
+
d.querySelector('[data-game]')?.addEventListener('click', () => count(cfg.game, 'cta', 'full-game'));
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/** Open the pass sheet; `from` names the button that opened it (counted as cta). */
|
| 204 |
+
export function open(from = 'button') {
|
| 205 |
+
render();
|
| 206 |
+
const d = dialog();
|
| 207 |
+
if (d.showModal) d.showModal(); else d.setAttribute('open', '');
|
| 208 |
+
count(cfg.game, 'cta', `pass-open-${from}`);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/** After a finished round (the value moment): one small inline card under the result, never a pop-up. Shows the
|
| 212 |
+
* pass price, the honest trust line and an optional "email me" weekly reminder (double opt-in).
|
| 213 |
+
* `host` is the result panel; the card is added once and removed for pass holders. */
|
| 214 |
+
// One quiet line under the result: CyberMax's free Roblox games (24 Oct 2026). Not on game portals (their rules ban
|
| 215 |
+
// outside links), never a pop-up; links carry the game id so clicks can be told apart.
|
| 216 |
+
const ROBLOX = [['Skyline Flight Circuit', 'https://www.roblox.com/games/89786604994377'], ['Hatchlume', 'https://www.roblox.com/games/80122923062327'],
|
| 217 |
+
['Sled Volt', 'https://www.roblox.com/games/134881648422275']];
|
| 218 |
+
function robloxRow(host) {
|
| 219 |
+
if (portal() || host.querySelector('.fp-rbx')) return;
|
| 220 |
+
const p = document.createElement('p'); p.className = 'fp-rbx';
|
| 221 |
+
const tag = `?utm_source=cybermax&utm_medium=game&utm_campaign=${encodeURIComponent(cfg.game || 'games')}-end`;
|
| 222 |
+
p.innerHTML = 'Play our Roblox games: ' + ROBLOX.map(([n, u]) => `<a href="${u}${tag}" target="_blank" rel="noopener">${esc(n)}</a>`).join(' · ');
|
| 223 |
+
p.querySelectorAll('a').forEach((a) => a.addEventListener('click', () => count(cfg.game, 'cta', 'roblox-end')));
|
| 224 |
+
host.appendChild(p);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
// The paywall moment (owner, 31 Oct 2026: "charge for more levels"; docs/ceo/game-content-monetization-2026-10-31.md):
|
| 228 |
+
// the unlock card is shown at a NATURAL point only: the first result after the free chapter is cleared (init({ ready }) ->
|
| 229 |
+
// true), else from the 3rd finished round in this browser, and then at most once a day. Never on the first round, never
|
| 230 |
+
// during play (results screens only), never stacked: the game's own result stays the headline. init({ preview: [...] })
|
| 231 |
+
// lists what the paid content holds (chapter names), shown as one quiet line in the card.
|
| 232 |
+
const ROUNDS_KEY = () => `cmx-rounds:${cfg.game || OFFER.game}`;
|
| 233 |
+
export function paywallDue() {
|
| 234 |
+
const r = store(ROUNDS_KEY()) || { n: 0, day: '', end: 0 };
|
| 235 |
+
r.n = (r.n || 0) + 1;
|
| 236 |
+
const day = new Date().toISOString().slice(0, 10);
|
| 237 |
+
let due = false, why = '';
|
| 238 |
+
let ready = false;
|
| 239 |
+
try { ready = !!(cfg.ready && cfg.ready()); } catch { /* game hook */ }
|
| 240 |
+
if (ready && !r.end) { due = true; why = 'chapter-end'; r.end = 1; } // the end of the free chapter: always the first time
|
| 241 |
+
else if (r.n >= 3 && r.day !== day) { due = true; why = ready ? 'chapter-end-again' : 'rounds'; }
|
| 242 |
+
if (due) r.day = day;
|
| 243 |
+
store(ROUNDS_KEY(), r);
|
| 244 |
+
return due ? why : '';
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
export function afterWin(host, from = 'win') {
|
| 248 |
+
if (!host) return;
|
| 249 |
+
robloxRow(host);
|
| 250 |
+
if (isPro() || portal()) { host.querySelector('.fp-after')?.remove(); return; }
|
| 251 |
+
const why = paywallDue();
|
| 252 |
+
const nudges = host.querySelectorAll('.nudge'); // a result never carries two upsells: the content card wins over a looks nudge
|
| 253 |
+
nudges.forEach((n) => { n.hidden = !!why; });
|
| 254 |
+
if (!why) { host.querySelector('.fp-after')?.remove(); return; }
|
| 255 |
+
from = `${from}-${why}`;
|
| 256 |
+
let el = host.querySelector('.fp-after');
|
| 257 |
+
if (!el) { el = document.createElement('div'); el.className = 'fp-after'; host.appendChild(el); }
|
| 258 |
+
const best = PLANS.find((p) => p.best) || PLANS[0];
|
| 259 |
+
const game = sellsGame();
|
| 260 |
+
const href = game ? gameUrl('after') : `${buyUrl(best.id)}-after`;
|
| 261 |
+
const label = game ? (cfg.title ? `Get the ${cfg.title}: ${OFFER.price} once` : `Get the full ${OFFER.name}: ${OFFER.price} once`) : `Get the Fun Pass: ${best.price}${best.per}`;
|
| 262 |
+
const line = game ? (cfg.extra || `The full game opens every level, mode, the daily archive and themes in ${OFFER.name}.`)
|
| 263 |
+
: (cfg.extra || 'The Fun Pass opens every level, mode, the full archive and themes in every CyberMax game.');
|
| 264 |
+
const pv = Array.isArray(cfg.preview) && cfg.preview.length && game ? `<p class="fp-pv">Inside: ${cfg.preview.slice(0, 4).map(esc).join(' · ')}</p>` : '';
|
| 265 |
+
el.innerHTML = `<p><b>${game && from.includes('chapter-end') ? 'You cleared the free levels.' : 'Want more today?'}</b> ${esc(line)}</p>${pv}
|
| 266 |
+
<p class="fp-row"><a class="btn sm" href="${href}" rel="nofollow" data-after>${esc(label)}</a> <button class="btn sm ghost" type="button" data-plans>${game ? 'All games pass' : 'See all plans'}</button></p>
|
| 267 |
+
<p class="fp-small">Secure checkout by Stripe (shown as Link) · turns on as soon as you pay · ${game ? 'one payment, no subscription' : 'cancel any time from your receipt email'} · 14-day fix-or-refund if it doesn't work as described (<a href="https://cybermaxtools.com/terms#payments" target="_blank" rel="noopener">terms</a>). Prices in USD, + tax where applicable. Today's daily challenge stays free.</p>
|
| 268 |
+
<div class="fp-cap"></div>`;
|
| 269 |
+
el.querySelector('[data-after]').addEventListener('click', () => { count(cfg.game, 'cta', game ? 'full-game-after' : `pass-${best.id}-after`); kit((K) => K.event('upgrade-click', cfg.game)); });
|
| 270 |
+
el.querySelector('[data-plans]').addEventListener('click', () => open(`after-${from}`));
|
| 271 |
+
kit((K) => {
|
| 272 |
+
K.event('result', cfg.game); K.event('upgrade-view', cfg.game);
|
| 273 |
+
K.capture(el.querySelector('.fp-cap'), { list: `weekly-${cfg.game}`, src: `game-${cfg.game}`, label: cfg.remind || 'Email me a weekly reminder with new puzzles (free)', button: 'Remind me' });
|
| 274 |
+
});
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
// Convert kit (funnel beacons + email capture) from the CyberMax site; optional, the game works without it.
|
| 278 |
+
let kitQ = null;
|
| 279 |
+
function kit(fn) {
|
| 280 |
+
if (window.CMXConvert) return fn(window.CMXConvert);
|
| 281 |
+
if (kitQ) return kitQ.push(fn);
|
| 282 |
+
kitQ = [fn];
|
| 283 |
+
const sc = document.createElement('script');
|
| 284 |
+
sc.src = 'https://cybermaxtools.com/store/convert.js'; sc.async = true;
|
| 285 |
+
sc.onload = () => kitQ.splice(0).forEach((f) => { try { f(window.CMXConvert); } catch { /* optional */ } });
|
| 286 |
+
document.head.appendChild(sc);
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
// ------------------------------------------------------------------ the Shop (owner, 29 Oct 2026: "there's nothing to buy")
|
| 290 |
+
// One clear Shop button on the title/menu screen and one quiet button on the results screen open ONE sheet that lists
|
| 291 |
+
// everything this game sells, cheapest first (OFFER.shop, written by scripts/games/sync_kit.py from products/fun-pass/shop.json;
|
| 292 |
+
// prices come from the Stripe packs): coin packs, Skin/Look/Founder Packs, the full game, the Fun Pass and the Arcade
|
| 293 |
+
// Lifetime. Buttons are plain markup with data-cmx-shop="<where>" (menu, title, results); this file labels them, opens
|
| 294 |
+
// the sheet and hides them on portal and Telegram builds (no outside checkout there). Never shown during play: the
|
| 295 |
+
// buttons live on menu/results screens or above the game, so the play HUD is unchanged. Buy links carry
|
| 296 |
+
// s=game-<id>-shop-<where>; cmx.js adds the first-touch tag on click. Nothing pops up by itself.
|
| 297 |
+
const SHOP = Array.isArray(OFFER.shop) ? OFFER.shop : [];
|
| 298 |
+
const TG = typeof location !== 'undefined' && (/[?&]tg(=|&|$)/.test(location.search) || /tgWebAppData=/.test(location.hash));
|
| 299 |
+
/** True where no web checkout may show: portal builds and the Telegram Mini App (Stars only). */
|
| 300 |
+
export const noShop = () => !!portal() || TG || !SHOP.length;
|
| 301 |
+
const slug = (s) => String(s || 'shop').toLowerCase().replace(/[^a-z0-9-]/g, '').slice(0, 24) || 'shop';
|
| 302 |
+
const shopHref = (offer, from) => `${DATA}/buy/${offer}?s=game-${OFFER.game}-shop-${slug(from)}`;
|
| 303 |
+
const ownedKind = (it) => {
|
| 304 |
+
if (it.kind === 'pass') return passOn();
|
| 305 |
+
if (it.kind === 'full') return ownsGame();
|
| 306 |
+
if (it.kind === 'skins') return !!store(`cmx-skins:${OFFER.game}`) || !!store(`cmx-founder:${OFFER.game}`);
|
| 307 |
+
if (it.kind === 'founder') return !!store(`cmx-founder:${OFFER.game}`);
|
| 308 |
+
if (it.kind === 'collector') return !!store(`cmx-collector:${OFFER.game}`); // looks Collector Packs (skins.js v2)
|
| 309 |
+
return false; // coin packs, looks packs and the Arcade Lifetime can always be bought
|
| 310 |
+
};
|
| 311 |
+
/** The Shop items with an owned flag: the game's content unlock (more levels, chapters, modes) on top, then cheapest first. */
|
| 312 |
+
const CONTENT = (it) => (it.kind === 'full' || it.kind === 'campaign' ? 0 : 1);
|
| 313 |
+
export const shopItems = () => SHOP.slice().sort((a, b) => CONTENT(a) - CONTENT(b) || a.cents - b.cents).map((it) => ({ ...it, owned: ownedKind(it) }));
|
| 314 |
+
/** Label for a Shop button: the menu/title one names the lowest price, the results one the most relevant offer. */
|
| 315 |
+
export function shopLabel(where = 'menu') {
|
| 316 |
+
if (where === 'results') return esc(OFFER.shopResults || '🛍️ See the shop →');
|
| 317 |
+
return `🛍️ Shop${OFFER.shopFrom ? ` <small>from ${esc(OFFER.shopFrom)}</small>` : ''}`;
|
| 318 |
+
}
|
| 319 |
+
/** Markup for a Shop button in screens a game draws itself ('' where no checkout may show). */
|
| 320 |
+
export function shopButtonHtml(where = 'menu', cls = '') {
|
| 321 |
+
if (noShop()) return '';
|
| 322 |
+
const c = where === 'results' ? 'btn ghost sm cmx-shopres' : 'btn cmx-shopbtn';
|
| 323 |
+
return `<button class="${c}${cls ? ` ${cls}` : ''}" type="button" data-cmx-shop="${esc(where)}">${shopLabel(where)}</button>`;
|
| 324 |
+
}
|
| 325 |
+
function paintShop() {
|
| 326 |
+
if (typeof document === 'undefined') return;
|
| 327 |
+
const off = noShop();
|
| 328 |
+
document.documentElement.classList.toggle('cmx-noshop', off);
|
| 329 |
+
for (const b of document.querySelectorAll('[data-cmx-shop]')) {
|
| 330 |
+
if (off) { if (!b.hasAttribute('data-cmx-keep')) b.hidden = true; continue; } // data-cmx-keep: the game's own button, its own handler
|
| 331 |
+
const where = b.dataset.cmxShop || 'menu';
|
| 332 |
+
const html = shopLabel(where === 'results' ? 'results' : 'menu');
|
| 333 |
+
if (b.dataset.cmxLabel !== html) { b.innerHTML = html; b.dataset.cmxLabel = html; }
|
| 334 |
+
if (b.hasAttribute('data-cmx-hidden')) continue; // the game shows/hides this one itself
|
| 335 |
+
b.hidden = false;
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
const swatch = (it) => `background:${it.sw && it.sw.length > 1 ? `linear-gradient(135deg,${it.sw.map(esc).join(',')})` : esc((it.sw || ['#FF6A3D'])[0])}`;
|
| 339 |
+
function shopDialog() {
|
| 340 |
+
let d = document.getElementById('cmxshop');
|
| 341 |
+
if (!d) {
|
| 342 |
+
d = document.createElement('dialog');
|
| 343 |
+
d.id = 'cmxshop';
|
| 344 |
+
d.className = 'funpass cmxshop';
|
| 345 |
+
d.setAttribute('aria-label', `${OFFER.name} shop`);
|
| 346 |
+
document.body.appendChild(d);
|
| 347 |
+
d.addEventListener('click', (e) => { if (e.target === d || e.target.closest('[data-close]')) d.close(); });
|
| 348 |
+
}
|
| 349 |
+
return d;
|
| 350 |
+
}
|
| 351 |
+
function renderShop(from) {
|
| 352 |
+
const d = shopDialog();
|
| 353 |
+
const rows = shopItems().map((it) => {
|
| 354 |
+
const img = it.img ? `<img src="${esc(it.img)}" alt="" loading="lazy" onerror="this.remove()">` : '';
|
| 355 |
+
const buy = it.owned ? '<span class="sh-own">Owned ✓</span>'
|
| 356 |
+
: `<a class="btn sm pass sh-buy" href="${shopHref(it.offer, from)}" rel="nofollow" data-offer="${esc(it.offer)}">${esc(it.price)}<small>${esc(it.per)}</small></a>`;
|
| 357 |
+
const alt = !it.owned && it.alt ? `<span class="sh-alt">or ${it.alt.map((a) => `<a href="${shopHref(a.offer, from)}" rel="nofollow" data-offer="${esc(a.offer)}">${esc(a.label)}</a>`).join(' · ')}</span>` : '';
|
| 358 |
+
return `<li class="sh-i sh-${esc(it.kind)}"><span class="sh-pv" style="${swatch(it)}" aria-hidden="true"><i>${esc(it.icon || '🛍️')}</i>${img}</span>`
|
| 359 |
+
+ `<span class="sh-t"><b>${esc(it.name)}</b><span class="sh-w"><em>What you get:</em> ${esc(it.what)}</span>${alt}</span>${buy}</li>`;
|
| 360 |
+
}).join('');
|
| 361 |
+
const store = OFFER.shopStore ? ` · <a href="${esc(OFFER.shopStore)}" target="_blank" rel="noopener">details in the store</a>` : '';
|
| 362 |
+
d.innerHTML = `<div class="fp"><button class="fp-x" data-close aria-label="Close">×</button><p class="fp-kick">${esc(OFFER.name)} shop</p>
|
| 363 |
+
<h2>Looks, packs and more</h2><ul class="sh-list">${rows}</ul>
|
| 364 |
+
<p class="fp-small">One-time prices unless marked /month or /year. Secure checkout by Stripe (shown as Link) · turns on as soon as you pay · your receipt code works on any device · 14-day fix-or-refund if it doesn't work as described (<a href="https://cybermaxtools.com/terms#payments" target="_blank" rel="noopener">terms</a>). Prices in USD, + tax where applicable. Looks never change scores or the daily board; the daily challenge stays free for everyone${store}.</p>
|
| 365 |
+
<p class="fp-small"><button class="sh-code" type="button" data-code>Already bought? Turn on your code</button></p></div>`;
|
| 366 |
+
d.querySelectorAll('a[data-offer]').forEach((a) => a.addEventListener('click', () => count(cfg.game, 'cta', `shop-buy-${a.dataset.offer.replace(/^st-/, '')}`.slice(0, 40))));
|
| 367 |
+
d.querySelector('[data-code]').addEventListener('click', () => { d.close(); open('shop-code'); });
|
| 368 |
+
}
|
| 369 |
+
/** Open the Shop sheet; `from` names the button that opened it (counted, and in the buy tag). */
|
| 370 |
+
export function openShop(from = 'button') {
|
| 371 |
+
if (noShop()) { if (portal()) open(from); return; } // a portal build keeps its rewarded-ad sheet
|
| 372 |
+
renderShop(from);
|
| 373 |
+
const d = shopDialog();
|
| 374 |
+
if (d.showModal) { if (!d.open) d.showModal(); } else d.setAttribute('open', '');
|
| 375 |
+
count(cfg.game, 'cta', `shop-open-${slug(from)}`);
|
| 376 |
+
}
|
| 377 |
+
if (typeof document !== 'undefined' && !window.__cmxShop) {
|
| 378 |
+
window.__cmxShop = 1;
|
| 379 |
+
// capture phase on the document: runs before the game's own handlers on that button, and stops them
|
| 380 |
+
document.addEventListener('click', (e) => {
|
| 381 |
+
const b = e.target && e.target.closest && e.target.closest('[data-cmx-shop]');
|
| 382 |
+
if (!b || noShop()) return; // portal / Telegram: the game's own handler (if any) runs as before
|
| 383 |
+
e.preventDefault(); e.stopPropagation();
|
| 384 |
+
openShop(b.dataset.cmxShop || 'menu');
|
| 385 |
+
}, true);
|
| 386 |
+
for (const ev of ['pointerdown', 'mousedown', 'touchstart']) { // tap-to-retry overlays never see a Shop tap
|
| 387 |
+
document.addEventListener(ev, (e) => { if (!noShop() && e.target && e.target.closest && e.target.closest('[data-cmx-shop]')) e.stopPropagation(); }, true);
|
| 388 |
+
}
|
| 389 |
+
paintShop();
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
/** Call once per page: game id, display name and the game's own perks (listed first). Reads #cmx-pro=<code> after
|
| 393 |
+
* checkout (?unlock=full marks this game's full-game return). Skin-pack codes are taken first by skins.js capture(). */
|
| 394 |
+
export function init(options) {
|
| 395 |
+
cfg = { ...cfg, ...options };
|
| 396 |
+
const m = /[#&]cmx-key=([^&]+)/.exec(location.hash || '') || /[#&]cmx-pro=([^&]+)/.exec(location.hash || '');
|
| 397 |
+
if (m && SID.test(decodeURIComponent(m[1]))) {
|
| 398 |
+
const q = new URLSearchParams(location.search);
|
| 399 |
+
const fullReturn = q.get('unlock') === 'full';
|
| 400 |
+
q.delete('unlock');
|
| 401 |
+
history.replaceState(null, '', location.pathname + (q.toString() ? `?${q}` : ''));
|
| 402 |
+
if (fullReturn) unlockGame(decodeURIComponent(m[1])); else unlock(decodeURIComponent(m[1]));
|
| 403 |
+
} else recheck();
|
| 404 |
+
emit();
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
// Direct checkout (17 Oct 2026, Workers cap fix): a click on a data.cybermaxtools.com/buy/<offer> link goes straight to the
|
| 408 |
+
// Stripe/Polar checkout (static map https://cybermaxtools.com/store/buy-direct.json); the click is counted by a beacon.
|
| 409 |
+
(() => {
|
| 410 |
+
if (typeof document === 'undefined' || window.__cmxBd) return;
|
| 411 |
+
window.__cmxBd = 1;
|
| 412 |
+
let MAP = null;
|
| 413 |
+
try { MAP = JSON.parse(sessionStorage.getItem('cmx-bd') || 'null'); } catch { /* none */ }
|
| 414 |
+
if (!MAP) fetch('https://cybermaxtools.com/store/buy-direct.json').then((r) => r.json()).then((j) => { MAP = j; try { sessionStorage.setItem('cmx-bd', JSON.stringify(j)); } catch { /* full */ } }).catch(() => {});
|
| 415 |
+
document.addEventListener('click', (e) => {
|
| 416 |
+
const a = e.target && e.target.closest && e.target.closest('a[href*="data.cybermaxtools.com/buy/"]');
|
| 417 |
+
if (!a || !MAP || !MAP.offers) return;
|
| 418 |
+
try {
|
| 419 |
+
const u = new URL(a.href);
|
| 420 |
+
const k = /^\/buy\/([a-z0-9-]+)\/?$/.exec(u.pathname);
|
| 421 |
+
const t = k && MAP.offers[k[1]];
|
| 422 |
+
if (!t) return;
|
| 423 |
+
const s = String(u.searchParams.get('s') || 'unknown').toLowerCase().replace(/[^a-z0-9-]/g, '').slice(0, 80) || 'unknown';
|
| 424 |
+
a.href = t.split(MAP.ph).join(s);
|
| 425 |
+
if (!navigator.webdriver) navigator.sendBeacon(u.href + (u.search ? '&' : '?') + 'b=1');
|
| 426 |
+
} catch { /* keep the counted link */ }
|
| 427 |
+
}, true);
|
| 428 |
+
})();
|
game.js
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Dig Drone: game screen (fixed-tick loop, crisp canvas, sound, haptics, upgrades, idle drone, daily dig, share card,
|
| 2 |
+
// Fun Pass). (c) 2026 CyberMax. All rights reserved.
|
| 3 |
+
import { makeRun, shareText as coreShare, botCol, HZ, COLS, TS, VIEW_W as W, VIEW_H as H, T, ORE, BIOMES, LAYER_EMOJI, biomeOf,
|
| 4 |
+
UPGRADES, DAILY_RIG, upgradeCost, idleCoins } from './core.js';
|
| 5 |
+
import { dayNumber, dateOf, count, store, toast, share, intents, download, canvasBlob, pwa, themeToggle, rr } from './cmx.js';
|
| 6 |
+
import * as pass from './funpass.js';
|
| 7 |
+
|
| 8 |
+
const GAME = 'delvewren';
|
| 9 |
+
const PATH = '/games/dig-drone/';
|
| 10 |
+
const $ = (id) => document.getElementById(id);
|
| 11 |
+
const cv = $('c');
|
| 12 |
+
const ctx = cv.getContext('2d');
|
| 13 |
+
const TAU = Math.PI * 2;
|
| 14 |
+
const LOOKS = {
|
| 15 |
+
ember: { name: 'Ember', tier: 'free', body: '#FF8A3D', belly: '#FFD9A8', wing: '#E2621B', drill: '#AEB8C6' },
|
| 16 |
+
berry: { name: 'Berry', tier: 'pass', body: '#FF5FA2', belly: '#FFD6E8', wing: '#D93C80', drill: '#C9B6FF' },
|
| 17 |
+
lagoon: { name: 'Lagoon', tier: 'pass', body: '#22C3B5', belly: '#C8FFF6', wing: '#109488', drill: '#FFD45C' },
|
| 18 |
+
};
|
| 19 |
+
const todayIso = new Date().toISOString().slice(0, 10);
|
| 20 |
+
const todayNum = dayNumber(todayIso);
|
| 21 |
+
|
| 22 |
+
pass.init({ game: GAME, name: 'Dig Drone', perks: ['Every past Daily Dig in the archive', 'Berry and Lagoon wren looks'],
|
| 23 |
+
free: 'Digging, every upgrade, the drone and the Daily Dig stay free for everyone.',
|
| 24 |
+
extra: 'The Fun Pass adds every past Daily Dig and 2 wren looks.',
|
| 25 |
+
preview: ['past daily digs', '2 looks'] });
|
| 26 |
+
const canUse = (s) => s.tier === 'free' || pass.isPro();
|
| 27 |
+
let look = LOOKS[store('delvewren:look')] && canUse(LOOKS[store('delvewren:look')]) ? store('delvewren:look') : 'ember';
|
| 28 |
+
let muted = !!store('delvewren:mute');
|
| 29 |
+
const save = store('delvewren:save') || { coins: 0, lv: { drill: 0, tank: 0, magnet: 0, value: 0 }, best: 0, runs: 0 };
|
| 30 |
+
const persist = () => store('delvewren:save', save);
|
| 31 |
+
let mode = { kind: 'dig' };
|
| 32 |
+
let run, acc = 0, last = performance.now(), hold = false, holdCol = null, keyDir = 0, keyHold = false, started = false, endShown = false, autoBot = false;
|
| 33 |
+
let camY = -170, shake = 0, hint = 1, banner = null, fx = [], texts = [], flyers = [], coinPulse = 0, digTick = 0;
|
| 34 |
+
const install = pwa(GAME, $('install'));
|
| 35 |
+
themeToggle($('theme'));
|
| 36 |
+
|
| 37 |
+
// ------------------------------------------------------------------ the helper drone digs while you're away (idle coins)
|
| 38 |
+
(() => {
|
| 39 |
+
const seen = store('delvewren:seen');
|
| 40 |
+
const got = seen ? idleCoins(Date.now() - seen, save.best) : 0;
|
| 41 |
+
store('delvewren:seen', Date.now());
|
| 42 |
+
if (got > 0) { save.coins += got; persist(); setTimeout(() => toast(`🤖 Your drone dug up 🪙 ${got} while you were away`, 4200), 700); }
|
| 43 |
+
setInterval(() => store('delvewren:seen', Date.now()), 30e3);
|
| 44 |
+
document.addEventListener('visibilitychange', () => store('delvewren:seen', Date.now()));
|
| 45 |
+
})();
|
| 46 |
+
|
| 47 |
+
// ------------------------------------------------------------------ sound (WebAudio, no files) + haptics
|
| 48 |
+
let ac, noiseBuf;
|
| 49 |
+
function audio() {
|
| 50 |
+
if (muted) return null;
|
| 51 |
+
try {
|
| 52 |
+
ac = ac || new (window.AudioContext || window.webkitAudioContext)();
|
| 53 |
+
if (!noiseBuf) { noiseBuf = ac.createBuffer(1, ac.sampleRate * 0.3, ac.sampleRate); const d = noiseBuf.getChannelData(0); for (let i = 0; i < d.length; i++) d[i] = Math.random() * 2 - 1; }
|
| 54 |
+
return ac;
|
| 55 |
+
} catch { return null; }
|
| 56 |
+
}
|
| 57 |
+
function tone(f, d = 0.08, type = 'sine', vol = 0.07, to = 1, delay = 0) {
|
| 58 |
+
const a = audio(); if (!a) return;
|
| 59 |
+
const t0 = a.currentTime + delay, o = a.createOscillator(), v = a.createGain();
|
| 60 |
+
o.type = type; o.frequency.setValueAtTime(f, t0); o.frequency.exponentialRampToValueAtTime(Math.max(40, f * to), t0 + d);
|
| 61 |
+
v.gain.setValueAtTime(0.0001, t0); v.gain.exponentialRampToValueAtTime(vol, t0 + 0.006); v.gain.exponentialRampToValueAtTime(0.0001, t0 + d);
|
| 62 |
+
o.connect(v); v.connect(a.destination); o.start(t0); o.stop(t0 + d + 0.03);
|
| 63 |
+
}
|
| 64 |
+
function crunch(freq, vol = 0.12, d = 0.09) {
|
| 65 |
+
const a = audio(); if (!a) return;
|
| 66 |
+
const s = a.createBufferSource(), f = a.createBiquadFilter(), v = a.createGain();
|
| 67 |
+
s.buffer = noiseBuf; f.type = 'bandpass'; f.frequency.value = freq; f.Q.value = 1.4;
|
| 68 |
+
v.gain.setValueAtTime(vol, a.currentTime); v.gain.exponentialRampToValueAtTime(0.0001, a.currentTime + d);
|
| 69 |
+
s.connect(f); f.connect(v); v.connect(a.destination); s.start(); s.stop(a.currentTime + d + 0.02);
|
| 70 |
+
}
|
| 71 |
+
const NOTES = [784, 880, 988, 1047, 1175, 1319, 1480, 1568];
|
| 72 |
+
const buzz = (ms) => { try { if (navigator.vibrate) navigator.vibrate(ms); } catch { /* */ } };
|
| 73 |
+
const setMuteLabel = () => { $('mute').textContent = muted ? '🔇' : '🔊'; };
|
| 74 |
+
setMuteLabel();
|
| 75 |
+
$('mute').onclick = () => { muted = !muted; store('delvewren:mute', muted); setMuteLabel(); };
|
| 76 |
+
|
| 77 |
+
// ------------------------------------------------------------------ crisp canvas (device pixels)
|
| 78 |
+
let scale = 1;
|
| 79 |
+
function fit() {
|
| 80 |
+
const r = cv.getBoundingClientRect();
|
| 81 |
+
const dpr = Math.min(3, window.devicePixelRatio || 1);
|
| 82 |
+
const w = Math.max(1, Math.round(r.width * dpr)), h = Math.max(1, Math.round(r.height * dpr));
|
| 83 |
+
if (cv.width !== w || cv.height !== h) { cv.width = w; cv.height = h; }
|
| 84 |
+
scale = cv.width / W;
|
| 85 |
+
}
|
| 86 |
+
new ResizeObserver(fit).observe(cv);
|
| 87 |
+
fit();
|
| 88 |
+
|
| 89 |
+
// ------------------------------------------------------------------ modes, upgrades, stats
|
| 90 |
+
const seedOf = (m) => (m.kind === 'daily' ? `daily:${m.date}` : m.seed);
|
| 91 |
+
const dayKey = (m) => `delvewren:day:${m.date}`;
|
| 92 |
+
const dayStats = (m) => store(dayKey(m)) || { best: 0, tries: 0 };
|
| 93 |
+
function renderModes() {
|
| 94 |
+
const el = $('modes'); el.innerHTML = '';
|
| 95 |
+
const items = [
|
| 96 |
+
{ t: 'Dig', on: mode.kind === 'dig', go: () => setMode({ kind: 'dig' }) },
|
| 97 |
+
{ t: `Daily Dig #${todayNum}`, on: mode.kind === 'daily' && mode.date === todayIso, go: () => setMode({ kind: 'daily', date: todayIso }) },
|
| 98 |
+
{ t: 'Archive', on: mode.kind === 'daily' && mode.date !== todayIso, lock: !pass.isPro(), go: archive },
|
| 99 |
+
];
|
| 100 |
+
for (const it of items) {
|
| 101 |
+
const b = document.createElement('button');
|
| 102 |
+
b.className = 'chip'; b.type = 'button'; b.setAttribute('aria-pressed', String(it.on));
|
| 103 |
+
b.innerHTML = `${it.t}${it.lock ? ' <span class="lock">🔒</span>' : ''}`;
|
| 104 |
+
b.onclick = it.go; el.appendChild(b);
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
function archive() {
|
| 108 |
+
if (!pass.isPro()) { pass.open('archive'); return; }
|
| 109 |
+
const n = todayNum - 1;
|
| 110 |
+
const k = Number(prompt(`Play a past Daily Dig: enter a number from 1 to ${n}`, String(n)));
|
| 111 |
+
if (k >= 1 && k <= n) setMode({ kind: 'daily', date: dateOf(k) });
|
| 112 |
+
}
|
| 113 |
+
function setMode(m) { mode = m; $('menu').open = false; renderModes(); start(); }
|
| 114 |
+
function hud() {
|
| 115 |
+
$('num').textContent = mode.kind === 'daily' ? `Daily #${dayNumber(mode.date)}` : '';
|
| 116 |
+
const best = mode.kind === 'daily' ? dayStats(mode).best : save.best;
|
| 117 |
+
$('best').textContent = `${best} m`; $('coins').textContent = save.coins.toLocaleString('en-US');
|
| 118 |
+
const ready = Object.keys(UPGRADES).filter((k) => upgradeCost(k, save.lv[k]) <= save.coins).length;
|
| 119 |
+
$('up-btn').textContent = ready ? `🛠 Upgrades · ${ready} ready` : '🛠 Upgrades';
|
| 120 |
+
$('up-btn').classList.toggle('glow', ready > 0);
|
| 121 |
+
}
|
| 122 |
+
const shopVis = (on) => { const b = $('shop-btn'); if (b) b.hidden = !on || pass.noShop(); };
|
| 123 |
+
function renderShop() {
|
| 124 |
+
const el = $('up-list'); el.innerHTML = '';
|
| 125 |
+
$('up-coins').textContent = save.coins.toLocaleString('en-US');
|
| 126 |
+
for (const [k, u] of Object.entries(UPGRADES)) {
|
| 127 |
+
const lv = save.lv[k] || 0, cost = upgradeCost(k, lv), max = cost === Infinity;
|
| 128 |
+
const row = document.createElement('div'); row.className = 'up';
|
| 129 |
+
row.innerHTML = `<span class="up-i" aria-hidden="true">${u.icon}</span><span class="up-t"><b>${u.name} <small>lv ${lv}</small></b><small>${u.what}</small></span>`;
|
| 130 |
+
const b = document.createElement('button'); b.type = 'button'; b.className = 'btn sm'; b.dataset.up = k;
|
| 131 |
+
b.textContent = max ? 'MAX' : `🪙 ${cost.toLocaleString('en-US')}`; b.disabled = max || cost > save.coins;
|
| 132 |
+
b.onclick = () => {
|
| 133 |
+
if (upgradeCost(k, save.lv[k]) > save.coins) return;
|
| 134 |
+
save.coins -= upgradeCost(k, save.lv[k]); save.lv[k] = (save.lv[k] || 0) + 1; persist();
|
| 135 |
+
tone(880, 0.08, 'triangle', 0.07); tone(1320, 0.12, 'triangle', 0.07, 1, 0.07); buzz(12);
|
| 136 |
+
count(GAME, 'win', `up-${k}`);
|
| 137 |
+
renderShop(); hud();
|
| 138 |
+
};
|
| 139 |
+
row.appendChild(b); el.appendChild(row);
|
| 140 |
+
}
|
| 141 |
+
$('up-note').textContent = mode.kind === 'daily' ? 'The Daily Dig uses the same rig for everyone; upgrades count in Dig mode.' : '';
|
| 142 |
+
}
|
| 143 |
+
$('up-btn').onclick = () => { renderShop(); $('upgrades').hidden = false; $('over').hidden = true; };
|
| 144 |
+
$('up-close').onclick = () => { $('upgrades').hidden = true; if (endShown) $('over').hidden = false; };
|
| 145 |
+
$('up-go').onclick = () => { $('upgrades').hidden = true; start(); };
|
| 146 |
+
|
| 147 |
+
// ------------------------------------------------------------------ run
|
| 148 |
+
function start() {
|
| 149 |
+
if (mode.kind === 'dig') mode.seed = `d${Date.now()}`;
|
| 150 |
+
run = makeRun(seedOf(mode), mode.kind === 'daily' ? DAILY_RIG : save.lv);
|
| 151 |
+
camY = -170; shake = 0; banner = null; fx = []; texts = []; flyers = []; endShown = false; started = false; acc = 0; last = performance.now();
|
| 152 |
+
$('over').hidden = true; $('upgrades').hidden = true; shopVis(false); hud();
|
| 153 |
+
}
|
| 154 |
+
function finish() {
|
| 155 |
+
endShown = true; save.runs++;
|
| 156 |
+
save.coins += run.coins;
|
| 157 |
+
let newBest = false;
|
| 158 |
+
if (mode.kind === 'daily') {
|
| 159 |
+
const s = dayStats(mode); s.tries = (s.tries || 0) + 1;
|
| 160 |
+
if (run.depth > (s.best || 0)) { s.best = run.depth; s.layers = run.layers; s.ores = run.ores; s.coins = run.coins; newBest = run.depth > 0; }
|
| 161 |
+
store(dayKey(mode), s);
|
| 162 |
+
} else if (run.depth > save.best) { save.best = run.depth; newBest = true; }
|
| 163 |
+
persist(); hud();
|
| 164 |
+
tone(523, 0.12, 'triangle', 0.07); tone(392, 0.25, 'triangle', 0.07, 1, 0.12);
|
| 165 |
+
setTimeout(() => showOver(newBest), 450);
|
| 166 |
+
if (run.depth >= 40) install.offer();
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
// ------------------------------------------------------------------ loop
|
| 170 |
+
function frame(now) {
|
| 171 |
+
requestAnimationFrame(frame);
|
| 172 |
+
const dt = Math.min(0.1, (now - last) / 1000); last = now;
|
| 173 |
+
const holding = hold || keyHold || autoBot;
|
| 174 |
+
if (holding && run && run.state === 'run' && !started) {
|
| 175 |
+
started = true;
|
| 176 |
+
count(GAME, 'play', mode.kind === 'daily' ? (mode.date === todayIso ? 'daily' : 'archive') : 'dig');
|
| 177 |
+
}
|
| 178 |
+
if (run && run.state === 'run' && started) {
|
| 179 |
+
acc += dt;
|
| 180 |
+
let n = 0;
|
| 181 |
+
while (acc >= 1 / HZ && n++ < 6) {
|
| 182 |
+
acc -= 1 / HZ;
|
| 183 |
+
const col = autoBot ? botCol(run) : keyDir ? run.x + keyDir : holdCol;
|
| 184 |
+
run.tick({ hold: holding, col });
|
| 185 |
+
for (const e of run.events) onEvent(e);
|
| 186 |
+
run.events.length = 0;
|
| 187 |
+
}
|
| 188 |
+
if (acc > 1 / HZ) acc = 0;
|
| 189 |
+
if (run.digging && ++digTick % 7 === 0) {
|
| 190 |
+
const d = run.digging; const b = BIOMES[biomeOf(d.r)];
|
| 191 |
+
dust((d.c + 0.5) * TS, (d.r + (d.r > run.cell() ? 0 : 0.5)) * TS, d.type === T.ROCK || d.type === T.BOULDER ? b.rock : b.soil, 3);
|
| 192 |
+
crunch(d.type === T.BOULDER ? 1300 : d.type === T.ROCK ? 900 : 420, 0.035, 0.05);
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
if (run && run.state === 'done' && !endShown) { for (const e of run.events) onEvent(e); run.events.length = 0; finish(); }
|
| 196 |
+
step(dt);
|
| 197 |
+
draw(now);
|
| 198 |
+
}
|
| 199 |
+
function onEvent(e) {
|
| 200 |
+
if (e.type === 'break') {
|
| 201 |
+
const b = BIOMES[e.biome];
|
| 202 |
+
const col = e.tile === T.BOULDER ? b.deep : e.tile === T.ROCK ? b.rock : b.soil;
|
| 203 |
+
dust((e.c + 0.5) * TS, (e.r + 0.5) * TS, col, e.tile === T.BOULDER ? 18 : e.tile === T.ROCK ? 10 : 6, 1.6);
|
| 204 |
+
if (e.tile === T.BOULDER) { shake = Math.max(shake, 6); crunch(1500, 0.14, 0.16); tone(110, 0.18, 'sine', 0.1, 0.6); buzz(15); }
|
| 205 |
+
else if (e.tile === T.ROCK) { shake = Math.max(shake, 2); crunch(950, 0.1, 0.1); }
|
| 206 |
+
else crunch(480, 0.08, 0.07);
|
| 207 |
+
} else if (e.type === 'ore') {
|
| 208 |
+
const c = { 4: '#E07B39', 5: '#DCE6F2', 6: '#FFD23F', 7: '#FF5FD2' }[e.ore];
|
| 209 |
+
dust((e.c + 0.5) * TS, (e.r + 0.5) * TS, c, 12, 2);
|
| 210 |
+
flyers.push({ x: (e.c + 0.5) * TS, y: (e.r + 0.5) * TS - camY, t: 0, c });
|
| 211 |
+
texts.push({ x: (e.c + 0.5) * TS, y: (e.r + 0.2) * TS, t: `+${e.v}`, life: 1, c: e.ore === 7 ? '#E2399B' : '#2B2340' });
|
| 212 |
+
tone(NOTES[Math.min(NOTES.length - 1, e.streak - 1)] * (e.ore === 7 ? 1.5 : 1), 0.12, 'triangle', 0.08);
|
| 213 |
+
if (e.ore >= 6) tone(NOTES[Math.min(NOTES.length - 1, e.streak)] * 1.5, 0.16, 'sine', 0.06, 1, 0.06);
|
| 214 |
+
buzz(e.ore >= 6 ? 14 : 6);
|
| 215 |
+
} else if (e.type === 'fuel') {
|
| 216 |
+
texts.push({ x: (e.c + 0.5) * TS, y: (e.r + 0.2) * TS, t: '+fuel', life: 1, c: '#E5484D' });
|
| 217 |
+
tone(520, 0.08, 'square', 0.04); tone(780, 0.1, 'square', 0.04, 1, 0.07); buzz(10);
|
| 218 |
+
} else if (e.type === 'biome') {
|
| 219 |
+
banner = { t: `${BIOMES[e.biome].name} · ${e.row} m`, life: 2.2 };
|
| 220 |
+
[0, 0.08, 0.16].forEach((d, i) => tone([659, 880, 1175][i], 0.18, 'triangle', 0.07, 1, d));
|
| 221 |
+
} else if (e.type === 'thud') { shake = Math.max(shake, 3); tone(90, 0.12, 'sine', 0.1, 0.7); }
|
| 222 |
+
}
|
| 223 |
+
function dust(x, y, c, n, sp = 1) {
|
| 224 |
+
for (let i = 0; i < n; i++) {
|
| 225 |
+
const a = Math.random() * TAU, v = (40 + Math.random() * 120) * sp;
|
| 226 |
+
fx.push({ x, y, vx: Math.cos(a) * v, vy: Math.sin(a) * v - 60, life: 0.6 + Math.random() * 0.5, r: 1.5 + Math.random() * 3, c });
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
function step(dt) {
|
| 230 |
+
for (const p of fx) { p.x += p.vx * dt; p.y += p.vy * dt; p.vy += 500 * dt; p.life -= dt * 1.5; }
|
| 231 |
+
fx = fx.filter((p) => p.life > 0); if (fx.length > 300) fx.splice(0, fx.length - 300);
|
| 232 |
+
for (const t of texts) { t.y -= 34 * dt; t.life -= dt; }
|
| 233 |
+
texts = texts.filter((t) => t.life > 0);
|
| 234 |
+
for (const f of flyers) f.t += dt * 2.2;
|
| 235 |
+
const arrived = flyers.filter((f) => f.t >= 1).length;
|
| 236 |
+
if (arrived) coinPulse = 1;
|
| 237 |
+
flyers = flyers.filter((f) => f.t < 1);
|
| 238 |
+
coinPulse = Math.max(0, coinPulse - dt * 3);
|
| 239 |
+
if (banner) { banner.life -= dt; if (banner.life <= 0) banner = null; }
|
| 240 |
+
if (run) {
|
| 241 |
+
const target = (run.y + 0.5) * TS - H * 0.36;
|
| 242 |
+
camY += (Math.max(-170, target) - camY) * Math.min(1, dt * 6);
|
| 243 |
+
if (started && run.t > 50) hint = Math.max(0, hint - dt * 0.9);
|
| 244 |
+
}
|
| 245 |
+
shake *= Math.pow(0.02, dt); if (shake < 0.2) shake = 0;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// ------------------------------------------------------------------ drawing
|
| 249 |
+
const mix = (a, b, k) => { // hex a -> hex b by k
|
| 250 |
+
const p = (h) => [parseInt(h.slice(1, 3), 16), parseInt(h.slice(3, 5), 16), parseInt(h.slice(5, 7), 16)];
|
| 251 |
+
const x = p(a), y = p(b);
|
| 252 |
+
return `rgb(${x.map((v, i) => Math.round(v + (y[i] - v) * k)).join(',')})`;
|
| 253 |
+
};
|
| 254 |
+
const pal = BIOMES.map((b) => ({ ...b, air: mix(b.soil, '#FFFFFF', 0.62), soilHi: mix(b.soil, '#FFFFFF', 0.22), rockHi: mix(b.rock, '#FFFFFF', 0.2), edge: mix(b.soil, '#FFFFFF', 0.45) }));
|
| 255 |
+
const h01 = (a, b) => { let h = (a * 374761393 + b * 668265263) | 0; h = (h ^ (h >>> 13)) * 1274126177; return ((h ^ (h >>> 16)) >>> 0) / 4294967296; };
|
| 256 |
+
function sky(c, top) {
|
| 257 |
+
// the sky above the surface (world y < 0): bright blue, sun, soft clouds
|
| 258 |
+
if (top >= 0) return;
|
| 259 |
+
const gr = c.createLinearGradient(0, top, 0, 0); gr.addColorStop(0, '#7FD3FF'); gr.addColorStop(1, '#D8F3FF');
|
| 260 |
+
c.fillStyle = gr; c.fillRect(-20, top - 20, W + 40, -top + 20);
|
| 261 |
+
c.fillStyle = '#FFE27A'; c.beginPath(); c.arc(W - 66, -92, 24, 0, TAU); c.fill();
|
| 262 |
+
c.fillStyle = 'rgba(255,255,255,.9)';
|
| 263 |
+
const t = performance.now() / 1000;
|
| 264 |
+
for (let i = 0; i < 3; i++) { const x = ((i * 140 + t * 8) % (W + 120)) - 60, y = -150 + i * 34; c.beginPath(); c.arc(x, y, 16, 0, TAU); c.arc(x + 18, y - 6, 20, 0, TAU); c.arc(x + 38, y, 15, 0, TAU); c.fill(); }
|
| 265 |
+
}
|
| 266 |
+
function tile(c, type, col, row, x, y, s) {
|
| 267 |
+
const b = pal[biomeOf(row)];
|
| 268 |
+
if (type === T.AIR) { c.fillStyle = b.air; c.fillRect(x, y, s, s); return; }
|
| 269 |
+
const base = type === T.ROCK ? b.rock : type === T.BOULDER ? b.deep : b.soil;
|
| 270 |
+
c.fillStyle = base; c.fillRect(x, y, s, s);
|
| 271 |
+
const u = s / TS; // device px per world unit
|
| 272 |
+
// speckles (fixed per tile, never flicker)
|
| 273 |
+
c.fillStyle = type === T.ROCK || type === T.BOULDER ? b.rockHi : b.soilHi;
|
| 274 |
+
for (let i = 0; i < 3; i++) { const px = h01(col * 7 + i, row), py = h01(row * 3 + i, col + 11); c.fillRect(x + (4 + px * 28) * u, y + (4 + py * 28) * u, 4 * u, 3 * u); }
|
| 275 |
+
if (type === T.BOULDER) {
|
| 276 |
+
c.fillStyle = b.rock; c.beginPath(); c.arc(x + s / 2, y + s / 2, s * 0.42, 0, TAU); c.fill();
|
| 277 |
+
c.fillStyle = b.rockHi; c.beginPath(); c.arc(x + s * 0.38, y + s * 0.36, s * 0.13, 0, TAU); c.fill();
|
| 278 |
+
} else if (ORE[type]) {
|
| 279 |
+
const oc = { 4: ['#E07B39', '#FFB27A'], 5: ['#C9D6E6', '#FFFFFF'], 6: ['#FFC21A', '#FFF1A8'], 7: ['#FF4FCB', '#FFD1F2'] }[type];
|
| 280 |
+
const pts = type === 7 ? [[0.5, 0.5]] : [[0.32, 0.36], [0.66, 0.42], [0.46, 0.7]];
|
| 281 |
+
for (const [px, py] of pts) {
|
| 282 |
+
const cx = x + px * s, cy = y + py * s, r = (type === 7 ? 11 : 6.5) * u;
|
| 283 |
+
c.fillStyle = oc[0]; c.beginPath(); c.moveTo(cx, cy - r); c.lineTo(cx + r, cy); c.lineTo(cx, cy + r); c.lineTo(cx - r, cy); c.closePath(); c.fill();
|
| 284 |
+
c.fillStyle = oc[1]; c.beginPath(); c.moveTo(cx, cy - r); c.lineTo(cx + r * 0.5, cy - r * 0.2); c.lineTo(cx, cy); c.closePath(); c.fill();
|
| 285 |
+
}
|
| 286 |
+
if (type >= 6) { const tw = (Math.sin(performance.now() / 260 + col * 2 + row) + 1) / 2; c.globalAlpha = tw; c.fillStyle = '#FFFFFF'; c.fillRect(x + s * 0.7, y + s * 0.18, 3 * u, 9 * u); c.fillRect(x + s * 0.7 - 3 * u, y + s * 0.18 + 3 * u, 9 * u, 3 * u); c.globalAlpha = 1; }
|
| 287 |
+
} else if (type === T.FUEL) {
|
| 288 |
+
c.fillStyle = '#E5484D'; rr(c, x + s * 0.24, y + s * 0.2, s * 0.52, s * 0.62, 5 * u); c.fill();
|
| 289 |
+
c.fillStyle = '#FFD45C'; c.fillRect(x + s * 0.24, y + s * 0.46, s * 0.52, s * 0.1);
|
| 290 |
+
c.fillStyle = '#B9282D'; c.fillRect(x + s * 0.42, y + s * 0.12, s * 0.16, s * 0.1);
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
function wren(c, x, y, S, dir, spin, s) { // the digging bird-bot, in world units
|
| 294 |
+
c.save(); c.translate(x, y); c.rotate(dir * -Math.PI / 2);
|
| 295 |
+
// drill cone below
|
| 296 |
+
c.fillStyle = S.drill; c.beginPath(); c.moveTo(-10, 8); c.lineTo(10, 8); c.lineTo(0, 30); c.closePath(); c.fill();
|
| 297 |
+
c.strokeStyle = 'rgba(43,35,64,.35)'; c.lineWidth = 2;
|
| 298 |
+
for (let i = 0; i < 3; i++) { const k = ((spin + i / 3) % 1); const yy = 10 + k * 18, hw = 10 * (1 - k * 0.9); c.beginPath(); c.moveTo(-hw, yy); c.lineTo(hw, yy + 3); c.stroke(); }
|
| 299 |
+
c.restore();
|
| 300 |
+
c.save(); c.translate(x, y);
|
| 301 |
+
c.fillStyle = S.body; c.beginPath(); c.arc(0, 0, 15, 0, TAU); c.fill();
|
| 302 |
+
c.lineWidth = 2.5; c.strokeStyle = 'rgba(43,35,64,.35)'; c.stroke();
|
| 303 |
+
c.fillStyle = S.belly; c.beginPath(); c.ellipse(0, 6, 9, 7, 0, 0, TAU); c.fill();
|
| 304 |
+
c.fillStyle = S.wing; c.beginPath(); c.ellipse(-11, 2, 6, 9, 0.5 + Math.sin(performance.now() / 90) * 0.15 * s, 0, TAU); c.fill();
|
| 305 |
+
c.fillStyle = '#FFFFFF'; c.beginPath(); c.arc(5, -4, 5.2, 0, TAU); c.fill();
|
| 306 |
+
c.fillStyle = '#2B2340'; c.beginPath(); c.arc(6, -4, 2.6, 0, TAU); c.fill();
|
| 307 |
+
c.fillStyle = '#FFC21A'; c.beginPath(); c.moveTo(12, -1); c.lineTo(19, 1); c.lineTo(12, 3); c.closePath(); c.fill();
|
| 308 |
+
c.fillStyle = 'rgba(255,255,255,.6)'; c.beginPath(); c.ellipse(-5, -9, 4, 2.4, -0.5, 0, TAU); c.fill();
|
| 309 |
+
c.restore();
|
| 310 |
+
}
|
| 311 |
+
function draw(now) {
|
| 312 |
+
const S = LOOKS[look];
|
| 313 |
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
| 314 |
+
const sh = shake ? [(Math.random() - 0.5) * shake * scale, (Math.random() - 0.5) * shake * scale] : [0, 0];
|
| 315 |
+
const cy = Math.round(camY * scale);
|
| 316 |
+
// background behind the ground (only seen in the sky)
|
| 317 |
+
ctx.fillStyle = '#D8F3FF'; ctx.fillRect(0, 0, cv.width, cv.height);
|
| 318 |
+
ctx.setTransform(scale, 0, 0, scale, sh[0], sh[1] - camY * scale);
|
| 319 |
+
sky(ctx, camY - 20);
|
| 320 |
+
if (!run) return;
|
| 321 |
+
// ground: drawn in device pixels with integer edges (no seams between tiles on any screen)
|
| 322 |
+
ctx.setTransform(1, 0, 0, 1, Math.round(sh[0]), Math.round(sh[1]));
|
| 323 |
+
const r0 = Math.max(0, Math.floor(camY / TS)), r1 = Math.ceil((camY + H) / TS);
|
| 324 |
+
for (let r = r0; r <= r1; r++) {
|
| 325 |
+
const y0 = Math.round(r * TS * scale) - cy, y1 = Math.round((r + 1) * TS * scale) - cy;
|
| 326 |
+
for (let c = 0; c < COLS; c++) {
|
| 327 |
+
const x0 = Math.round(c * TS * scale), x1 = Math.round((c + 1) * TS * scale);
|
| 328 |
+
const type = run.tile(c, r);
|
| 329 |
+
tile(ctx, type, c, r, x0, y0, Math.max(x1 - x0, y1 - y0));
|
| 330 |
+
if (type !== T.AIR) {
|
| 331 |
+
// a light edge where ground meets a tunnel or the sky: reads as depth, keeps the screen calm
|
| 332 |
+
if (run.tile(c, r - 1) === T.AIR || r === 0) { ctx.fillStyle = r === 0 ? '#6FD36B' : pal[biomeOf(r)].edge; ctx.fillRect(x0, y0, x1 - x0, Math.max(2, Math.round((r === 0 ? 7 : 3) * scale))); }
|
| 333 |
+
const k = run.crack(c, r);
|
| 334 |
+
if (k > 0.05) { ctx.strokeStyle = `rgba(43,35,64,${0.25 + k * 0.4})`; ctx.lineWidth = Math.max(1, 2 * scale); const mx = (x0 + x1) / 2, my = (y0 + y1) / 2, q = (x1 - x0) * 0.38 * k;
|
| 335 |
+
ctx.beginPath(); ctx.moveTo(mx, my); ctx.lineTo(mx - q, my - q * 0.6); ctx.moveTo(mx, my); ctx.lineTo(mx + q * 0.8, my - q * 0.3); ctx.moveTo(mx, my); ctx.lineTo(mx + q * 0.2, my + q); ctx.stroke(); }
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
// world things (wren, particles, texts) in world units
|
| 340 |
+
ctx.setTransform(scale, 0, 0, scale, sh[0], sh[1] - camY * scale);
|
| 341 |
+
const px = (run.x + (run.tx !== null ? Math.sign(run.tx - run.x) * Math.abs(run.sx || 0) : 0) + 0.5) * TS, py = (run.y + 0.5) * TS;
|
| 342 |
+
const side = run.digging && run.digging.r === run.cell() ? Math.sign(run.digging.c - run.x) : run.tx !== null ? Math.sign(run.tx - run.x) : 0;
|
| 343 |
+
const spin = run.digging ? (now / 120) % 1 : 0;
|
| 344 |
+
const jx = run.digging ? (Math.random() - 0.5) * 1.6 : 0;
|
| 345 |
+
wren(ctx, px + jx, py - 4, S, side, spin, run.digging ? 1 : 0.3);
|
| 346 |
+
for (const p of fx) { ctx.globalAlpha = Math.max(0, Math.min(1, p.life * 1.6)); ctx.fillStyle = p.c; ctx.fillRect(p.x - p.r, p.y - p.r, p.r * 2, p.r * 2); }
|
| 347 |
+
ctx.globalAlpha = 1; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
|
| 348 |
+
for (const t of texts) { ctx.globalAlpha = Math.min(1, t.life * 1.6); ctx.font = '900 16px system-ui, -apple-system, sans-serif'; ctx.lineWidth = 4; ctx.strokeStyle = '#FFFFFF'; ctx.strokeText(t.t, t.x, t.y); ctx.fillStyle = t.c; ctx.fillText(t.t, t.x, t.y); }
|
| 349 |
+
ctx.globalAlpha = 1;
|
| 350 |
+
// HUD (screen units): one depth + fuel chip, one coin chip
|
| 351 |
+
ctx.setTransform(scale, 0, 0, scale, 0, 0);
|
| 352 |
+
for (const f of flyers) { const e = f.t * f.t; const x = f.x + (W - 50 - f.x) * e, y = f.y + (30 - f.y) * e; ctx.fillStyle = f.c; ctx.beginPath(); ctx.arc(x, y, 5, 0, TAU); ctx.fill(); }
|
| 353 |
+
ctx.fillStyle = 'rgba(255,255,255,.88)'; rr(ctx, 12, 10, 132, 46, 20); ctx.fill();
|
| 354 |
+
ctx.fillStyle = '#2B2340'; ctx.textAlign = 'left'; ctx.font = '900 22px system-ui, -apple-system, sans-serif'; ctx.fillText(`${run.depth} m`, 26, 28);
|
| 355 |
+
const fk = run.fuel / run.maxFuel;
|
| 356 |
+
ctx.fillStyle = 'rgba(43,35,64,.12)'; rr(ctx, 26, 42, 104, 7, 3.5); ctx.fill();
|
| 357 |
+
ctx.fillStyle = fk > 0.35 ? "#2FBF71" : fk > 0.15 ? "#FFA41B" : "#E5484D"; if (fk > 0) { rr(ctx, 26, 42, Math.max(7, 104 * fk), 7, 3.5); ctx.fill(); }
|
| 358 |
+
ctx.fillStyle = '#2B2340'; ctx.font = '700 11px system-ui, -apple-system, sans-serif'; ctx.globalAlpha = 0.55; ctx.textAlign = 'right'; ctx.fillText('fuel', 130, 28); ctx.globalAlpha = 1;
|
| 359 |
+
const cw = 92 + coinPulse * 6;
|
| 360 |
+
ctx.fillStyle = 'rgba(255,255,255,.88)'; rr(ctx, W - 12 - cw, 10, cw, 36, 18); ctx.fill();
|
| 361 |
+
ctx.fillStyle = '#2B2340'; ctx.textAlign = 'center'; ctx.font = `900 ${17 + coinPulse * 3}px system-ui, -apple-system, sans-serif`; ctx.fillText(`🪙 ${run.coins}`, W - 12 - cw / 2, 29);
|
| 362 |
+
if (banner) { ctx.globalAlpha = Math.min(1, banner.life * 1.5); ctx.fillStyle = 'rgba(255,255,255,.9)'; rr(ctx, 40, H * 0.2 - 22, W - 80, 44, 22); ctx.fill(); ctx.fillStyle = '#2B2340'; ctx.font = '900 18px system-ui, -apple-system, sans-serif'; ctx.fillText(banner.t, W / 2, H * 0.2); ctx.globalAlpha = 1; }
|
| 363 |
+
if (hint > 0 && run.state === 'run') {
|
| 364 |
+
ctx.globalAlpha = Math.min(1, hint * 1.5); ctx.fillStyle = 'rgba(255,255,255,.9)'; rr(ctx, 50, H * 0.62 - 26, W - 100, 56, 20); ctx.fill();
|
| 365 |
+
ctx.fillStyle = '#2B2340'; ctx.font = '900 18px system-ui, -apple-system, sans-serif'; ctx.fillText(started ? 'Slide to steer to the gems' : 'Hold to dig', W / 2, H * 0.62 - 6);
|
| 366 |
+
ctx.font = '600 13px system-ui, -apple-system, sans-serif'; ctx.globalAlpha *= 0.7; ctx.fillText(started ? 'let go to save fuel' : 'anywhere on the ground', W / 2, H * 0.62 + 14); ctx.globalAlpha = 1;
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
// ------------------------------------------------------------------ results, share, card
|
| 371 |
+
const label = () => (mode.kind === 'daily' ? `#${dayNumber(mode.date)}` : 'dig');
|
| 372 |
+
const shareText = () => `${coreShare(run, label())}\nHow deep can your wren dig?`;
|
| 373 |
+
function showOver(newBest) {
|
| 374 |
+
$('over-title').textContent = newBest ? 'New record!' : 'Out of fuel!';
|
| 375 |
+
$('over-score').textContent = `${run.depth} m`;
|
| 376 |
+
$('over-line').textContent = `+${run.coins} coins · ${BIOMES[biomeOf(Math.max(1, run.depth))].name}`;
|
| 377 |
+
$('over-grid').textContent = coreShare(run, label());
|
| 378 |
+
const it = intents(GAME, shareText(), PATH);
|
| 379 |
+
$('sx').href = it.x; $('sb').href = it.bsky; $('sw').href = it.whatsapp;
|
| 380 |
+
$('over').hidden = false; shopVis(true); hud();
|
| 381 |
+
pass.afterWin($('over'), 'over');
|
| 382 |
+
}
|
| 383 |
+
function card() {
|
| 384 |
+
const c = document.createElement('canvas'); c.width = 1080; c.height = 1350;
|
| 385 |
+
const x = c.getContext('2d');
|
| 386 |
+
const gr = x.createLinearGradient(0, 0, 0, 1350); gr.addColorStop(0, '#9FE0FF'); gr.addColorStop(0.28, '#D8F3FF'); gr.addColorStop(0.28, '#6FD36B'); gr.addColorStop(0.3, BIOMES[0].soil);
|
| 387 |
+
run.layers.forEach((b, i) => gr.addColorStop(Math.min(0.99, 0.32 + (i + 1) * 0.09), BIOMES[b].soil));
|
| 388 |
+
x.fillStyle = gr; x.fillRect(0, 0, 1080, 1350);
|
| 389 |
+
x.save(); x.scale(3, 3); wren(x, 300, 140, LOOKS[look], 0, 0.3, 0); x.restore();
|
| 390 |
+
x.fillStyle = '#2B2340'; x.textAlign = 'left';
|
| 391 |
+
x.font = '900 72px system-ui, sans-serif'; x.fillText('DIG DRONE', 80, 130);
|
| 392 |
+
x.globalAlpha = 0.75; x.font = '700 40px system-ui, sans-serif'; x.fillText(mode.kind === 'daily' ? `Daily Dig #${dayNumber(mode.date)} · ${mode.date}` : 'My deepest dig', 80, 190);
|
| 393 |
+
x.globalAlpha = 1; x.fillStyle = '#FFFFFF'; x.font = '900 190px system-ui, sans-serif'; x.fillText(`${run.depth} m`, 80, 640);
|
| 394 |
+
x.font = '800 48px system-ui, sans-serif'; x.fillText(run.layers.map((b) => LAYER_EMOJI[b]).join(' '), 80, 740);
|
| 395 |
+
x.fillText(`🪙 ${run.coins}${run.ores[7] ? ` 💎 ×${run.ores[7]}` : ''}`, 80, 830);
|
| 396 |
+
x.font = '800 46px system-ui, sans-serif'; x.fillText('How deep can your wren dig?', 80, 1230);
|
| 397 |
+
x.globalAlpha = 0.85; x.font = '600 32px system-ui, sans-serif'; x.fillText('Play free: cybermaxtools.com/games/dig-drone', 80, 1295);
|
| 398 |
+
return c;
|
| 399 |
+
}
|
| 400 |
+
const fname = () => `delvewren-${mode.date || 'dig'}.png`;
|
| 401 |
+
$('share').onclick = async () => share(GAME, shareText(), PATH, await canvasBlob(card()), fname());
|
| 402 |
+
['sx', 'sb', 'sw'].forEach((id) => $(id).addEventListener('click', () => count(GAME, 'share', { sx: 'x', sb: 'bsky', sw: 'whatsapp' }[id])));
|
| 403 |
+
$('card').onclick = async () => { download(await canvasBlob(card()), fname()); count(GAME, 'share', 'png'); };
|
| 404 |
+
|
| 405 |
+
// ------------------------------------------------------------------ input: hold to dig, slide to steer
|
| 406 |
+
const colAt = (e) => { const r = cv.getBoundingClientRect(); return ((e.clientX - r.left) / r.width) * COLS - 0.5; };
|
| 407 |
+
cv.addEventListener('pointerdown', (e) => {
|
| 408 |
+
e.preventDefault();
|
| 409 |
+
if (run && run.state === 'done') { if (endShown) start(); return; }
|
| 410 |
+
hold = true; holdCol = colAt(e);
|
| 411 |
+
// a press right on the wren means "straight down"
|
| 412 |
+
if (run && Math.abs(holdCol - run.x) < 0.6) holdCol = null;
|
| 413 |
+
try { cv.setPointerCapture(e.pointerId); } catch { /* */ }
|
| 414 |
+
});
|
| 415 |
+
cv.addEventListener('pointermove', (e) => { if (hold) { const c = colAt(e); holdCol = run && Math.abs(c - run.x) < 0.6 ? null : c; } });
|
| 416 |
+
const up = () => { hold = false; holdCol = null; };
|
| 417 |
+
cv.addEventListener('pointerup', up); cv.addEventListener('pointercancel', up);
|
| 418 |
+
const KEYS = { ArrowLeft: -1, ArrowRight: 1, a: -1, d: 1 };
|
| 419 |
+
document.addEventListener('keydown', (e) => {
|
| 420 |
+
if (/^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(document.activeElement && document.activeElement.tagName) && (e.key === ' ' || e.key === 'Enter')) return;
|
| 421 |
+
if (e.key in KEYS) { keyDir = KEYS[e.key]; keyHold = true; e.preventDefault(); }
|
| 422 |
+
else if (e.key === ' ' || e.key === 'ArrowDown' || e.key === 's') { e.preventDefault(); if (run && run.state === 'done') { if (endShown && !e.repeat) start(); } else keyHold = true; }
|
| 423 |
+
else if (e.key === 'r' || e.key === 'R') { e.preventDefault(); start(); }
|
| 424 |
+
else if (e.key === 'm' || e.key === 'M') $('mute').click();
|
| 425 |
+
});
|
| 426 |
+
document.addEventListener('keyup', (e) => {
|
| 427 |
+
if (e.key in KEYS) { if (keyDir === KEYS[e.key]) keyDir = 0; keyHold = false; }
|
| 428 |
+
else if (e.key === ' ' || e.key === 'ArrowDown' || e.key === 's') keyHold = false;
|
| 429 |
+
});
|
| 430 |
+
window.addEventListener('blur', () => { up(); keyHold = false; keyDir = 0; });
|
| 431 |
+
$('pass-btn').onclick = () => pass.open('header');
|
| 432 |
+
$('again').onclick = () => { start(); cv.focus(); };
|
| 433 |
+
document.addEventListener('visibilitychange', () => { last = performance.now(); acc = 0; up(); });
|
| 434 |
+
function renderLooks() {
|
| 435 |
+
const el = $('looks'); el.innerHTML = '';
|
| 436 |
+
for (const [id, s] of Object.entries(LOOKS)) {
|
| 437 |
+
const b = document.createElement('button');
|
| 438 |
+
const lock = !canUse(s);
|
| 439 |
+
b.type = 'button'; b.title = `${s.name}${s.tier === 'pass' ? ' (Fun Pass)' : ''}`; b.setAttribute('aria-label', b.title);
|
| 440 |
+
b.style.background = `linear-gradient(135deg, ${s.body} 50%, ${s.belly} 50%)`;
|
| 441 |
+
b.setAttribute('aria-pressed', String(id === look));
|
| 442 |
+
if (lock) b.classList.add('locked');
|
| 443 |
+
b.onclick = () => { if (lock) { pass.open('theme'); return; } look = id; store('delvewren:look', id); renderLooks(); };
|
| 444 |
+
el.appendChild(b);
|
| 445 |
+
}
|
| 446 |
+
}
|
| 447 |
+
const refresh = () => { if (!canUse(LOOKS[look])) { look = 'ember'; store('delvewren:look', 'ember'); } renderLooks(); renderModes(); };
|
| 448 |
+
pass.onChange(refresh);
|
| 449 |
+
|
| 450 |
+
// test + screenshot hooks (no effect on normal play)
|
| 451 |
+
window.__delvewren = {
|
| 452 |
+
state: () => ({ state: run.state, depth: run.depth, coins: run.coins, fuel: run.fuel, started, endShown, bank: save.coins, lv: { ...save.lv }, mode: mode.kind }),
|
| 453 |
+
bot: (on = true) => { autoBot = on; },
|
| 454 |
+
drain: () => { run.fuel = Math.min(run.fuel, 0.05); },
|
| 455 |
+
};
|
| 456 |
+
window.__cmxShot = async () => {
|
| 457 |
+
start(); started = true; hint = 0;
|
| 458 |
+
const r = run;
|
| 459 |
+
for (let i = 0; i < 60 * 9 && r.state === 'run'; i++) { r.tick({ hold: true, col: botCol(r) }); r.events.length = 0; }
|
| 460 |
+
camY = (r.y + 0.5) * TS - H * 0.36;
|
| 461 |
+
};
|
| 462 |
+
|
| 463 |
+
renderModes(); renderLooks();
|
| 464 |
+
start();
|
| 465 |
+
requestAnimationFrame(frame);
|
icon-192.png
ADDED
|
|
icon-512.png
ADDED
|
|
icon-maskable.png
ADDED
|
|
icon.svg
ADDED
|
|
index.html
CHANGED
|
@@ -1,19 +1,85 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en" data-theme="light"><head><meta charset="utf-8"><!-- cmx:sound --><script>(()=>{let on=false;const W=window,L=[];try{if(navigator.audioSession)navigator.audioSession.type='playback'}catch(e){}const kick=c=>{if(c.state==='closed')return;if(c.state!=='running')c.resume().catch(()=>{});try{const b=c.createBuffer(1,1,22050),s=c.createBufferSource();s.buffer=b;s.connect(c.destination);s.start(0)}catch(e){}};for(const K of['AudioContext','webkitAudioContext']){const O=W[K];if(!O||O.__cmx)continue;const C=class extends O{constructor(...a){super(...a);L.push(this);if(on)kick(this)}};C.__cmx=1;W[K]=C}const go=()=>{on=true;L.forEach(kick)};for(const e of['pointerdown','touchend','keydown','click'])addEventListener(e,go,{capture:true,passive:true});document.addEventListener('visibilitychange',()=>{if(!document.hidden&&on)go()})})();</script><!-- /cmx:sound -->
|
| 3 |
+
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
| 4 |
+
<title>Dig Drone: Free Digging Game Online, Upgrade and Dig Deeper</title>
|
| 5 |
+
<meta name="description" content="Play Dig Drone free: hold to dig, slide to steer to gems, then spend coins on drill, tank and magnet upgrades to dig deeper. Daily Dig. No download.">
|
| 6 |
+
<link rel="canonical" href="https://cybermaxtools.com/games/dig-drone/">
|
| 7 |
+
<meta property="og:type" content="website"><meta property="og:site_name" content="CyberMax">
|
| 8 |
+
<meta property="og:title" content="Dig Drone: Free Digging Game Online">
|
| 9 |
+
<meta property="og:description" content="Play Dig Drone free: hold to dig, slide to steer to gems, then spend coins on drill, tank and magnet upgrades to dig deeper. Daily Dig. No download.">
|
| 10 |
+
<meta property="og:url" content="https://cybermaxtools.com/games/dig-drone/">
|
| 11 |
+
<meta property="og:image" content="https://cybermaxtools.com/games/dig-drone/og.png"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630">
|
| 12 |
+
<meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://cybermaxtools.com/games/dig-drone/og.png">
|
| 13 |
+
<meta name="twitter:title" content="Dig Drone: Free Digging Game Online">
|
| 14 |
+
<meta name="twitter:description" content="Play Dig Drone free: hold to dig, slide to steer to gems, then spend coins on drill, tank and magnet upgrades to dig deeper. Daily Dig. No download.">
|
| 15 |
+
<meta name="theme-color" content="#BFE9FF">
|
| 16 |
+
<link rel="manifest" href="manifest.webmanifest">
|
| 17 |
+
<link rel="icon" href="icon.svg" type="image/svg+xml"><link rel="apple-touch-icon" href="icon-192.png">
|
| 18 |
+
<meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-title" content="Dig Drone">
|
| 19 |
+
<link rel="stylesheet" href="fun.css"><link rel="stylesheet" href="style.css">
|
| 20 |
+
<script>try{var t=localStorage.getItem('cm-theme');document.documentElement.dataset.theme=t||'light'}catch(e){}</script>
|
| 21 |
+
<style>.h1kw{display:block;font-size:.42em;font-weight:600;opacity:.75;letter-spacing:.01em;margin-top:.15em}.seo ol,.seo ul{padding-left:1.2em}.seo li{margin:.25em 0}</style>
|
| 22 |
+
<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "VideoGame", "@id": "https://cybermaxtools.com/games/dig-drone/#game", "name": "Dig Drone", "alternateName": "Digging game online free", "url": "https://cybermaxtools.com/games/dig-drone/", "image": "https://cybermaxtools.com/games/dig-drone/og.png", "description": "Dig Drone is a free digging game for your browser. You steer a little drill-bird called a wren down through bright layers of soil, clay, sandstone, slate, crystal caves, ember rock and the golden core. Hold anywhere to dig, slide your finger to steer toward copper, silver, gold and gems, and grab fuel cans on the way. When the fuel runs out the run ends and your coins are banked. Spend them in the workshop on a faster drill, a bigger fuel tank, a magnet that pulls ores from the side columns and polish that makes every ore worth more, then dig again and go deeper. While you are away, your helper drone digs up coins for you. The Daily Dig gives everyone the same ground and the same rig, so depths compare fairly.", "genre": ["Arcade", "Casual", "Idle", "Incremental"], "gamePlatform": ["Web browser", "Android", "iOS", "Windows", "macOS", "ChromeOS"], "applicationCategory": "Game", "operatingSystem": "Any (web browser)", "playMode": "SinglePlayer", "inLanguage": "en", "isAccessibleForFree": true, "offers": [{"@type": "Offer", "name": "Free to play (daily challenge + free modes)", "price": "0", "priceCurrency": "USD"}], "author": {"@type": "Organization", "name": "CyberMax", "url": "https://cybermaxtools.com/"}, "publisher": {"@type": "Organization", "name": "CyberMax"}, "datePublished": "2026-11-07", "keywords": "Digging game online free, free dig-down upgrade game, unblocked, no download, browser game"}, {"@type": "FAQPage", "@id": "https://cybermaxtools.com/games/dig-drone/#faq", "mainEntity": [{"@type": "Question", "name": "Is Dig Drone free?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. Digging, every upgrade, the drone and the Daily Dig are free, with no ads and no sign-up. The optional CyberMax Fun Pass adds every past Daily Dig and two wren looks."}}, {"@type": "Question", "name": "How do I get deeper?", "acceptedAnswer": {"@type": "Answer", "text": "Spend the coins from each run on upgrades: the Drill digs faster and cracks boulders, the Fuel tank makes runs longer, the Magnet collects ores from side columns and Polish raises the coins per ore."}}, {"@type": "Question", "name": "Is it an idle game?", "acceptedAnswer": {"@type": "Answer", "text": "Partly. Runs are short and active, and your helper drone also digs up coins while you are away, for up to 8 hours."}}, {"@type": "Question", "name": "Is the Daily Dig fair?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. Everyone gets the same ground and the same rig that day, whatever they have upgraded, so depths compare fairly."}}, {"@type": "Question", "name": "Can I play offline?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, after the first visit, and you can add it to your home screen like an app."}}]}]}</script>
|
| 23 |
+
</head><body>
|
| 24 |
+
<div class="wrap">
|
| 25 |
+
<header class="top"><a class="brand" href="https://cybermaxtools.com/games/"><svg viewBox="0 0 512 512" aria-hidden="true"><clipPath id="lg"><rect width="512" height="512" rx="116"/></clipPath><g clip-path="url(#lg)"><rect width="512" height="512" fill="#FF6A3D"/><path d="M512 250V512H250Z" fill="#D9481F"/></g><g transform="translate(86 86) scale(3.4)"><path d="M66 27 A27 27 0 1 0 66 73" fill="none" stroke="#11141B" stroke-width="17" stroke-linecap="round"/><rect x="66" y="41" width="20" height="18" rx="4" fill="#11141B"/></g></svg>CyberMax</a>
|
| 26 |
+
<nav><a href="https://cybermaxtools.com/games/">Games</a></nav><button class="btn sm cmx-shopbtn cmx-shop-top" id="shop-btn" type="button" data-cmx-shop="title" data-cmx-hidden>🛍️ Shop</button><button class="icon" id="mute" type="button" aria-label="Sound on or off">🔊</button><button class="icon" id="theme" type="button" aria-label="Switch light or dark">◐</button></header>
|
| 27 |
+
<main>
|
| 28 |
+
<section class="game">
|
| 29 |
+
<div class="headline"><h1>Dig Drone <span id="num" class="num"></span> <span class="pro-badge">PASS</span> <small class="h1kw">Free dig-down upgrade game</small></h1></div>
|
| 30 |
+
<div class="stage"><canvas id="c" width="360" height="540" aria-label="Dig Drone game. Hold to dig down, slide left or right to steer. Space or arrow keys on a keyboard." tabindex="0"></canvas>
|
| 31 |
+
<section class="panel over" id="over" hidden aria-live="polite">
|
| 32 |
+
<h2 id="over-title"></h2>
|
| 33 |
+
<p class="big-num" id="over-score">0</p>
|
| 34 |
+
<p id="over-line" class="muted"></p>
|
| 35 |
+
<button class="btn big" id="again" type="button">Dig again</button>
|
| 36 |
+
<p><button class="btn ghost sm cmx-shopres" type="button" data-cmx-shop="results">See the shop →</button></p>
|
| 37 |
+
<details class="more-res"><summary>Your dig and sharing</summary>
|
| 38 |
+
<p id="over-grid" class="grid" aria-label="Your dig"></p>
|
| 39 |
+
<div class="row"><button class="btn sm" id="share" type="button">Share score</button><a class="btn ghost sm" id="sx" target="_blank" rel="noopener">X</a><a class="btn ghost sm" id="sb" target="_blank" rel="noopener">Bluesky</a><a class="btn ghost sm" id="sw" target="_blank" rel="noopener">WhatsApp</a><button class="btn ghost sm" id="card" type="button">Save card</button></div>
|
| 40 |
+
</details>
|
| 41 |
+
</section>
|
| 42 |
+
<section class="panel upgrades" id="upgrades" hidden aria-label="Upgrades">
|
| 43 |
+
<h2>Workshop <small class="muted">🪙 <b id="up-coins">0</b></small></h2>
|
| 44 |
+
<div id="up-list"></div>
|
| 45 |
+
<p id="up-note" class="muted small"></p>
|
| 46 |
+
<div class="row"><button class="btn big" id="up-go" type="button">Dig again</button><button class="btn ghost sm" id="up-close" type="button">Back</button></div>
|
| 47 |
+
</section>
|
| 48 |
+
</div>
|
| 49 |
+
<div class="row under"><span class="muted small">Best <b id="best">0 m</b> · 🪙 <b id="coins">0</b></span><button class="btn ghost sm" id="up-btn" type="button">🛠 Upgrades</button>
|
| 50 |
+
<details class="menu" id="menu"><summary class="btn ghost sm">☰ Menu</summary>
|
| 51 |
+
<div class="menu-body">
|
| 52 |
+
<div class="chips" id="modes" role="group" aria-label="Mode"></div>
|
| 53 |
+
<div class="row looks" id="looks" aria-label="Wren look"></div>
|
| 54 |
+
<div class="row"><button class="btn pass sm" id="pass-btn" type="button">✨ Fun Pass</button><button class="btn ghost sm" id="install" type="button" hidden>📲 Add to Home Screen</button></div>
|
| 55 |
+
</div>
|
| 56 |
+
</details>
|
| 57 |
+
</div>
|
| 58 |
+
</section>
|
| 59 |
+
<section class="seo" id="guide">
|
| 60 |
+
<h2>Dig Drone: digging game online free</h2>
|
| 61 |
+
<p>Dig Drone is a free digging game for your browser. You steer a little drill-bird called a wren down through bright layers of soil, clay, sandstone, slate, crystal caves, ember rock and the golden core. Hold anywhere to dig, slide your finger to steer toward copper, silver, gold and gems, and grab fuel cans on the way. When the fuel runs out the run ends and your coins are banked. Spend them in the workshop on a faster drill, a bigger fuel tank, a magnet that pulls ores from the side columns and polish that makes every ore worth more, then dig again and go deeper. While you are away, your helper drone digs up coins for you. The Daily Dig gives everyone the same ground and the same rig, so depths compare fairly.</p>
|
| 62 |
+
<h2>How to play Dig Drone</h2>
|
| 63 |
+
<ol><li>Hold anywhere on the game to dig straight down.</li><li>Slide your finger left or right to steer toward ores and around boulders.</li><li>Let go to stop digging and save fuel.</li><li>Ores pay coins; red fuel cans add fuel.</li><li>When the fuel runs out, spend your coins in the workshop and dig again.</li><li>Come back later: your drone digs up coins while you are away.</li></ol>
|
| 64 |
+
<h3>Controls</h3>
|
| 65 |
+
<p><b>Phone and tablet:</b> Hold to dig, slide to steer.</p>
|
| 66 |
+
<p><b>Desktop, laptop and Chromebook:</b> Hold the mouse button, or hold Down/Space to dig and Left/Right to steer. R restarts, M mutes.</p>
|
| 67 |
+
<h2>Dig Drone tips and strategy</h2>
|
| 68 |
+
<ul><li>Boulders take long to crack early on: steer around them.</li><li>Caves are free depth: fall through them without using drill time.</li><li>Buy the Fuel tank and Drill first, then the Magnet.</li><li>Gems only appear from the Slate Deep (120 m) down.</li></ul>
|
| 69 |
+
<h2>Game modes</h2>
|
| 70 |
+
<ul><li>Dig: your own upgraded rig, fresh ground every run.</li><li>Daily Dig: the same ground and the same rig for everyone today, with a shareable depth card.</li><li>Fun Pass: every past Daily Dig and the Berry and Lagoon wren looks.</li></ul>
|
| 71 |
+
<p>The daily challenge and the main modes are free to play, with no ads and no sign-up. Bonus modes, the daily archive and colour themes come with the optional <a href="https://cybermaxtools.com/games/#pass">CyberMax Fun Pass</a> ($2.99/month, $19/year or $29.99 for life), which opens everything in every CyberMax game.</p>
|
| 72 |
+
<h2>Dig Drone FAQ</h2>
|
| 73 |
+
<h3>Is Dig Drone free?</h3><p>Yes. Digging, every upgrade, the drone and the Daily Dig are free, with no ads and no sign-up. The optional CyberMax Fun Pass adds every past Daily Dig and two wren looks.</p>
|
| 74 |
+
<h3>How do I get deeper?</h3><p>Spend the coins from each run on upgrades: the Drill digs faster and cracks boulders, the Fuel tank makes runs longer, the Magnet collects ores from side columns and Polish raises the coins per ore.</p>
|
| 75 |
+
<h3>Is it an idle game?</h3><p>Partly. Runs are short and active, and your helper drone also digs up coins while you are away, for up to 8 hours.</p>
|
| 76 |
+
<h3>Is the Daily Dig fair?</h3><p>Yes. Everyone gets the same ground and the same rig that day, whatever they have upgraded, so depths compare fairly.</p>
|
| 77 |
+
<h3>Can I play offline?</h3><p>Yes, after the first visit, and you can add it to your home screen like an app.</p>
|
| 78 |
+
<h2>Similar free games</h2>
|
| 79 |
+
<div class="more"><a href="https://cybermaxtools.com/games/gummy-jar/"><b>Gummy Jar</b><span>Drop gummies, match two, plop them bigger</span></a><a href="https://cybermaxtools.com/games/sledvolt/"><b>Sled Volt</b><span>3D downhill sled runner: swipe, jump, tuck and outrun the Rimehorn</span></a><a href="https://cybermaxtools.com/games/web-wrecker/"><b>Web Wrecker</b><span>Wreck any website with a stickman</span></a><a href="https://cybermaxtools.com/games/"><b>All CyberMax games</b><span>Free browser games, no download</span></a></div>
|
| 80 |
+
</section>
|
| 81 |
+
</main>
|
| 82 |
+
<footer>© 2026 CyberMax · <a href="https://cybermaxtools.com/games/">Games</a> · <a href="https://cybermaxtools.com/store/">Store</a> · <a href="https://cybermaxtools.com/privacy">Privacy</a> · <a href="https://cybermaxtools.com/terms">Terms</a></footer>
|
| 83 |
+
</div>
|
| 84 |
+
<script type="module" src="game.js"></script>
|
| 85 |
+
</body></html>
|
manifest.webmanifest
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "Dig Drone",
|
| 3 |
+
"short_name": "Dig Drone",
|
| 4 |
+
"description": "Hold to dig, slide to steer, upgrade and dig deeper. Free daily game by CyberMax, works offline.",
|
| 5 |
+
"id": "index.html",
|
| 6 |
+
"start_url": "index.html?utm_source=pwa-hf",
|
| 7 |
+
"scope": "./",
|
| 8 |
+
"display": "standalone",
|
| 9 |
+
"orientation": "portrait",
|
| 10 |
+
"background_color": "#BFE9FF",
|
| 11 |
+
"theme_color": "#BFE9FF",
|
| 12 |
+
"categories": [
|
| 13 |
+
"games",
|
| 14 |
+
"entertainment"
|
| 15 |
+
],
|
| 16 |
+
"icons": [
|
| 17 |
+
{
|
| 18 |
+
"src": "icon-192.png",
|
| 19 |
+
"sizes": "192x192",
|
| 20 |
+
"type": "image/png"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"src": "icon-512.png",
|
| 24 |
+
"sizes": "512x512",
|
| 25 |
+
"type": "image/png"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"src": "icon-maskable.png",
|
| 29 |
+
"sizes": "512x512",
|
| 30 |
+
"type": "image/png",
|
| 31 |
+
"purpose": "maskable"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"src": "icon.svg",
|
| 35 |
+
"sizes": "any",
|
| 36 |
+
"type": "image/svg+xml"
|
| 37 |
+
}
|
| 38 |
+
],
|
| 39 |
+
"screenshots": [
|
| 40 |
+
{
|
| 41 |
+
"src": "shot-phone.png",
|
| 42 |
+
"sizes": "780x1688",
|
| 43 |
+
"type": "image/png",
|
| 44 |
+
"form_factor": "narrow"
|
| 45 |
+
}
|
| 46 |
+
]
|
| 47 |
+
}
|
offer.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Written by scripts/games/sync_kit.py from products/fun-pass/games.json; do not edit by hand. (c) 2026 CyberMax.
|
| 2 |
+
export const OFFER = {"game": "delvewren", "name": "Dig Drone", "price": null, "live": false, "demo": 20, "games": 26, "levels": false, "shop": [{"offer": "st-fun-pass-monthly", "kind": "pass", "name": "Fun Pass", "what": "Every paid level, chapter and mode in every CyberMax game (Campaign+, Prism+, every full game), plus every past daily and theme. Cancel any time.", "cents": 299, "price": "$2.99", "per": "/month", "icon": "✨", "sw": ["#FFB547", "#FF6A3D"], "store": "https://cybermaxtools.com/store/fun-pass/", "img": "https://cybermaxtools.com/store/img/fun-pass-icon.webp", "alt": [{"offer": "st-fun-pass-yearly", "label": "$19/year"}, {"offer": "st-fun-pass-unlock", "label": "$29.99 for life"}]}, {"offer": "st-arcade-lifetime-lifetime", "kind": "arcade", "name": "Arcade Lifetime", "what": "One payment for every content unlock in every CyberMax game, now and later (every full game, Campaign+, Prism+ and new chapters), plus the Fun Pass for life and every Skin, Look and Founder Pack. Coin and crown packs not included.", "cents": 3999, "price": "$39.99", "per": "", "icon": "🕹️", "sw": ["#5CF2FF", "#B26BFF"], "store": "https://cybermaxtools.com/store/arcade-lifetime/", "img": "https://cybermaxtools.com/store/img/arcade-lifetime-icon.webp"}], "shopFrom": "$2.99", "shopResults": "✨ See the Fun Pass →", "shopStore": null, "shopPass": true};
|
og.png
ADDED
|
shot-phone.png
ADDED
|
Git LFS Details
|
style.css
CHANGED
|
@@ -1,28 +1,29 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
}
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
}
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
-
}
|
|
|
|
|
|
| 1 |
+
/* Dig Drone layout. Ground colours live in core.js (BIOMES). Calm screen: the dig (depth/fuel + coins drawn in it), upgrades, one menu. (c) 2026 CyberMax. */
|
| 2 |
+
.headline h1{margin:4px 0 0}.headline h1 .num{color:var(--muted);font-weight:700;font-size:.62em}
|
| 3 |
+
.stage{position:relative;display:flex;justify-content:center;margin-top:8px}
|
| 4 |
+
#c{display:block;width:min(100%,calc((100svh - 190px) * 2 / 3),480px);min-width:240px;aspect-ratio:2/3;height:auto;border-radius:24px;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;cursor:pointer;box-shadow:0 2px 6px rgba(17,20,27,.08),0 14px 40px rgba(17,20,27,.12);background:#BFE9FF}
|
| 5 |
+
.under{justify-content:center;align-items:flex-start;margin:10px 0;gap:10px}
|
| 6 |
+
.menu{position:relative}.menu>summary{list-style:none;cursor:pointer;min-height:44px}.menu>summary::-webkit-details-marker{display:none}
|
| 7 |
+
.menu-body{display:flex;flex-direction:column;gap:10px;margin-top:8px;padding:12px;border:1px solid var(--line);border-radius:14px;background:var(--card,transparent)}
|
| 8 |
+
.over{margin:12px auto;text-align:center;max-width:520px}.over h2{margin:0;font-size:1.5em}
|
| 9 |
+
.big-num{font-size:3.2em;font-weight:900;margin:0;line-height:1.1;letter-spacing:-.02em}
|
| 10 |
+
.btn.big{font-size:1.15em;padding:14px 34px;min-height:52px;margin:8px 0}
|
| 11 |
+
.more-res{margin-top:6px;text-align:left}.more-res summary{cursor:pointer;color:var(--muted)}
|
| 12 |
+
.looks{justify-content:center;margin:0;flex-wrap:wrap}
|
| 13 |
+
.looks button{width:38px;height:38px;border-radius:50%;border:3px solid var(--line);cursor:pointer;position:relative}
|
| 14 |
+
.looks button[aria-pressed=true]{border-color:var(--ink)}
|
| 15 |
+
.looks button.locked::after{content:"🔒";position:absolute;right:-6px;bottom:-6px;font-size:12px}
|
| 16 |
+
.grid{font-size:20px;letter-spacing:1px;margin:4px 0 10px;white-space:pre-line;line-height:1.4}
|
| 17 |
+
.seo ol,.seo ul{padding-left:1.2em}.seo li{margin:.25em 0}
|
| 18 |
+
@media (max-width:520px){.wrap{padding-left:10px;padding-right:10px}header.top{margin-bottom:2px}.headline h1{font-size:1.5em}}
|
| 19 |
+
#up-btn.glow{background:linear-gradient(135deg,#FFB547,#FF6A3D);color:#11141B;border-color:transparent;animation:upg 1.6s ease-in-out infinite}
|
| 20 |
+
@keyframes upg{50%{box-shadow:0 0 0 6px rgba(255,140,60,.18)}}
|
| 21 |
+
@media (prefers-reduced-motion:reduce){#up-btn.glow{animation:none}}
|
| 22 |
+
.upgrades{margin:12px auto;max-width:520px}.upgrades h2{margin:0 0 8px;display:flex;justify-content:space-between;align-items:baseline}
|
| 23 |
+
.up{display:grid;grid-template-columns:40px 1fr auto;gap:10px;align-items:center;padding:8px 0;border-bottom:1px solid var(--line)}
|
| 24 |
+
.up-i{font-size:24px;width:40px;height:40px;display:grid;place-items:center;border-radius:12px;background:var(--chip)}
|
| 25 |
+
.up-t b{display:block}.up-t small{color:var(--muted)}.up-t b small{font-weight:600}
|
| 26 |
+
.up .btn[disabled]{opacity:.45;cursor:not-allowed}
|
| 27 |
+
.stage>.panel{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:min(90%,420px);max-height:92%;overflow:auto;margin:0;z-index:5;background:var(--card-solid,#fff);border-radius:22px;box-shadow:0 10px 40px rgba(17,20,27,.22);animation:pin .22s ease-out}
|
| 28 |
+
@keyframes pin{from{opacity:0;transform:translate(-50%,-46%) scale(.96)}}
|
| 29 |
+
@media (prefers-reduced-motion:reduce){.stage>.panel{animation:none}}
|
sw.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// CyberMax game service worker: the game works offline after the first visit. Cache-first for the game's own files,
|
| 2 |
+
// network-first for the page itself (so updates arrive), never caches API calls or other sites. (c) 2026 CyberMax.
|
| 3 |
+
const GAME = 'delvewren';
|
| 4 |
+
const CACHE = `cmx-${GAME}-61816957b4`;
|
| 5 |
+
const FILES = ["index.html", "arena.js", "cmx.js", "core.js", "fun.css", "funpass.js", "game.js", "icon-192.png", "icon-512.png", "icon-maskable.png", "icon.svg", "index.html", "manifest.webmanifest", "offer.js", "style.css"];
|
| 6 |
+
|
| 7 |
+
self.addEventListener('install', (e) => {
|
| 8 |
+
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(FILES)).then(() => self.skipWaiting()));
|
| 9 |
+
});
|
| 10 |
+
self.addEventListener('activate', (e) => {
|
| 11 |
+
e.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter((k) => k.startsWith(`cmx-${GAME}-`) && k !== CACHE).map((k) => caches.delete(k)))).then(() => self.clients.claim()));
|
| 12 |
+
});
|
| 13 |
+
self.addEventListener('fetch', (e) => {
|
| 14 |
+
const u = new URL(e.request.url);
|
| 15 |
+
if (e.request.method !== 'GET' || u.origin !== location.origin || !u.pathname.startsWith(new URL(self.registration.scope).pathname)) return;
|
| 16 |
+
if (e.request.mode === 'navigate') {
|
| 17 |
+
e.respondWith(fetch(e.request).then((r) => { const c = r.clone(); caches.open(CACHE).then((x) => x.put(u.pathname, c)); return r; })
|
| 18 |
+
.catch(() => caches.match(u.pathname).then((r) => r || caches.match('index.html'))));
|
| 19 |
+
return;
|
| 20 |
+
}
|
| 21 |
+
e.respondWith(caches.match(e.request, { ignoreSearch: true }).then((r) => r || fetch(e.request).then((res) => {
|
| 22 |
+
if (res.ok) { const c = res.clone(); caches.open(CACHE).then((x) => x.put(e.request, c)); }
|
| 23 |
+
return res;
|
| 24 |
+
})));
|
| 25 |
+
});
|