Просмотр исходного кода

feat: 环境条常驻渲染 + 手感调节参数(?speed=/?prod=)便于快速体验后期;禅定节奏增加 30 秒

LiuYuYang 1 неделя назад
Родитель
Сommit
ba7195d2aa
2 измененных файлов с 30 добавлено и 7 удалено
  1. 1 1
      js/state.js
  2. 29 6
      js/ui.js

+ 1 - 1
js/state.js

@@ -34,7 +34,7 @@ export function newState() {
 }
 
 /** 自动转生间隔(秒),可在面板调节 5~60 秒;禅定模式(挂机) */
-export const AUTO_STEPS = [60, 120, 300];
+export const AUTO_STEPS = [30, 60, 120, 300];
 export function autoRebirthEvery(s) { return AUTO_STEPS.includes(+(s.autoEvery)) ? +s.autoEvery : 120; }
 export function cycleAutoEvery(s) { const i = AUTO_STEPS.indexOf(autoRebirthEvery(s)); s.autoEvery = AUTO_STEPS[(i + 1) % AUTO_STEPS.length]; }
 

+ 29 - 6
js/ui.js

@@ -27,6 +27,7 @@ export class App {
     this.lastSave = 0;
     this.lastRender = 0;
     this.fps = { n: 0, t: 0, v: 60 };
+    this.readTune();
     this.bindEvents();
     this.bindKeys();
     this.startLoop();
@@ -39,7 +40,8 @@ export class App {
     const loop = (ts) => {
       const dt = Math.min(0.5, (ts - this.lastFrame) / 1000);
       this.lastFrame = ts;
-      acc += dt;
+      const tsMul = (this.tune && this.tune.ts) || 1;
+      acc += dt * tsMul;   // 手感调节:时间倍率
       let guard = 0;
       while (acc >= STEP && guard++ < 10) { acc -= STEP; this.step(STEP); }
       if (ts - this.lastRender > 100) { this.lastRender = ts; this.renderDynamic(); }
@@ -52,7 +54,9 @@ export class App {
 
   step(dt) {
     const s = this.s;
+    const e0 = s.essence;
     const out = S.tick(s, this.riftRun ? { run: this.riftRun } : null, dt);
+    if (this.tune && this.tune.rs !== 1 && s.essence > e0) s.essence = e0 + (s.essence - e0) * this.tune.rs;
     this.riftRun = s.planeRun;
     // 表现:跳关
     if (out.skip) { this.scene.burst(1); this.floatLayer(`跃迁 +${out.skip.k}`); }
@@ -133,27 +137,39 @@ export class App {
     $('.topbar').style.borderTopColor = C.PLANES[s.currentPlane].color;
     // 里世界
     if (this.riftRun) this.renderRiftLive();
+    // 手感调节(?speed=&prod=)
+    const tune = this.tune || { ts: 1, rs: 1 };
+    const th = $('#tune-hint');
+    if (th) { const text = (tune.ts !== 1 || tune.rs !== 1) ? `×${tune.ts} 时间 · ×${tune.rs} 产出` : ''; if (th.textContent !== text) th.textContent = text; }
     // 引导
     this.refreshGuide(st);
   }
 
   renderEnv(st) {
-    const el = $('#env-strip');
-    if (!el) return;
+    if (!this.envEls) {
+      this.envEls = true;
+      $('#env-strip').innerHTML = '<span class="env-dot"></span><b></b><span class="env-eff"></span><span class="env-prog"><i></i></span><span class="env-left"></span><span class="env-left" id="tune-hint" style="margin-left:auto;color:#cbd5e1"></span>';
+    }
     const env = st.env;
     if (!env) return;
+    const strip = $('#env-strip');
     const D = Math.max(0, (this.s.layer || 0) - st.start);
     const prog = (D % 18) / 18;
     const fire = st.envFactors && st.envFactors.fire ? ` · 火种 ${Math.floor(this.s._fireAcc || 0)}/10` : '';
     const boost = (this.s._fireBoost || 0) > Date.now() / 1000 ? ' · 星火 ×2.5' : '';
-    const html = `<span class="env-dot" style="background:${env.color}"></span><b>${env.name}</b><span class="env-eff">${env.eff}</span><span class="env-prog"><i style="width:${(prog * 100).toFixed(0)}%;background:${env.color}"></i></span><span class="env-left">${env.desc}${fire}${boost}</span>`;
-    this.html('#env-strip', html);
+    const set = (sel, v) => { const e = strip.querySelector(sel); if (e && e.textContent !== v) e.textContent = v; };
+    strip.querySelector('.env-dot').style.background = env.color;
+    set('b', env.name);
+    set('.env-eff', env.eff);
+    strip.querySelector('.env-prog i').style.cssText = `width:${(prog * 100).toFixed(0)}%;background:${env.color}`;
+    set('.env-left', env.desc + fire + boost);
   }
 
   renderHud(st) {
     if (!this.hudBuilt) {
       this.hudBuilt = true;
       $('#hud').innerHTML = '<div><div class="layer" id="hud-layer">0<small>层</small></div><div class="meta" id="hud-sub"></div></div><div class="meta hud-meta" id="hud-meta"></div>';
+      $('#env-strip').innerHTML = '<span class="env-dot"></span><b></b><span class="env-eff"></span><span class="env-prog"><i></i></span><span class="env-left"></span><span class="env-left" id="tune-hint" style="margin-left:auto;color:#cbd5e1"></span>';
     }
     const lf = this.s.layer;
     this.html('#hud-layer', `${fmt(Math.floor(lf), { int: true })}<small>层</small>`);
@@ -338,7 +354,7 @@ export class App {
     this.html('#rebirth', `
       <div class="panel-title">时间回溯</div>
       <div class="reb-card">
-        <div class="k">预计炼化</div>
+        <div class="k">预计炼化 <span style="font-weight:400;letter-spacing:0">· 首次建议 ≥20 层</span></div>
         <div class="v"><span id="reb-gain">0</span><small>结晶</small></div>
         <div class="line"><span>本轮深度 <b id="reb-depth">0</b></span><span>回溯代价 <b id="reb-cost">1</b></span><span>收益效率 <b id="reb-eff">—</b></span></div>
       </div>
@@ -514,6 +530,13 @@ export class App {
   }
 
   // ───────────── 交互 ─────────────
+  readTune() {
+    const q = new URLSearchParams(location.search);
+    const ts = Math.max(0.5, Math.min(20, parseFloat(q.get('speed')) || 1));
+    const rs = Math.max(1, Math.min(1000, parseFloat(q.get('prod')) || 1));
+    this.tune = { ts, rs };
+  }
+
   bindKeys() {
     document.addEventListener('keydown', (e) => {
       if (e.target && /INPUT|TEXTAREA/.test(e.target.tagName)) return;