theme: adopt the SCORPIOX BOT theme (v1.0.1) + SCORPIOX BOT casing
- src/bot_theme_plugin.h: bot tokens (trimmed bot_theme.h), prepaint order ?theme= -> localStorage.bot_theme -> prefers-color-scheme, sx-theme listener + sx-theme-request, embed-hidden toggle. - private palette deleted; legacy var names alias the bot tokens. - ScorpioX Bot -> SCORPIOX BOT across source, README, plugin.json, Makefile. - tests/run.sh pins the tokens, the handoff and the removed palette.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-12 04:29:57
Commit8695c414
Parents500ae48a
Changed files
Makefile+1−1■■
README.md+1−1■■
plugin.json+1−1■■
release-dist.sh+2−2■■■■
src/plugin_tetris_3d.c+2−2■■■■
src/ui_html.h+32−13■■■■■
tests/run.sh+19−9■■■■■
7 files+58−29
Diff
Makefile+1−1■■
index 59f1c9d..b289bd7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
1-# plugin_tetris_3d - ScorpioX Bot open-source 3D block game
1+# plugin_tetris_3d - SCORPIOX BOT open-source 3D block game
22 #
33 # Targets:
44 # make native build -> ./plugin_tetris_3d
README.md+1−1■■
index d738f4b..4f7b9dc 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
11 # plugin_tetris_3d
22
3-A 3D block-stacking puzzle game for a ScorpioX Bot node — a single clean-room C99
3+A 3D block-stacking puzzle game for a SCORPIOX BOT node — a single clean-room C99
44 binary, MIT licensed, with no dependency beyond libc.
55
66 It serves a complete game UI: isometric cubes with real depth and shading,
plugin.json+1−1■■
index 5742df5..9b8a0d3 100644
--- a/plugin.json
+++ b/plugin.json
@@ -2,7 +2,7 @@
22 "slug": "tetris-3d",
33 "id": "plugin_tetris_3d",
44 "title": "3D Block Puzzle Game",
5- "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",
5+ "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",
66 "category": "utilities",
77 "license": "MIT",
88 "capabilities": ["local_filesystem_write"],
release-dist.sh+2−2■■■■
index 5db98bb..4412b5d 100755
--- a/release-dist.sh
+++ b/release-dist.sh
@@ -31,7 +31,7 @@ set -euo pipefail
3131
3232 SLUG="tetris-3d"
3333 ID="plugin_tetris_3d"
34-VERSION="1.0.0"
34+VERSION="1.0.1"
3535 DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins"
3636
3737 ROOT="$(cd "$(dirname "$0")" && pwd)"
@@ -224,7 +224,7 @@ target_meta() { # target_meta <key> <file> <format> <relpath>
224224 printf ' "name": "tetris",\n'
225225 printf ' "desc": "3D block game",\n'
226226 printf ' "title": "3D Block Puzzle Game",\n'
227- printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n'
227+ printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n'
228228 printf ' "category": "utilities",\n'
229229 printf ' "version": "%s",\n' "$VERSION"
230230 printf ' "license": "MIT",\n'
src/plugin_tetris_3d.c+2−2■■■■
index 00a217d..b6ae3c7 100644
--- a/src/plugin_tetris_3d.c
+++ b/src/plugin_tetris_3d.c
@@ -1,5 +1,5 @@
11 /*
2- * plugin_tetris_3d - ScorpioX Bot open-source 3D block game (clean room)
2+ * plugin_tetris_3d - SCORPIOX BOT open-source 3D block game (clean room)
33 *
44 * A single dependency-free C99 binary that serves THREE modes:
55 * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata
@@ -59,7 +59,7 @@
5959 #define PLUGIN_ID "plugin_tetris_3d"
6060 #define PLUGIN_NAME "tetris"
6161 #define PLUGIN_DESC "3D block game"
62-#define PLUGIN_VER "1.0.0"
62+#define PLUGIN_VER "1.0.1"
6363
6464 #define MAX_SCORES 10
6565 #define PATH_SZ 1024
src/ui_html.h+32−13■■■■■
index 0646853..6e377e1 100644
--- a/src/ui_html.h
+++ b/src/ui_html.h
@@ -7,11 +7,27 @@ static const char *UI_HTML =
77 "<html lang=\"en\"><head><meta charset=\"utf-8\">\n"
88 "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\">\n"
99 "<title>tetris</title>\n"
10+ "<script>(function(){var t='';"
11+ "try{var m=/[?&]theme=(light|dark)/.exec(location.search);if(m)t=m[1];}catch(e){}"
12+ "if(!t){try{var s=localStorage.getItem('bot_theme');if(s==='light'||s==='dark')t=s;}catch(e){}}"
13+ "if(!t){try{t=(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches)?'light':'dark';}catch(e){t='dark';}}"
14+ "document.documentElement.setAttribute('data-theme',t);"
15+ "try{if(/[?&]embed=(1|true)(&|$)/.test(location.search))document.documentElement.classList.add('embedded');}catch(e){}"
16+ "try{localStorage.setItem('bot_theme',t);}catch(e){}"
17+ "})();</script>\n"
1018 "<style>\n"
11- ":root{color-scheme:dark light;--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11);--accent:#0a84ff;--good:#30d158;--warn:#ff9f0a;--radius:14px}\n"
12- "@media(prefers-color-scheme:light){:root{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}}\n"
13- "html[data-theme=\"dark\"]{--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11)}\n"
14- "html[data-theme=\"light\"]{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}\n"
19+ ":root{color-scheme:dark;--bg:#000000;--bg-2:#08080a;--bg-card:#1c1c1e;"
20+ "--surface-2:rgba(255,255,255,.06);--line:rgba(255,255,255,.08);--text:#f5f5f7;--text-2:#86868b;"
21+ "--blue:#0a84ff;--green:#30d158;--orange:#ff9f0a;--red:#ff453a;--purple:#bf5af2;--teal:#64d2ff;--yellow:#ffd60a;"
22+ "--radius:14px;--panel:var(--bg-card);--panel-solid:var(--bg-card);--muted:var(--text-2);--accent:var(--blue);--good:var(--green);--warn:var(--orange)}"
23+ "@media (prefers-color-scheme:light){html:not([data-theme=dark]){--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;"
24+ "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;"
25+ "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}}"
26+ "html[data-theme=light]{--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;"
27+ "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;"
28+ "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}"
29+ "html{color-scheme:dark}html[data-theme=dark]{color-scheme:dark}"
30+ "html.embedded #btnTheme{display:none!important}"
1531 "*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}\n"
1632 "html,body{margin:0;padding:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Inter,system-ui,sans-serif}\n"
1733 "#app{position:relative;width:100%;height:100%;display:flex;flex-direction:column}\n"
@@ -133,25 +149,28 @@ static const char *UI_HTML =
133149 " document.getElementById('btnTheme').textContent =\n"
134150 " (document.documentElement.getAttribute('data-theme') === 'light') ? 'Dark' : 'Light';\n"
135151 "}\n"
136- "applyTheme(localStorage.getItem(THEME_KEY) || q.get('theme') || '');\n"
152+ "/* the bot posts sx-theme into the iframe; follow it, and ask once at start */\n"
153+ "window.addEventListener('message', function(e){var d=e&&e.data;"
154+ "if(d&&d.type==='sx-theme') applyTheme(d.theme);});\n"
155+ "try{if(window.parent&&window.parent!==window)window.parent.postMessage({type:'sx-theme-request'},'*');}catch(e){}\n"
137156 "document.getElementById('btnTheme').addEventListener('click', function(){\n"
138157 " var cur = document.documentElement.getAttribute('data-theme');\n"
139158 " if (!cur) cur = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';\n"
140159 " var next = cur === 'light' ? 'dark' : 'light';\n"
141- " localStorage.setItem(THEME_KEY, next);\n"
160+ " localStorage.setItem(THEME_KEY, next);try{localStorage.setItem('bot_theme',next);}catch(e){}\n"
142161 " applyTheme(next);\n"
143162 "});\n"
144163 "\n"
145164 "/* ---------------------------------------------------------------- board */\n"
146165 "var COLS = 10, ROWS = 20, DEPTH = 3;\n"
147166 "var SHAPES = [\n"
148- " { k:'I', c:'#22d3ee', b:[[1,1,1,1]] },\n"
149- " { k:'J', c:'#3b82f6', b:[[1,0,0],[1,1,1]] },\n"
150- " { k:'L', c:'#f59e0b', b:[[0,0,1],[1,1,1]] },\n"
151- " { k:'O', c:'#facc15', b:[[1,1],[1,1]] },\n"
152- " { k:'S', c:'#22c55e', b:[[0,1,1],[1,1,0]] },\n"
153- " { k:'T', c:'#a855f7', b:[[0,1,0],[1,1,1]] },\n"
154- " { k:'Z', c:'#ef4444', b:[[1,1,0],[0,1,1]] }\n"
167+ " { k:'I', c:'#64d2ff', b:[[1,1,1,1]] },\n"
168+ " { k:'J', c:'#0a84ff', b:[[1,0,0],[1,1,1]] },\n"
169+ " { k:'L', c:'#ff9f0a', b:[[0,0,1],[1,1,1]] },\n"
170+ " { k:'O', c:'#ffd60a', b:[[1,1],[1,1]] },\n"
171+ " { k:'S', c:'#30d158', b:[[0,1,1],[1,1,0]] },\n"
172+ " { k:'T', c:'#bf5af2', b:[[0,1,0],[1,1,1]] },\n"
173+ " { k:'Z', c:'#ff453a', b:[[1,1,0],[0,1,1]] }\n"
155174 "];\n"
156175 "\n"
157176 "var grid = []; /* grid[y][x] = color string or 0 */\n"
tests/run.sh+19−9■■■■■
index 5f110f4..2a4bae1 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -63,7 +63,7 @@ check "meta desc length <= 13" "$(python3 -c 'print(len("3D block game"))')" "13
6363 M2=$(SX_PLUGIN_META=1 "$BIN")
6464 check "SX_PLUGIN_META equals --meta" "$M2" "$M"
6565 check "meta has exactly two keys" "$(jget "$M" 'sorted(d.keys())')" "['desc', 'name']"
66-check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.0"
66+check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.1"
6767 check "--meta needs no auth" "$(BOT_PASSWORD=secret "$BIN" --meta)" "$M"
6868
6969 echo "== score API"
@@ -73,7 +73,7 @@ check "empty store ok" "$(jget "$J" 'd["ok"]')" "True"
7373 check "empty store highscore" "$(jget "$J" 'd["highscore"]')" "0"
7474 check "empty store list" "$(jget "$J" 'd["scores"]')" "[]"
7575 check "plugin id" "$(jget "$J" 'd["plugin"]')" "plugin_tetris_3d"
76-check "version" "$(jget "$J" 'd["version"]')" "1.0.0"
76+check "version" "$(jget "$J" 'd["version"]')" "1.0.1"
7777
7878 J=$(json 'action=save_score&val=1200')
7979 check "save 1200 ok" "$(jget "$J" 'd["ok"]')" "True"
@@ -141,19 +141,19 @@ check "unwritable store error name" "$(jget "$(cat "$TMP/unw.json")" 'd["erro
141141
142142 echo "== node auth"
143143 hdr() { head -1 | tr -d '\r'; }
144-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW "$BIN" | hdr)
144+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw "$BIN" | hdr)
145145 check "401 without credentials" "$A" "Status: 401 Unauthorized"
146-A=$(QUERY_STRING='action=scores&pwd=TESTPW' BOT_PASSWORD=TESTPW "$BIN" | tail -1)
146+A=$(QUERY_STRING='action=scores&pwd=testpw' BOT_PASSWORD=testpw "$BIN" | tail -1)
147147 check "pwd query accepted" "$(jget "$A" 'd["ok"]')" "True"
148-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | tail -1)
148+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | tail -1)
149149 check "X-Bot-Password accepted" "$(jget "$A" 'd["ok"]')" "True"
150-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1)
150+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1)
151151 check "Bearer accepted" "$(jget "$A" 'd["ok"]')" "True"
152-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr)
152+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr)
153153 check "wrong Bearer rejected" "$A" "Status: 401 Unauthorized"
154-A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW "$BIN" | hdr)
154+A=$(QUERY_STRING='' BOT_PASSWORD=testpw "$BIN" | hdr)
155155 check "html is gated too" "$A" "Status: 401 Unauthorized"
156-A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | hdr)
156+A=$(QUERY_STRING='' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | hdr)
157157 check "html served with password" "$A" "Content-Type: text/html; charset=utf-8"
158158
159159 echo "== html"
@@ -173,6 +173,16 @@ has "theme toggle" "$TMP/html.txt" 'id="btnTheme"'
173173 has "dark media query" "$TMP/html.txt" 'prefers-color-scheme'
174174 has "explicit dark theme" "$TMP/html.txt" 'data-theme="dark"'
175175 has "explicit light theme" "$TMP/html.txt" 'data-theme="light"'
176+has "theme reads ?theme=" "$TMP/html.txt" 'theme=(light|dark)'
177+has "theme listens sx-theme" "$TMP/html.txt" "d.type==='sx-theme'"
178+has "theme asks the host" "$TMP/html.txt" "sx-theme-request"
179+has "bot token --bg-card" "$TMP/html.txt" '--bg-card'
180+has "bot token --surface-2" "$TMP/html.txt" '--surface-2'
181+had_toggle_embed=$(grep -c 'html.embedded #btnTheme' "$TMP/html.txt")
182+check "toggle hidden when embedded ($had_toggle_embed)" "$had_toggle_embed" "1"
183+not_has "no private palette 08080b" "$TMP/html.txt" '08080b'
184+not_has "no private palette eceef3" "$TMP/html.txt" 'eceef3'
185+not_has "no retired brand casing" "$TMP/html.txt" 'Scorpio'"X Bot"
176186 has "touch controls pad" "$TMP/html.txt" 'id="pad"'
177187 has "left button" "$TMP/html.txt" 'id="bLeft"'
178188 has "rotate button" "$TMP/html.txt" 'id="bRot"'
179189
Makefile+1−1■■
index 59f1c9d..b289bd7 100644index 59f1c9d..b289bd7 100644
--- a/Makefile--- a/Makefile
+++ b/Makefile+++ b/Makefile
@@ -1,4 +1,4 @@@@ -1,4 +1,4 @@
1-# plugin_tetris_3d - ScorpioX Bot open-source 3D block game1+# plugin_tetris_3d - SCORPIOX BOT open-source 3D block game
2 #2 #
3 # Targets:3 # Targets:
4 # make native build -> ./plugin_tetris_3d4 # make native build -> ./plugin_tetris_3d
README.md+1−1■■
index d738f4b..4f7b9dc 100644index d738f4b..4f7b9dc 100644
--- a/README.md--- a/README.md
+++ b/README.md+++ b/README.md
@@ -1,6 +1,6 @@@@ -1,6 +1,6 @@
1 # plugin_tetris_3d1 # plugin_tetris_3d
2 2
3-A 3D block-stacking puzzle game for a ScorpioX Bot node — a single clean-room C993+A 3D block-stacking puzzle game for a SCORPIOX BOT node — a single clean-room C99
4 binary, MIT licensed, with no dependency beyond libc.4 binary, MIT licensed, with no dependency beyond libc.
5 5
6 It serves a complete game UI: isometric cubes with real depth and shading,6 It serves a complete game UI: isometric cubes with real depth and shading,
plugin.json+1−1■■
index 5742df5..9b8a0d3 100644index 5742df5..9b8a0d3 100644
--- a/plugin.json--- a/plugin.json
+++ b/plugin.json+++ b/plugin.json
@@ -2,7 +2,7 @@@@ -2,7 +2,7 @@
2 "slug": "tetris-3d",2 "slug": "tetris-3d",
3 "id": "plugin_tetris_3d",3 "id": "plugin_tetris_3d",
4 "title": "3D Block Puzzle Game",4 "title": "3D Block Puzzle Game",
5- "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",5+ "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",
6 "category": "utilities",6 "category": "utilities",
7 "license": "MIT",7 "license": "MIT",
8 "capabilities": ["local_filesystem_write"],8 "capabilities": ["local_filesystem_write"],
release-dist.sh+2−2■■■■
index 5db98bb..4412b5d 100755index 5db98bb..4412b5d 100755
--- a/release-dist.sh--- a/release-dist.sh
+++ b/release-dist.sh+++ b/release-dist.sh
@@ -31,7 +31,7 @@ set -euo pipefail@@ -31,7 +31,7 @@ set -euo pipefail
31 31
32 SLUG="tetris-3d"32 SLUG="tetris-3d"
33 ID="plugin_tetris_3d"33 ID="plugin_tetris_3d"
34-VERSION="1.0.0"34+VERSION="1.0.1"
35 DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins"35 DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins"
36 36
37 ROOT="$(cd "$(dirname "$0")" && pwd)"37 ROOT="$(cd "$(dirname "$0")" && pwd)"
@@ -224,7 +224,7 @@ target_meta() { # target_meta <key> <file> <format> <relpath>@@ -224,7 +224,7 @@ target_meta() { # target_meta <key> <file> <format> <relpath>
224 printf ' "name": "tetris",\n'224 printf ' "name": "tetris",\n'
225 printf ' "desc": "3D block game",\n'225 printf ' "desc": "3D block game",\n'
226 printf ' "title": "3D Block Puzzle Game",\n'226 printf ' "title": "3D Block Puzzle Game",\n'
227- printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n'227+ printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n'
228 printf ' "category": "utilities",\n'228 printf ' "category": "utilities",\n'
229 printf ' "version": "%s",\n' "$VERSION"229 printf ' "version": "%s",\n' "$VERSION"
230 printf ' "license": "MIT",\n'230 printf ' "license": "MIT",\n'
src/plugin_tetris_3d.c+2−2■■■■
index 00a217d..b6ae3c7 100644index 00a217d..b6ae3c7 100644
--- a/src/plugin_tetris_3d.c--- a/src/plugin_tetris_3d.c
+++ b/src/plugin_tetris_3d.c+++ b/src/plugin_tetris_3d.c
@@ -1,5 +1,5 @@@@ -1,5 +1,5 @@
1 /*1 /*
2- * plugin_tetris_3d - ScorpioX Bot open-source 3D block game (clean room)2+ * plugin_tetris_3d - SCORPIOX BOT open-source 3D block game (clean room)
3 *3 *
4 * A single dependency-free C99 binary that serves THREE modes:4 * A single dependency-free C99 binary that serves THREE modes:
5 * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata5 * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata
@@ -59,7 +59,7 @@@@ -59,7 +59,7 @@
59 #define PLUGIN_ID "plugin_tetris_3d"59 #define PLUGIN_ID "plugin_tetris_3d"
60 #define PLUGIN_NAME "tetris"60 #define PLUGIN_NAME "tetris"
61 #define PLUGIN_DESC "3D block game"61 #define PLUGIN_DESC "3D block game"
62-#define PLUGIN_VER "1.0.0"62+#define PLUGIN_VER "1.0.1"
63 63
64 #define MAX_SCORES 1064 #define MAX_SCORES 10
65 #define PATH_SZ 102465 #define PATH_SZ 1024
src/ui_html.h+32−13■■■■■
index 0646853..6e377e1 100644index 0646853..6e377e1 100644
--- a/src/ui_html.h--- a/src/ui_html.h
+++ b/src/ui_html.h+++ b/src/ui_html.h
@@ -7,11 +7,27 @@ static const char *UI_HTML =@@ -7,11 +7,27 @@ static const char *UI_HTML =
7 "<html lang=\"en\"><head><meta charset=\"utf-8\">\n"7 "<html lang=\"en\"><head><meta charset=\"utf-8\">\n"
8 "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\">\n"8 "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\">\n"
9 "<title>tetris</title>\n"9 "<title>tetris</title>\n"
10+ "<script>(function(){var t='';"
11+ "try{var m=/[?&]theme=(light|dark)/.exec(location.search);if(m)t=m[1];}catch(e){}"
12+ "if(!t){try{var s=localStorage.getItem('bot_theme');if(s==='light'||s==='dark')t=s;}catch(e){}}"
13+ "if(!t){try{t=(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches)?'light':'dark';}catch(e){t='dark';}}"
14+ "document.documentElement.setAttribute('data-theme',t);"
15+ "try{if(/[?&]embed=(1|true)(&|$)/.test(location.search))document.documentElement.classList.add('embedded');}catch(e){}"
16+ "try{localStorage.setItem('bot_theme',t);}catch(e){}"
17+ "})();</script>\n"
10 "<style>\n"18 "<style>\n"
11- ":root{color-scheme:dark light;--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11);--accent:#0a84ff;--good:#30d158;--warn:#ff9f0a;--radius:14px}\n"19+ ":root{color-scheme:dark;--bg:#000000;--bg-2:#08080a;--bg-card:#1c1c1e;"
12- "@media(prefers-color-scheme:light){:root{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}}\n"20+ "--surface-2:rgba(255,255,255,.06);--line:rgba(255,255,255,.08);--text:#f5f5f7;--text-2:#86868b;"
13- "html[data-theme=\"dark\"]{--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11)}\n"21+ "--blue:#0a84ff;--green:#30d158;--orange:#ff9f0a;--red:#ff453a;--purple:#bf5af2;--teal:#64d2ff;--yellow:#ffd60a;"
14- "html[data-theme=\"light\"]{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}\n"22+ "--radius:14px;--panel:var(--bg-card);--panel-solid:var(--bg-card);--muted:var(--text-2);--accent:var(--blue);--good:var(--green);--warn:var(--orange)}"
23+ "@media (prefers-color-scheme:light){html:not([data-theme=dark]){--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;"
24+ "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;"
25+ "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}}"
26+ "html[data-theme=light]{--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;"
27+ "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;"
28+ "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}"
29+ "html{color-scheme:dark}html[data-theme=dark]{color-scheme:dark}"
30+ "html.embedded #btnTheme{display:none!important}"
15 "*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}\n"31 "*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}\n"
16 "html,body{margin:0;padding:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Inter,system-ui,sans-serif}\n"32 "html,body{margin:0;padding:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Inter,system-ui,sans-serif}\n"
17 "#app{position:relative;width:100%;height:100%;display:flex;flex-direction:column}\n"33 "#app{position:relative;width:100%;height:100%;display:flex;flex-direction:column}\n"
@@ -133,25 +149,28 @@ static const char *UI_HTML =@@ -133,25 +149,28 @@ static const char *UI_HTML =
133 " document.getElementById('btnTheme').textContent =\n"149 " document.getElementById('btnTheme').textContent =\n"
134 " (document.documentElement.getAttribute('data-theme') === 'light') ? 'Dark' : 'Light';\n"150 " (document.documentElement.getAttribute('data-theme') === 'light') ? 'Dark' : 'Light';\n"
135 "}\n"151 "}\n"
136- "applyTheme(localStorage.getItem(THEME_KEY) || q.get('theme') || '');\n"152+ "/* the bot posts sx-theme into the iframe; follow it, and ask once at start */\n"
153+ "window.addEventListener('message', function(e){var d=e&&e.data;"
154+ "if(d&&d.type==='sx-theme') applyTheme(d.theme);});\n"
155+ "try{if(window.parent&&window.parent!==window)window.parent.postMessage({type:'sx-theme-request'},'*');}catch(e){}\n"
137 "document.getElementById('btnTheme').addEventListener('click', function(){\n"156 "document.getElementById('btnTheme').addEventListener('click', function(){\n"
138 " var cur = document.documentElement.getAttribute('data-theme');\n"157 " var cur = document.documentElement.getAttribute('data-theme');\n"
139 " if (!cur) cur = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';\n"158 " if (!cur) cur = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';\n"
140 " var next = cur === 'light' ? 'dark' : 'light';\n"159 " var next = cur === 'light' ? 'dark' : 'light';\n"
141- " localStorage.setItem(THEME_KEY, next);\n"160+ " localStorage.setItem(THEME_KEY, next);try{localStorage.setItem('bot_theme',next);}catch(e){}\n"
142 " applyTheme(next);\n"161 " applyTheme(next);\n"
143 "});\n"162 "});\n"
144 "\n"163 "\n"
145 "/* ---------------------------------------------------------------- board */\n"164 "/* ---------------------------------------------------------------- board */\n"
146 "var COLS = 10, ROWS = 20, DEPTH = 3;\n"165 "var COLS = 10, ROWS = 20, DEPTH = 3;\n"
147 "var SHAPES = [\n"166 "var SHAPES = [\n"
148- " { k:'I', c:'#22d3ee', b:[[1,1,1,1]] },\n"167+ " { k:'I', c:'#64d2ff', b:[[1,1,1,1]] },\n"
149- " { k:'J', c:'#3b82f6', b:[[1,0,0],[1,1,1]] },\n"168+ " { k:'J', c:'#0a84ff', b:[[1,0,0],[1,1,1]] },\n"
150- " { k:'L', c:'#f59e0b', b:[[0,0,1],[1,1,1]] },\n"169+ " { k:'L', c:'#ff9f0a', b:[[0,0,1],[1,1,1]] },\n"
151- " { k:'O', c:'#facc15', b:[[1,1],[1,1]] },\n"170+ " { k:'O', c:'#ffd60a', b:[[1,1],[1,1]] },\n"
152- " { k:'S', c:'#22c55e', b:[[0,1,1],[1,1,0]] },\n"171+ " { k:'S', c:'#30d158', b:[[0,1,1],[1,1,0]] },\n"
153- " { k:'T', c:'#a855f7', b:[[0,1,0],[1,1,1]] },\n"172+ " { k:'T', c:'#bf5af2', b:[[0,1,0],[1,1,1]] },\n"
154- " { k:'Z', c:'#ef4444', b:[[1,1,0],[0,1,1]] }\n"173+ " { k:'Z', c:'#ff453a', b:[[1,1,0],[0,1,1]] }\n"
155 "];\n"174 "];\n"
156 "\n"175 "\n"
157 "var grid = []; /* grid[y][x] = color string or 0 */\n"176 "var grid = []; /* grid[y][x] = color string or 0 */\n"
tests/run.sh+19−9■■■■■
index 5f110f4..2a4bae1 100755index 5f110f4..2a4bae1 100755
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -63,7 +63,7 @@ check "meta desc length <= 13" "$(python3 -c 'print(len("3D block game"))')" "13@@ -63,7 +63,7 @@ check "meta desc length <= 13" "$(python3 -c 'print(len("3D block game"))')" "13
63 M2=$(SX_PLUGIN_META=1 "$BIN")63 M2=$(SX_PLUGIN_META=1 "$BIN")
64 check "SX_PLUGIN_META equals --meta" "$M2" "$M"64 check "SX_PLUGIN_META equals --meta" "$M2" "$M"
65 check "meta has exactly two keys" "$(jget "$M" 'sorted(d.keys())')" "['desc', 'name']"65 check "meta has exactly two keys" "$(jget "$M" 'sorted(d.keys())')" "['desc', 'name']"
66-check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.0"66+check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.1"
67 check "--meta needs no auth" "$(BOT_PASSWORD=secret "$BIN" --meta)" "$M"67 check "--meta needs no auth" "$(BOT_PASSWORD=secret "$BIN" --meta)" "$M"
68 68
69 echo "== score API"69 echo "== score API"
@@ -73,7 +73,7 @@ check "empty store ok" "$(jget "$J" 'd["ok"]')" "True"@@ -73,7 +73,7 @@ check "empty store ok" "$(jget "$J" 'd["ok"]')" "True"
73 check "empty store highscore" "$(jget "$J" 'd["highscore"]')" "0"73 check "empty store highscore" "$(jget "$J" 'd["highscore"]')" "0"
74 check "empty store list" "$(jget "$J" 'd["scores"]')" "[]"74 check "empty store list" "$(jget "$J" 'd["scores"]')" "[]"
75 check "plugin id" "$(jget "$J" 'd["plugin"]')" "plugin_tetris_3d"75 check "plugin id" "$(jget "$J" 'd["plugin"]')" "plugin_tetris_3d"
76-check "version" "$(jget "$J" 'd["version"]')" "1.0.0"76+check "version" "$(jget "$J" 'd["version"]')" "1.0.1"
77 77
78 J=$(json 'action=save_score&val=1200')78 J=$(json 'action=save_score&val=1200')
79 check "save 1200 ok" "$(jget "$J" 'd["ok"]')" "True"79 check "save 1200 ok" "$(jget "$J" 'd["ok"]')" "True"
@@ -141,19 +141,19 @@ check "unwritable store error name" "$(jget "$(cat "$TMP/unw.json")" 'd["erro@@ -141,19 +141,19 @@ check "unwritable store error name" "$(jget "$(cat "$TMP/unw.json")" 'd["erro
141 141
142 echo "== node auth"142 echo "== node auth"
143 hdr() { head -1 | tr -d '\r'; }143 hdr() { head -1 | tr -d '\r'; }
144-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW "$BIN" | hdr)144+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw "$BIN" | hdr)
145 check "401 without credentials" "$A" "Status: 401 Unauthorized"145 check "401 without credentials" "$A" "Status: 401 Unauthorized"
146-A=$(QUERY_STRING='action=scores&pwd=TESTPW' BOT_PASSWORD=TESTPW "$BIN" | tail -1)146+A=$(QUERY_STRING='action=scores&pwd=testpw' BOT_PASSWORD=testpw "$BIN" | tail -1)
147 check "pwd query accepted" "$(jget "$A" 'd["ok"]')" "True"147 check "pwd query accepted" "$(jget "$A" 'd["ok"]')" "True"
148-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | tail -1)148+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | tail -1)
149 check "X-Bot-Password accepted" "$(jget "$A" 'd["ok"]')" "True"149 check "X-Bot-Password accepted" "$(jget "$A" 'd["ok"]')" "True"
150-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1)150+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1)
151 check "Bearer accepted" "$(jget "$A" 'd["ok"]')" "True"151 check "Bearer accepted" "$(jget "$A" 'd["ok"]')" "True"
152-A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr)152+A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr)
153 check "wrong Bearer rejected" "$A" "Status: 401 Unauthorized"153 check "wrong Bearer rejected" "$A" "Status: 401 Unauthorized"
154-A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW "$BIN" | hdr)154+A=$(QUERY_STRING='' BOT_PASSWORD=testpw "$BIN" | hdr)
155 check "html is gated too" "$A" "Status: 401 Unauthorized"155 check "html is gated too" "$A" "Status: 401 Unauthorized"
156-A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | hdr)156+A=$(QUERY_STRING='' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | hdr)
157 check "html served with password" "$A" "Content-Type: text/html; charset=utf-8"157 check "html served with password" "$A" "Content-Type: text/html; charset=utf-8"
158 158
159 echo "== html"159 echo "== html"
@@ -173,6 +173,16 @@ has "theme toggle" "$TMP/html.txt" 'id="btnTheme"'@@ -173,6 +173,16 @@ has "theme toggle" "$TMP/html.txt" 'id="btnTheme"'
173 has "dark media query" "$TMP/html.txt" 'prefers-color-scheme'173 has "dark media query" "$TMP/html.txt" 'prefers-color-scheme'
174 has "explicit dark theme" "$TMP/html.txt" 'data-theme="dark"'174 has "explicit dark theme" "$TMP/html.txt" 'data-theme="dark"'
175 has "explicit light theme" "$TMP/html.txt" 'data-theme="light"'175 has "explicit light theme" "$TMP/html.txt" 'data-theme="light"'
176+has "theme reads ?theme=" "$TMP/html.txt" 'theme=(light|dark)'
177+has "theme listens sx-theme" "$TMP/html.txt" "d.type==='sx-theme'"
178+has "theme asks the host" "$TMP/html.txt" "sx-theme-request"
179+has "bot token --bg-card" "$TMP/html.txt" '--bg-card'
180+has "bot token --surface-2" "$TMP/html.txt" '--surface-2'
181+had_toggle_embed=$(grep -c 'html.embedded #btnTheme' "$TMP/html.txt")
182+check "toggle hidden when embedded ($had_toggle_embed)" "$had_toggle_embed" "1"
183+not_has "no private palette 08080b" "$TMP/html.txt" '08080b'
184+not_has "no private palette eceef3" "$TMP/html.txt" 'eceef3'
185+not_has "no retired brand casing" "$TMP/html.txt" 'Scorpio'"X Bot"
176 has "touch controls pad" "$TMP/html.txt" 'id="pad"'186 has "touch controls pad" "$TMP/html.txt" 'id="pad"'
177 has "left button" "$TMP/html.txt" 'id="bLeft"'187 has "left button" "$TMP/html.txt" 'id="bLeft"'
178 has "rotate button" "$TMP/html.txt" 'id="bRot"'188 has "rotate button" "$TMP/html.txt" 'id="bRot"'
179189