纠正仓库内容为衍生项目,标明 campaign-200-r2 最新版

This commit is contained in:
toshiocn
2026-10-19 16:56:31 +08:00
parent a492c5b80e
commit fdca4f67ea
1396 changed files with 392768 additions and 19530 deletions
+25
View File
@@ -0,0 +1,25 @@
from pathlib import Path
root=Path(r'G:\项目\NumberSwipe-Variants\campaign-50')
p=root/'tools/build.mjs';s=p.read_text(encoding='utf-8-sig');a=s.index('const html=`');b=s.index('fs.writeFileSync(path.join(root,\'index.html\')',a)
s=s[:a]+'''const html=`<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="theme-color" content="#ffffff"><title>数字一笔 · 50关DEMO</title><style>${css}</style></head><body><div id="app">
<section id="screen-select" class="screen"><header class="select-header"><h1 id="title">数字一笔</h1><p class="sub">50关DEMO · 一笔走遍每一格</p><div class="overall"><div class="overall-bar"><i id="overall-fill"></i></div><span id="progress" class="overall-text">0 / 50</span></div></header><div id="pack-list" class="pack-list"></div><button id="btn-continue" class="primary">继续</button><footer class="select-footer"><a href="../index.html" class="chip">原型入口</a><button id="btn-feedback" class="chip">试玩反馈</button></footer></section>
<section id="screen-play" class="screen hidden"><header class="topbar"><button id="btn-back" class="icon" aria-label="返回选关"><svg viewBox="0 0 24 24" width="26" height="26" aria-hidden="true"><path d="M15 5l-7 7 7 7" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg></button><div class="level-info"><div id="position" class="level-title"></div><div id="level-sub" class="level-sub"></div></div><div id="remaining" class="remaining" aria-live="polite"><svg class="remaining-icon tile" viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><rect x="4" y="4" width="16" height="16" rx="4.5" fill="none" stroke="currentColor" stroke-width="2.4"/></svg><svg class="remaining-icon check" viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" fill="none" stroke="currentColor" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round"/></svg><span id="remaining-n">0</span></div></header><div id="level-progress" class="level-progress" aria-hidden="true"></div><div id="caption" class="caption"></div><div id="constraints" aria-label="当前规则"></div><div id="board-wrap" class="board-wrap"><canvas id="board" aria-label="拖动或点按共边格画路"></canvas></div><h2 id="goal" class="sr-only"></h2><p class="gesture-help">按住滑动连线 · 点已走格回退</p><footer class="bottombar"><button id="restart" class="action"><svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M4 12a8 8 0 1 0 2.5-5.8M4 4v5h5" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg><span>重开</span></button><button id="undo" class="action"><svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M9 5l-5 5 5 5M4 10h10a6 6 0 0 1 0 12" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg><span>撤销</span></button><button id="hint" class="action"><svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M5 19v-7a4 4 0 0 1 4-4h10m-4-4 4 4-4 4" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg><span>指路</span></button></footer><button id="next" class="primary next-overlay" hidden>下一关 →</button><button id="btn-rules" class="rules-button">规则</button></section>
<div id="status" class="toast" role="status" aria-live="polite"></div>
<div id="rules-sheet" class="sheet-backdrop" hidden><section class="sheet" role="dialog" aria-label="本关规则"><h2>本关规则</h2><p id="rule-text"></p><div class="sheet-actions"><button id="close-rules" class="action">返回游戏</button></div></section></div>
<div id="feedback-sheet" class="sheet-backdrop" hidden><section class="sheet" role="dialog" aria-label="试玩反馈"><h2>试玩反馈</h2><p>记下有趣、枯燥、太难或规则不清楚的关卡,导出记录后用于调整。</p><textarea id="reasoning" aria-label="本关反馈" placeholder="例如:第18关有趣;第24关太难……"></textarea><div class="sheet-actions"><button id="close-feedback" class="action">关闭</button><button id="export" class="primary">导出全部记录</button></div></section></div>
</div><script>const PACK=${JSON.stringify(pack).replaceAll('<','\\\\u003c')};\\n${rules}\\n${ui}</script></body></html>`;
''' +s[b:]
p.write_text(s,encoding='utf-8')
p=root/'ui.mjs';s=p.read_text(encoding='utf-8').replace('(height-20)/(ymax-ymin)','(height-20-height*.06)/(ymax-ymin)');p.write_text(s,encoding='utf-8')
p=root/'tests/ui.test.mjs';s=p.read_text(encoding='utf-8-sig')
s=s.replace("this.value='';", "this.value='';this.style={};this.className='';")
s=s.replace("lineTo(x,y){this.p.push([x,y]);},closePath()", "lineTo(x,y){this.p.push([x,y]);},quadraticCurveTo(cx,cy,x,y){this.p.push([x,y]);},closePath()")
s=s.replace("setTimeout:f=>f()", "setTimeout:f=>f(),clearTimeout(){}")
s=s.replace("get('difficulties').children[ch].click();get('levels').children[(n-1)%10].click();", "get('pack-list').children[ch].children[1].children[(n-1)%10].click();")
s=s.replace("ui.get('difficulties').children.length,5", "ui.get('pack-list').children.length,5")
s=s.replace("ui.get('levels').children.length,10", "ui.get('pack-list').children[Math.floor((n-1)/10)].children[1].children.length,10")
s=s.replace("ui.get('remaining').textContent,'完成 ✓'", "ui.get('remaining-n').textContent,'完成'")
s=s.replace("/1\\/50/", "/1\\s*\\/\\s*50/")
s+='''\ntest('original project select/play screens, progress segments and rule sheet',()=>{const ui=boot();assert.equal(ui.snapshot().screen,'select');ui.get('btn-continue').click();assert.equal(ui.snapshot().screen,'play');assert.equal(ui.get('level-progress').children.length,10);ui.get('btn-rules').click();assert.equal(ui.get('rules-sheet').hidden,false);ui.get('close-rules').click();assert.equal(ui.get('rules-sheet').hidden,true);ui.get('btn-back').click();assert.equal(ui.snapshot().screen,'select');ui.select(22);assert.equal(ui.snapshot().screen,'play');assert.equal(ui.get('position').textContent,'3-2');});
'''
p.write_text(s,encoding='utf-8')