Explorar el Código

feat: 连续空间加长到 2500 层(每章 500)+ 能量谷曲线重设计;平衡/UI 测试脚本与截图

LiuYuYang hace 1 semana
padre
commit
1f1b4a814d

+ 14 - 12
js/config.js

@@ -6,8 +6,10 @@ export const SAVE_KEY = 'worldtree_escape_save_v1';
 export const SAVE_VERSION = 1;
 export const SAVE_VERSION = 1;
 
 
 // ── 主线:逃离室女座空洞(连续空间) ─────────────────────────
 // ── 主线:逃离室女座空洞(连续空间) ─────────────────────────
-// 逃逸进度 = 本轮回“抵达层数 / 1000”,连续流动;六章每 200 层一段,章内没有结算弹窗。
-export const TOTAL_LAYERS = 1000;
+// 逃逸进度 = 本轮回“抵达层数 / TOTAL_LAYERS”,连续流动;六章每 500 层一段,章内没有结算弹窗。
+// 每章 500 层。这个常数同时是“能量谷”的深度标尺:GM(L) 的线性段在 L/Gm 处平滑衔接(Gm = TOTAL×(ENV_STEP−1)/(GM_END−1) ≈ 1.71×TOTAL),
+// 调大 TOTAL 会让回跑段变得更“浅”,因此主曲线参数要跟着一起调(见 tests/balance-sim.mjs)。
+export const TOTAL_LAYERS = 2500;
 export const CHAPTERS = [
 export const CHAPTERS = [
   { idx: 0, short: '地球',     title: '保护地球',     desc: '空洞前沿已越过柯伊伯带,地球是最后一处有生命的声音。' },
   { idx: 0, short: '地球',     title: '保护地球',     desc: '空洞前沿已越过柯伊伯带,地球是最后一处有生命的声音。' },
   { idx: 1, short: '太阳系',   title: '脱离太阳系',   desc: '把整颗星球托进世界树的根系,太阳系成为空洞中的第一枚灯塔。' },
   { idx: 1, short: '太阳系',   title: '脱离太阳系',   desc: '把整颗星球托进世界树的根系,太阳系成为空洞中的第一枚灯塔。' },
@@ -16,7 +18,7 @@ export const CHAPTERS = [
   { idx: 4, short: '本星系群', title: '脱离本星系群', desc: '本星系群的引力潮被抵消,空洞的边界第一次出现在视野里。' },
   { idx: 4, short: '本星系群', title: '脱离本星系群', desc: '本星系群的引力潮被抵消,空洞的边界第一次出现在视野里。' },
   { idx: 5, short: '空洞外',   title: '冲出空洞',     desc: '室女座空洞之外,还有一片未被规则侵蚀的星空。' },
   { idx: 5, short: '空洞外',   title: '冲出空洞',     desc: '室女座空洞之外,还有一片未被规则侵蚀的星空。' },
 ];
 ];
-for (const ch of CHAPTERS) ch.at = ch.idx * 200;   // 每章 200 层
+for (const ch of CHAPTERS) ch.at = ch.idx * 500;   // 每章 500 层
 
 
 /** 当前层数对应的章序号(0..5) */
 /** 当前层数对应的章序号(0..5) */
 export function chapterOf(layer) {
 export function chapterOf(layer) {
@@ -97,10 +99,10 @@ export function canopySkip(level) { return Math.min(SKIP.cap, COST.canopy.per *
 export function canopySpeedMul(level) { return Math.pow(1.08, level || 0); }
 export function canopySpeedMul(level) { return Math.pow(1.08, level || 0); }
 
 
 // 永久乘区(除世界树/遗物外的简单加乘)
 // 永久乘区(除世界树/遗物外的简单加乘)
-export function multCreature(totalLevel) { return 1 + 0.08 * Math.max(0, (totalLevel || 0) - 30); }
+export function multCreature(totalLevel) { return Math.max(1e-6, 1 + 0.08 * Math.max(0, (totalLevel || 0) - 30)); }
 export function multRelic(count) { return Math.pow(1.25, count || 0); }
 export function multRelic(count) { return Math.pow(1.25, count || 0); }
-export function multRebirth(count) { return 1 + 0.10 * (count || 0); }
-export function multExploration(explore) { return 1 + 2 * Math.max(0, explore || 0) / 100; }
+export function multRebirth(count) { return Math.max(1e-6, 1 + 0.10 * (count || 0)); }
+export function multExploration(explore) { return Math.max(1e-6, 1 + 2 * Math.max(0, explore || 0) / 100); }
 
 
 // ── 兵种(常驻推进跑道,持续生效) ──────────────────────────
 // ── 兵种(常驻推进跑道,持续生效) ──────────────────────────
 // 等级 n:升级成本 cost × 1.15^(n−1);技能强度 = 1 + per × n。解锁:上一兵种 ≥3 级。
 // 等级 n:升级成本 cost × 1.15^(n−1);技能强度 = 1 + per × n。解锁:上一兵种 ≥3 级。
@@ -137,8 +139,8 @@ export const RACE_SKIP_BONUS = 0.05;
 export function raceStacks(race, count) { return Math.max(0, count - (RACES[race].need - 1)); }
 export function raceStacks(race, count) { return Math.max(0, count - (RACES[race].need - 1)); }
 
 
 // ── 永久乘区(时间结晶,跨轮回) ───────────────────────────
 // ── 永久乘区(时间结晶,跨轮回) ───────────────────────────
-// 世界树等级 D:成本 30 × 1.6^D;每级 本源产出 ×1.05、推进速度 ×1.08(几何乘区)
-export const TREE = { costBase: 30, costRatio: 1.6, prodPer: 0.05, speedPer: 0.08 };
+// 世界树等级 D:成本 30 × 1.9^D;每级 本源产出 ×1.05、推进速度 ×1.08(几何乘区)
+export const TREE = { costBase: 30, costRatio: 1.9, prodPer: 0.05, speedPer: 0.08 };
 export function treeCost(level) { return Math.ceil(TREE.costBase * Math.pow(TREE.costRatio, level || 0)); }
 export function treeCost(level) { return Math.ceil(TREE.costBase * Math.pow(TREE.costRatio, level || 0)); }
 export function treeProdMul(level) { return Math.pow(1 + TREE.prodPer, level || 0); }
 export function treeProdMul(level) { return Math.pow(1 + TREE.prodPer, level || 0); }
 export function treeSpeedMul(level) { return Math.pow(1 + TREE.speedPer, level || 0); }
 export function treeSpeedMul(level) { return Math.pow(1 + TREE.speedPer, level || 0); }
@@ -153,9 +155,9 @@ export function relicMul(count) { return Math.pow(1 + PERM.relicPer, count || 0)
 
 
 // 自由轮回(首次逃逸后永久解锁):每完成一次完整的 1000 层轮回,自由轮回加成 +10%
 // 自由轮回(首次逃逸后永久解锁):每完成一次完整的 1000 层轮回,自由轮回加成 +10%
 export const FREEDOM = { per: 0.1 };
 export const FREEDOM = { per: 0.1 };
-export function freedomMul(state) { return 1 + FREEDOM.per * (state.freeCycles || 0); }
+export function freedomMul(state) { return Math.max(1e-6, 1 + FREEDOM.per * (state.freeCycles || 0)); }
 /** 残响(被动):炼化乘区 ×(1+0.02×已回溯次数) */
 /** 残响(被动):炼化乘区 ×(1+0.02×已回溯次数) */
-export function resonanceMul(state) { return 1 + 0.02 * (state.rebirths || 0); }
+export function resonanceMul(state) { return Math.max(1e-6, 1 + 0.02 * (state.rebirths || 0)); }
 
 
 export const RELICS = [
 export const RELICS = [
   { id: 'seed',   name: '初生之种', desc: '本源产出 ×1.25', icon: 'seed' },
   { id: 'seed',   name: '初生之种', desc: '本源产出 ×1.25', icon: 'seed' },
@@ -169,12 +171,12 @@ export const RELICS = [
 ];
 ];
 
 
 // ── 转生(时间回溯) ─────────────────────────────────────
 // ── 转生(时间回溯) ─────────────────────────────────────
-// 单次收益 R = ⌊0.5 × T^1.3 × E × M × ruleMod⌋(保底 1,T = 本轮最深;指数 1.3 > 回溯的 1.0,鼓励往深处走)
+// 单次收益 R = ⌊0.5 × T^1.6 × E × M × ruleMod⌋(保底 1,T = 本轮最深;指数 1.6 > 回溯的 1.0,深度的收益超线性)
 // E 计入见闻;同一轮回内重复回溯收益 ×0.5^n。
 // E 计入见闻;同一轮回内重复回溯收益 ×0.5^n。
 //   E = 1 + 所有位面探索度之和/100(见闻)
 //   E = 1 + 所有位面探索度之和/100(见闻)
 //   M = 炼化乘区 = 兵种炼化技能 × 星穹羁绊 × 探索阶梯 × 跳关加成(1+min(0.3,0.5p)) × 见闻 × 自由轮回 × 残响
 //   M = 炼化乘区 = 兵种炼化技能 × 星穹羁绊 × 探索阶梯 × 跳关加成(1+min(0.3,0.5p)) × 见闻 × 自由轮回 × 残响
 // 本轮回溯成本 C(T) = 1 + (T/40)²;效率 = R/C。同一轮回内再次炼化收益 ×0.5^n。
 // 本轮回溯成本 C(T) = 1 + (T/40)²;效率 = R/C。同一轮回内再次炼化收益 ×0.5^n。
-export const REBIRTH = { k: 0.5, power: 1.3, exploreDiv: 100, min: 1, costDiv: 40, decay: 0.5, skipNoteCap: 0.3 };
+export const REBIRTH = { k: 0.5, power: 1.6, exploreDiv: 100, min: 1, costDiv: 40, decay: 0.5, skipNoteCap: 0.3 };
 export function rebirthCost(T) { return 1 + Math.pow(Math.max(0, T) / REBIRTH.costDiv, 2); }
 export function rebirthCost(T) { return 1 + Math.pow(Math.max(0, T) / REBIRTH.costDiv, 2); }
 export function rebirthReward({ maxLayer = 0, exploreSum = 0, incomeMul = 1, ruleMod = 1 }) {
 export function rebirthReward({ maxLayer = 0, exploreSum = 0, incomeMul = 1, ruleMod = 1 }) {
   const T = Math.max(0, maxLayer);
   const T = Math.max(0, maxLayer);

+ 12 - 8
js/formulas.js

@@ -8,13 +8,17 @@ const nowSec = () => Date.now() / 1000;
 export function F0(state) { return C.earlyLayer(state.maxLayerRound || 0, C.PLANE_RULES[state.currentPlane || 0]); }
 export function F0(state) { return C.earlyLayer(state.maxLayerRound || 0, C.PLANE_RULES[state.currentPlane || 0]); }
 
 
 /**
 /**
- * 推进基准(连续空间“能量谷包络”):前 GRACE 层 ×1,之后每深入 1 层单层推进时间 ×ENV_STEP(封顶 ENV_CAP)
- * gm(D) = ENV_STEP^(max(0, D − GRACE)),D = L − F
+ * 推进基准(连续空间“能量谷包络”):前 GRACE 层 ×1;之后 gm = max( ENV_STEP^(D−GRACE)(封顶 ENV_CAP), (D/TOTAL_LAYERS)^GM_Q )
+ * 这样全程难度单调且终点 gm ≤ ENV_CAP(不会出现“越走越快直接冲到终点”);D = L − F
  */
  */
-export const GRACE = 15, ENV_STEP = 1.063, ENV_CAP = 15;
+export const GRACE = 15, ENV_STEP = 1.04, ENV_CAP = 50, GM_Q = 2, GM_END = 8;
 export function marchBase(layer, start) {
 export function marchBase(layer, start) {
-  const d = Math.max(0, layer - (start || 0) - GRACE);
-  return Math.min(ENV_CAP, Math.pow(ENV_STEP, d));
+  const D = Math.max(0, layer - (start || 0));
+    // 前 GRACE 层 ×1;gm = max(1, 指数包络 ENV_STEP^(D−GRACE)(封顶 ENV_CAP), 二次下界 (min(1, D/Gm))^GM_Q,Gm = TOTAL×(ENV_STEP−1)/(GM_END−1))
+  const Gm = C.TOTAL_LAYERS * (ENV_STEP - 1) / (GM_END - 1);   // 见 config.TOTAL_LAYERS 注释
+  // 指数包络只在 D < Gm 内生效(越走越快的“前段”);之后线性增长到终点 ×(GM_END−1)
+  if (D >= Gm) return Math.min(ENV_CAP, 1 + (GM_END - 1) * Math.min(1, D / (0.8 * C.TOTAL_LAYERS)));
+  return Math.max(1, Math.min(ENV_CAP, Math.pow(ENV_STEP, D - GRACE)), Math.pow(Math.max(1, D) / Gm, GM_Q));
 }
 }
 
 
 /** 兵种技能、已解锁兵种数、种族羁绊 */
 /** 兵种技能、已解锁兵种数、种族羁绊 */
@@ -37,8 +41,8 @@ export function lifeSkill(state) {
   for (const r of Object.keys(C.RACES)) stacks[r] = C.raceStacks(r, byRace[r]);
   for (const r of Object.keys(C.RACES)) stacks[r] = C.raceStacks(r, byRace[r]);
   return {
   return {
     prod, spd, skip, crystal, awake, total, byRace, stacks,
     prod, spd, skip, crystal, awake, total, byRace, stacks,
-    bondProd: Math.pow(C.RACE_BOND_MULT, stacks.生命),
-    bondCrystal: Math.pow(C.RACE_BOND_MULT, stacks.星穹),
+    bondProd: Math.max(1e-6, Math.pow(C.RACE_BOND_MULT, stacks.生命)),
+    bondCrystal: Math.max(1e-6, Math.pow(C.RACE_BOND_MULT, stacks.星穹)),
     bondSkip: Math.min(2, C.RACE_SKIP_BONUS * stacks.虚空),
     bondSkip: Math.min(2, C.RACE_SKIP_BONUS * stacks.虚空),
   };
   };
 }
 }
@@ -57,7 +61,7 @@ export function rebirthMOf(state, sk) {
   const tier = C.exploreTierOf(state.planes?.[p]?.explore || 0);
   const tier = C.exploreTierOf(state.planes?.[p]?.explore || 0);
   const skipNote = 1 + Math.min(C.REBIRTH.skipNoteCap, 0.5 * skipProbOf(state, l)) * l.crystal;
   const skipNote = 1 + Math.min(C.REBIRTH.skipNoteCap, 0.5 * skipProbOf(state, l)) * l.crystal;
   const insight = 1 + (state.exploreSum || 0) / 100;
   const insight = 1 + (state.exploreSum || 0) / 100;
-  return l.crystal * l.bondCrystal * tier.crystal * skipNote * insight * C.freedomMul(state) * C.resonanceMul(state);
+  return Math.max(1e-6, l.crystal * l.bondCrystal * tier.crystal * skipNote * insight * C.freedomMul(state) * C.resonanceMul(state));
 }
 }
 
 
 /** 推进速度乘区 M_spd(不含危机) */
 /** 推进速度乘区 M_spd(不含危机) */

+ 6 - 3
js/state.js

@@ -183,7 +183,7 @@ export function tick(s, rift, dt) {
   if (fl > 0 && fl % 10 === 0 && fl !== s._lastFlash) { s._lastFlash = fl; out.floor = fl; }
   if (fl > 0 && fl % 10 === 0 && fl !== s._lastFlash) { s._lastFlash = fl; out.floor = fl; }
 
 
   // 主线章节里程碑(连续空间:章节只是进度条上的一段,无弹窗结算)
   // 主线章节里程碑(连续空间:章节只是进度条上的一段,无弹窗结算)
-  const ch = Math.min(5, C.chapterOf(s.layer));
+  const ch = Math.min(5, C.chapterOf(Math.min(C.TOTAL_LAYERS, s.layer)));   // 超出终点的层数不再触发新章节
   if (ch > (s.chapterSeen || 0)) {
   if (ch > (s.chapterSeen || 0)) {
     for (let c = Math.max(1, (s.chapterSeen || 0) + 1); c <= ch; c++) {
     for (let c = Math.max(1, (s.chapterSeen || 0) + 1); c <= ch; c++) {
       s.chapterSeen = c;
       s.chapterSeen = c;
@@ -248,11 +248,14 @@ export function tick(s, rift, dt) {
   s._autoT = (s._autoT || 0) + dt;
   s._autoT = (s._autoT || 0) + dt;
   if (s.autoOn && s._autoT >= autoRebirthEvery(s)) {
   if (s.autoOn && s._autoT >= autoRebirthEvery(s)) {
     s._autoT = 0;
     s._autoT = 0;
-    // 节奏固定,但只在“离本轮最优回溯点足够近”时真正回溯(其余时机继续生长);硬闸:两次回溯至少相隔 30 秒
+    // 节奏固定;触发条件 = 卡墙(最近 40 秒几乎没前进)或已在“本轮最优回溯点”附近;两次回溯至少相隔 20 秒
+    s._stall = s._stall || {};
+    if (!s._stall.t || s.playSec - s._stall.t > 40) s._stall = { t: s.playSec, layer: s.layer };
+    const stalled = s.layer - (s._stall.layer || 0) < 1;
     const floor = C.earlyLayer(Math.max(s.maxLayerRound || 0, s.layer || 0), st.rule);
     const floor = C.earlyLayer(Math.max(s.maxLayerRound || 0, s.layer || 0), st.rule);
     const progress = (s.layer - floor) / Math.max(1, (s.maxLayerRound || 0) - floor);
     const progress = (s.layer - floor) / Math.max(1, (s.maxLayerRound || 0) - floor);
     const sinceReb = s.playSec - (s._lastRebSec || -1e9);
     const sinceReb = s.playSec - (s._lastRebSec || -1e9);
-    if (s.playSec >= 60 && progress >= 0.6 && sinceReb >= 30) { out.auto = true; s._lastRebSec = s.playSec; }
+    if (s.playSec >= 60 && sinceReb >= 20 && (stalled || progress >= 0.4)) { out.auto = true; s._lastRebSec = s.playSec; s._stall = { t: s.playSec, layer: s.layer }; }
   }
   }
   return out;
   return out;
 }
 }

+ 3 - 3
js/ui.js

@@ -154,7 +154,7 @@ export class App {
     const prog = Math.min(1, s.layer / C.TOTAL_LAYERS);
     const prog = Math.min(1, s.layer / C.TOTAL_LAYERS);
     const bar = $('#mainline .esc-bar .fill');
     const bar = $('#mainline .esc-bar .fill');
     if (bar) bar.style.width = (prog * 100).toFixed(2) + '%';
     if (bar) bar.style.width = (prog * 100).toFixed(2) + '%';
-    const el = $('#esc-layer'); if (el) { const v = `第 ${fmt(Math.floor(s.layer), { int: true })} / 1000 层`; if (el.textContent !== v) el.textContent = v; }
+    const el = $('#esc-layer'); if (el) { const v = `第 ${fmt(Math.floor(s.layer), { int: true })} / ${C.TOTAL_LAYERS} 层`; if (el.textContent !== v) el.textContent = v; }
     const t = $('#ch-title'); if (t) { const v = s.escaped ? '冲出空洞 · 自由轮回' : info.title; if (t.textContent !== v) { t.textContent = v; this.setText('#mainline .ch-desc', s.escaped ? `你已完成 ${s.escapeCount || 1} 次逃逸;禅定循环会继续累积自由轮回加成(×${C.freedomMul(s).toFixed(2)})。` : info.desc); const idx = $('#mainline .ch-title .idx'); if (idx) idx.textContent = `CH.${ch + 1} / 6`; } }
     const t = $('#ch-title'); if (t) { const v = s.escaped ? '冲出空洞 · 自由轮回' : info.title; if (t.textContent !== v) { t.textContent = v; this.setText('#mainline .ch-desc', s.escaped ? `你已完成 ${s.escapeCount || 1} 次逃逸;禅定循环会继续累积自由轮回加成(×${C.freedomMul(s).toFixed(2)})。` : info.desc); const idx = $('#mainline .ch-title .idx'); if (idx) idx.textContent = `CH.${ch + 1} / 6`; } }
     const tag = $('#mainline .panel-title .tag'); if (tag) { const v = fmtPct(prog, 2); if (tag.textContent !== v) tag.textContent = v; }
     const tag = $('#mainline .panel-title .tag'); if (tag) { const v = fmtPct(prog, 2); if (tag.textContent !== v) tag.textContent = v; }
   }
   }
@@ -211,7 +211,7 @@ export class App {
       </div>
       </div>
       <div class="esc-track">
       <div class="esc-track">
         <div class="esc-bar"><div class="fill" style="width:${(prog * 100).toFixed(2)}%"></div>${marks}</div>
         <div class="esc-bar"><div class="fill" style="width:${(prog * 100).toFixed(2)}%"></div>${marks}</div>
-        <span id="esc-layer">第 ${fmt(Math.floor(s.layer), { int: true })} / 1000 层</span><span id="esc-goal">${s.escaped ? '已抵达' : '目标:冲出空洞'}</span>
+        <span id="esc-layer">第 ${fmt(Math.floor(s.layer), { int: true })} / ${C.TOTAL_LAYERS} 层</span><span id="esc-goal">${s.escaped ? '已抵达' : '目标:冲出空洞'}</span>
       </div>`);
       </div>`);
   }
   }
 
 
@@ -242,7 +242,7 @@ export class App {
       return;
       return;
     }
     }
     this.upgBuilt = true;
     this.upgBuilt = true;
-    const rows = C.UPGRADE_KINDS.map((k) => {
+    const rows = C.UPGRADE_KINDS.filter((k) => k === 'root' || k === 'canopy').map((k) => {
       const c = C.COST[k];
       const c = C.COST[k];
       const lv = s.upgrades[k] || 0;
       const lv = s.upgrades[k] || 0;
       const ic = k === 'root' ? I.tree() : I.canopy();
       const ic = k === 'root' ? I.tree() : I.canopy();

+ 1 - 1
js/util.js

@@ -23,7 +23,7 @@ export function hashStr(s) {
 // 中文大数单位(万进制)
 // 中文大数单位(万进制)
 export const UNITS = ['', '万', '亿', '兆', '京', '垓', '秭', '穰', '沟', '涧', '正', '载', '极'];
 export const UNITS = ['', '万', '亿', '兆', '京', '垓', '秭', '穰', '沟', '涧', '正', '载', '极'];
 // 超过“极”(10^48)后用扩展单位(万进制继续,避免 e 科学计数法在游戏里出戏)
 // 超过“极”(10^48)后用扩展单位(万进制继续,避免 e 科学计数法在游戏里出戏)
-export const UNITS_X = ['恒河沙', '阿僧祇', '那由他', '不可思议', '无量大数'];
+export const UNITS_X = ['恒河沙', '阿僧祇', '那由他', '不可思议', '无量大数', '古'];
 export const MAX_UNIT = 1e4 ** (UNITS.length - 1 + UNITS_X.length);
 export const MAX_UNIT = 1e4 ** (UNITS.length - 1 + UNITS_X.length);
 
 
 function trimFixed(v, d) {
 function trimFixed(v, d) {

+ 2 - 0
tests/balance-sim.mjs

@@ -7,6 +7,7 @@ import * as R from '/opt/data/git-repos/worldtree-escape/js/rift.js';
 
 
 if (process.argv[1] && process.argv[1].endsWith('balance-sim.mjs')) {
 if (process.argv[1] && process.argv[1].endsWith('balance-sim.mjs')) {
   const H = +(process.argv[2] || 6);
   const H = +(process.argv[2] || 6);
+  const CAP = +(process.argv[3] || 0);
   let seed = 7; Math.random = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };
   let seed = 7; Math.random = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };
   const s = S.newState(); s.autoOn = true;
   const s = S.newState(); s.autoOn = true;
   const dt = 0.2; let upgT = 0; const marks = []; let lastRift = -1e9;
   const dt = 0.2; let upgT = 0; const marks = []; let lastRift = -1e9;
@@ -25,6 +26,7 @@ if (process.argv[1] && process.argv[1].endsWith('balance-sim.mjs')) {
       }
       }
       const bp = F.bestPerm(s); if (bp && bp.cost <= s.crystals) { if (bp.kind === 'stem') S.buyTree(s); else S.buyRelic(s); }
       const bp = F.bestPerm(s); if (bp && bp.cost <= s.crystals) { if (bp.kind === 'stem') S.buyTree(s); else S.buyRelic(s); }
     }
     }
+    if (CAP && s.layer >= CAP && !s.escaped) S.rebirth(s);   // 模拟“卡层即回溯”的保守玩家
     if (s.escaped) { S.rebirth(s); marks.push(`★ 逃逸完成 t=${(t / 60) | 0}m 第 ${s.escapeCount} 次`); }
     if (s.escaped) { S.rebirth(s); marks.push(`★ 逃逸完成 t=${(t / 60) | 0}m 第 ${s.escapeCount} 次`); }
     if (t > 300 && t - lastRift > 480 && !s.planeRun) {
     if (t > 300 && t - lastRift > 480 && !s.planeRun) {
       lastRift = t;
       lastRift = t;

BIN
tests/shots/desktop-1-start.png


BIN
tests/shots/desktop-2-progress.png


BIN
tests/shots/desktop-3-first-rebirth.png


BIN
tests/shots/desktop-4-rift-fight.png


BIN
tests/shots/desktop-5-rift-result.png


BIN
tests/shots/desktop-6-crisis.png


BIN
tests/shots/desktop-7-civilization.png


BIN
tests/shots/desktop-8-save.png


BIN
tests/shots/desktop-9-late.png


BIN
tests/shots/mobile-1-growth.png


BIN
tests/shots/mobile-2-march.png


BIN
tests/shots/mobile-3-rebirth.png


BIN
tests/shots/mobile-4-rift-build.png


BIN
tests/shots/mobile-5-rift-fight.png


BIN
tests/shots/mobile-6-rift-result.png


+ 84 - 0
tests/ui-shots.cjs

@@ -0,0 +1,84 @@
+// 游戏流程截图脚本(tests/ui-shots.cjs):用 playwright-core 驱动真实页面,输出到 tests/shots/
+const { chromium } = require('/opt/data/tmp/domtest/node_modules/playwright-core');
+const EXE = '/opt/hermes/.playwright/chromium_headless_shell-1243/chrome-headless-shell-linux64/chrome-headless-shell';
+const BASE = process.env.BASE || 'http://127.0.0.1:8801/index.html';
+const OUT = process.env.OUT || '/opt/data/git-repos/worldtree-escape/tests/shots';
+const fs = require('fs');
+fs.mkdirSync(OUT, { recursive: true });
+
+(async () => {
+  const browser = await chromium.launch({ executablePath: EXE, args: ['--no-sandbox'] });
+  const errors = [];
+  const hook = (page) => { page.on('pageerror', (e) => errors.push('pageerror: ' + e.message)); page.on('console', (m) => { if (m.type() === 'error') errors.push('console: ' + m.text()); }); page.on('requestfailed', (r) => errors.push('requestfailed: ' + r.url())); };
+
+  // ── 桌面端
+  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+  hook(page);
+  await page.goto(BASE); await page.waitForTimeout(1000);
+  await page.screenshot({ path: OUT + '/desktop-1-start.png' });
+  await page.evaluate(() => { const s = window.__wt.s; s.essence = 3e4; s.playSec = 200; s.upgrades = { root: 14, canopy: 5 }; s.lives = { sprout: 22, firefly: 9 }; s.layer = 26; s.maxLayerRound = 26; window.__wt.renderAll(); });
+  await page.waitForTimeout(800);
+  await page.screenshot({ path: OUT + '/desktop-2-progress.png' });
+  // 回溯
+  await page.click('[data-act="rebirth"]'); await page.waitForTimeout(500);
+  await page.screenshot({ path: OUT + '/desktop-3-first-rebirth.png' });
+  await page.evaluate(() => document.querySelector('[data-mact="close"]')?.click());
+  // 里世界战斗
+  await page.evaluate(() => { const w = window.__wt; w.s.playSec = 100; w.startRift(); w.riftRun.budget = 12; w.riftPanelKey = null; w.renderRiftPanel(); });
+  await page.waitForTimeout(300);
+  await page.evaluate(() => document.querySelector('[data-r="auto"]').click()); await page.waitForTimeout(300);
+  await page.evaluate(() => document.querySelector('[data-r="build"]').click()); await page.waitForTimeout(300);
+  await page.evaluate(() => window.__wt.rollRift(5)); await page.waitForTimeout(400);
+  await page.screenshot({ path: OUT + '/desktop-4-rift-fight.png' });
+  await page.evaluate(() => window.__wt.abandonRift()); await page.waitForTimeout(500);
+  await page.screenshot({ path: OUT + '/desktop-5-rift-result.png' });
+  await page.evaluate(() => document.querySelector('[data-mact="close"]')?.click());
+  // 危机 / 文明
+  await page.evaluate(() => { window.__wt.s.crisis.next = 0.1; }); await page.waitForTimeout(700);
+  await page.screenshot({ path: OUT + '/desktop-6-crisis.png' });
+  await page.evaluate(() => document.querySelector('[data-mact="crisis"]')?.click());
+  await page.evaluate(() => { window.__wt.s.nextCivSec = 0.1; }); await page.waitForTimeout(600);
+  await page.screenshot({ path: OUT + '/desktop-7-civilization.png' });
+  await page.evaluate(() => document.querySelector('[data-mact="civ"]')?.click());
+  // 存档
+  await page.click('.top-save'); await page.waitForTimeout(400);
+  await page.screenshot({ path: OUT + '/desktop-8-save.png' });
+  await page.evaluate(() => window.__wt.closeModal());
+  // 后期(大数字 + 修士位面)
+  await page.evaluate(() => { const s = window.__wt.s; s.layer = 812; s.maxLayerRound = 812; s.essence = 1e42; s.upgrades = { root: 160, canopy: 40 }; s.lives = { sprout: 300, firefly: 250, rootwalker: 120, arbor: 90 }; s.treeLv = 24; s.crystals = 1e9; s.rebirths = 88; s.chapterSeen = 5; s.escaped = true; s.escapeCount = 1; s.planes = [{ explore: 100 }, { explore: 100 }, { explore: 73 }, { explore: 12 }]; s.exploreSum = 285; s.currentPlane = 3; s.relics = ['seed', 'star', 'gear']; window.__wt.renderLeft(); window.__wt.renderRight(); window.__wt.renderAll(); });
+  await page.waitForTimeout(900);
+  await page.screenshot({ path: OUT + '/desktop-9-late.png' });
+
+  // ── 手机端 375×667
+  const ctx = await browser.newContext({ viewport: { width: 375, height: 667 }, isMobile: true, hasTouch: true, deviceScaleFactor: 2 });
+  const mp = await ctx.newPage(); hook(mp);
+  await mp.goto(BASE); await mp.waitForTimeout(900);
+  await mp.screenshot({ path: OUT + '/mobile-1-growth.png' });
+  const of1 = await mp.evaluate(() => ({ sw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth }));
+  await mp.click('#tabbar button[data-tab="center"]'); await mp.waitForTimeout(800);
+  await mp.screenshot({ path: OUT + '/mobile-2-march.png' });
+  await mp.click('#tabbar button[data-tab="right"]'); await mp.waitForTimeout(500);
+  await mp.screenshot({ path: OUT + '/mobile-3-rebirth.png' });
+  await mp.evaluate(() => { const w = window.__wt; w.s.playSec = 100; w.s.riftCdSec = 0; w.startRift(); w.riftRun.budget = 12; w.riftPanelKey = null; w.renderRiftPanel(); });
+  await mp.waitForTimeout(400); await mp.screenshot({ path: OUT + '/mobile-4-rift-build.png' });
+  await mp.evaluate(() => document.querySelector('[data-r="auto"]').click()); await mp.waitForTimeout(200);
+  await mp.evaluate(() => document.querySelector('[data-r="build"]').click()); await mp.waitForTimeout(500);
+  await mp.screenshot({ path: OUT + '/mobile-5-rift-fight.png' });
+  const of2 = await mp.evaluate(() => ({ sw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth }));
+  // 手机端点击升级
+  const before0 = await mp.evaluate(() => [window.__wt.s.upgrades.root, window.__wt.s.essence, window.__wt.riftRun && window.__wt.riftRun.state]);
+  await mp.evaluate(() => { const a = window.__wt; a.riftRun.state = 'result'; a.finishRift(); });
+  await mp.waitForTimeout(400);
+  await mp.screenshot({ path: OUT + '/mobile-6-rift-result.png' });
+  await mp.evaluate(() => document.querySelector('[data-mact="close"]')?.click());
+  await mp.evaluate(() => { window.__wt.s.riftCdSec = 0; window.__wt.s.essence = 1000; window.__wt.s.playSec = 200; window.__wt.renderAll(); });
+  await mp.waitForTimeout(300);
+  await mp.evaluate(() => window.__wt.showTab('left')); await mp.waitForTimeout(200);
+  await mp.tap('#buy-root').catch(() => {});
+  await mp.waitForTimeout(300);
+  const after = await mp.evaluate(() => window.__wt.s.upgrades.root);
+  console.log('mobile tap upgrade: before', JSON.stringify(before0), '→', after);
+  console.log('overflow', JSON.stringify({ desktop: 'ok', mobile: of1, mobileRift: of2 }));
+  console.log('errors', JSON.stringify(errors.slice(0, 10)));
+  await browser.close();
+})();

+ 3 - 3
tests/unit.mjs

@@ -25,7 +25,7 @@ ok('maxAffordable 与 batchCost 一致', (() => { const n = C.maxAffordable('roo
 ok('根须产出乘区 1.10^0.6R', near(C.rootProdMul(10), Math.pow(1.1, 6)));
 ok('根须产出乘区 1.10^0.6R', near(C.rootProdMul(10), Math.pow(1.1, 6)));
 ok('根须速度 ×1.10/级', near(C.rootSpeedMul(20), Math.pow(1.1, 20)));
 ok('根须速度 ×1.10/级', near(C.rootSpeedMul(20), Math.pow(1.1, 20)));
 ok('世界树等级 ×1.05/级、速度 ×1.08/级', near(C.treeProdMul(5), Math.pow(1.05, 5)) && near(C.treeSpeedMul(5), Math.pow(1.08, 5)));
 ok('世界树等级 ×1.05/级、速度 ×1.08/级', near(C.treeProdMul(5), Math.pow(1.05, 5)) && near(C.treeSpeedMul(5), Math.pow(1.08, 5)));
-ok('世界树成本 30×1.6^D', C.treeCost(4) === Math.ceil(30 * Math.pow(1.6, 4)));
+ok('世界树成本 30×1.9^D', C.treeCost(4) === Math.ceil(30 * Math.pow(1.9, 4)));
 ok('遗物 ×1.25/件,成本 50×2.6^i', near(C.relicMul(8), Math.pow(1.25, 8)) && C.relicCost(2) === Math.ceil(50 * Math.pow(2.6, 2)));
 ok('遗物 ×1.25/件,成本 50×2.6^i', near(C.relicMul(8), Math.pow(1.25, 8)) && C.relicCost(2) === Math.ceil(50 * Math.pow(2.6, 2)));
 ok('兵种价格 = 基础×1.10^(n−1)×max(1, κ(π−π₀))', (() => {
 ok('兵种价格 = 基础×1.10^(n−1)×max(1, κ(π−π₀))', (() => {
   const pi = C.piOf(40, 0); const expect = 25 * Math.pow(1.1, 2) * Math.max(1, C.KAPPA * Math.max(0, pi - C.PI0));
   const pi = C.piOf(40, 0); const expect = 25 * Math.pow(1.1, 2) * Math.max(1, C.KAPPA * Math.max(0, pi - C.PI0));
@@ -34,8 +34,8 @@ ok('兵种价格 = 基础×1.10^(n−1)×max(1, κ(π−π₀))', (() => {
 ok('兵种基础成本 25×3^i', near(C.lifeBase(2), 225));
 ok('兵种基础成本 25×3^i', near(C.lifeBase(2), 225));
 
 
 // 4) 转生收益 R = ⌊0.5·T^1.3·E·M·ruleMod⌋
 // 4) 转生收益 R = ⌊0.5·T^1.3·E·M·ruleMod⌋
-ok('转生公式 T=100, E=1, M=1 → ⌊0.5·100^1.3⌋', C.rebirthReward({ maxLayer: 100 }) === Math.floor(0.5 * Math.pow(100, 1.3)));
-ok('探索见闻 E = 1 + Σ探索/100', C.rebirthReward({ maxLayer: 10, exploreSum: 100 }) === Math.floor(0.5 * Math.pow(10, 1.3) * 2));
+ok('转生公式 T=100, E=1, M=1 → ⌊0.5·100^1.6⌋', C.rebirthReward({ maxLayer: 100 }) === Math.floor(0.5 * Math.pow(100, 1.6)));
+ok('探索见闻 E = 1 + Σ探索/100', C.rebirthReward({ maxLayer: 10, exploreSum: 100 }) === Math.floor(0.5 * Math.pow(10, 1.6) * 2));
 const st0 = S.newState();
 const st0 = S.newState();
 ok('UI 预期 = state.rebirth() 实得', (() => {
 ok('UI 预期 = state.rebirth() 实得', (() => {
   const a = S.newState(); a.maxLayerRound = 120; a.layer = 120; a.lives = { constsign: 4 }; a.exploreSum = 60; a.planes[0].explore = 60;
   const a = S.newState(); a.maxLayerRound = 120; a.layer = 120; a.lives = { constsign: 4 }; a.exploreSum = 60; a.planes[0].explore = 60;