|
|
@@ -104,20 +104,20 @@ export class App {
|
|
|
this.renderTop(st);
|
|
|
this.renderHud(st);
|
|
|
// 资源块
|
|
|
- this.setText('#res-essence', fmt(s.essence));
|
|
|
+ this.setText('#res-essence .num', fmt(s.essence));
|
|
|
this.setText('#res-essence-rate', `${fmt(st.prod)} / 秒${st.frozen ? '(冻结)' : ''}`);
|
|
|
- this.setText('#res-crystal', fmt(s.crystals));
|
|
|
+ this.setText('#res-crystal .num', fmt(s.crystals));
|
|
|
this.setText('#res-crystal-rate', s.planes.filter((p) => p.explore >= 100).length ? `锚定采集 ${s.planes.filter((p) => p.explore >= 100).length} 处运行中` : '转生结算,永久');
|
|
|
- // HUD
|
|
|
const lf = s.layer;
|
|
|
|
|
|
- this.html('#hud-r', `<b>${fmt(s.maxLayerRound || 0, { int: true })}</b> 本轮最深<br>时间乘区 <b>×${st.timeMul.toFixed(2)}</b>`);
|
|
|
+ this.html('#hud-r', `<b>${fmt(Math.max(s.maxLayerRound || 0, Math.floor(s.layer)), { int: true })}</b> 本轮最深<br>时间乘区 <b>×${st.timeMul.toFixed(2)}</b>`);
|
|
|
const magic = $('#magic-badge');
|
|
|
if (st.narrSig > 0) {
|
|
|
this.html('#magic-badge', `叙事共鸣 ×${Math.pow(1.3, Math.min(10, st.narrSig)).toFixed(2)}(${st.narrSig} 层)`);
|
|
|
$('#magic-badge').hidden = false;
|
|
|
} else $('#magic-badge').hidden = true;
|
|
|
// 行动条
|
|
|
+ this.refreshMainline(st);
|
|
|
this.refreshActions();
|
|
|
this.refreshAutoButtons();
|
|
|
// 转生面板
|
|
|
@@ -128,9 +128,6 @@ export class App {
|
|
|
// 主世界 canvas
|
|
|
const chF = C.chapterOf(lf);
|
|
|
this.scene.update({ chapter: chF, layerFloat: lf, layersPerSec: st.layersPerSec, layerSec: st.layerSec });
|
|
|
- this.setText('#hud-layer', fmt(Math.floor(lf), { int: true }));
|
|
|
- this.setText('#hud-sub', `第 ${fmt(Math.floor(lf) + 1, { int: true })} 层 · 距下一层 ${fmtPct(lf - Math.floor(lf), 0)}`);
|
|
|
- this.html('#hud-meta', `${fmt(st.prod)} 本源/秒 · 约 ${st.minutesPerLayer < 0.01 ? '<0.01' : st.minutesPerLayer.toFixed(2)} 分/层(含跳关) · 跳关 ${fmtPct(st.skipP, 0)}`);
|
|
|
document.documentElement.style.setProperty('--plane-c', C.PLANES[s.currentPlane].color);
|
|
|
$('.topbar').style.borderTopColor = C.PLANES[s.currentPlane].color;
|
|
|
// 里世界
|
|
|
@@ -140,12 +137,28 @@ export class App {
|
|
|
}
|
|
|
|
|
|
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" id="hud-meta"></div>';
|
|
|
+ }
|
|
|
const lf = this.s.layer;
|
|
|
- this.setText('#hud-layer', fmt(Math.floor(lf), { int: true }));
|
|
|
- this.setText('#hud-sub', `第 ${fmt(Math.floor(lf) + 1, { int: true })} 层 · 距下一层 ${fmtPct(Math.min(0.99, lf - Math.floor(lf)), 0)}`);
|
|
|
+ this.html('#hud-layer', `${fmt(Math.floor(lf), { int: true })}<small>层</small>`);
|
|
|
+ this.setText('#hud-sub', `距下一层 ${fmtPct(Math.min(0.99, lf - Math.floor(lf)), 0)} · 本轮第 ${fmt(Math.floor(lf) - st.start + 1, { int: true })} 层`);
|
|
|
this.html('#hud-meta', `${fmt(st.prod)} 本源/秒 · 约 ${st.minutesPerLayer < 0.01 ? '<0.01' : st.minutesPerLayer.toFixed(2)} 分/层(含跳关) · 跳关触发率 ${fmtPct(st.skipP, 0)}`);
|
|
|
}
|
|
|
|
|
|
+ refreshMainline(st) {
|
|
|
+ const s = this.s;
|
|
|
+ const ch = s.escaped ? 5 : C.chapterOf(s.layer);
|
|
|
+ const info = C.CHAPTERS[ch];
|
|
|
+ const prog = Math.min(1, s.layer / C.TOTAL_LAYERS);
|
|
|
+ const bar = $('#mainline .esc-bar .fill');
|
|
|
+ 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 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; }
|
|
|
+ }
|
|
|
+
|
|
|
setText(sel, v) { const e = $(sel); if (e && e.textContent !== v) e.textContent = v; }
|
|
|
html(sel, v) { const e = $(sel); if (e && this.cache.get(sel) !== v) { e.innerHTML = v; this.cache.set(sel, v); } }
|
|
|
|
|
|
@@ -167,9 +180,9 @@ export class App {
|
|
|
<div class="panel-title">资源 · ${C.PLANES[s.currentPlane].essence}</div>
|
|
|
<div class="res-row">
|
|
|
<div class="res"><div class="k"><span class="dot"></span>本源 <span style="font-size:10px;color:var(--muted-2)">· 本轮</span></div>
|
|
|
- <div class="v num" id="res-essence">0</div><div class="d" id="res-essence-rate">0 / 秒</div></div>
|
|
|
+ <div class="v num" id="res-essence"><span class="num">0</span></div><div class="d" id="res-essence-rate">0 / 秒</div></div>
|
|
|
<div class="res"><div class="k"><span class="dot gold"></span>时间结晶 <span style="font-size:10px;color:var(--muted-2)">· 永久</span></div>
|
|
|
- <div class="v num" id="res-crystal">0</div><div class="d" id="res-crystal-rate">转生结算,永久</div></div>
|
|
|
+ <div class="v num" id="res-crystal"><span class="num">0</span></div><div class="d" id="res-crystal-rate">转生结算,永久</div></div>
|
|
|
</div>`);
|
|
|
this.renderMainline();
|
|
|
this.renderUpgrades();
|
|
|
@@ -193,12 +206,12 @@ export class App {
|
|
|
${guide}
|
|
|
<div class="panel-title">主线 · 逃逸进度 <span class="tag">${fmtPct(prog, 2)}</span></div>
|
|
|
<div class="chapter">
|
|
|
- <div class="ch-title"><span class="idx">CH.${ch + 1} / 6</span>${s.escaped ? '冲出空洞 · 自由轮回' : info.title}</div>
|
|
|
- <div class="ch-desc">${s.escaped ? `空洞已被甩在身后。你已完成 ${s.escapeCount || 1} 次逃逸;禅定循环将继续为你累积自由轮回加成(×${C.freedomMul(s).toFixed(2)})。` : info.desc}</div>
|
|
|
+ <div class="ch-title"><span class="idx">CH.${ch + 1} / 6</span><span id="ch-title">${s.escaped ? '冲出空洞 · 自由轮回' : info.title}</span></div>
|
|
|
+ <div class="ch-desc" id="ch-desc">${s.escaped ? `空洞已被甩在身后。你已完成 ${s.escapeCount || 1} 次逃逸;禅定循环将继续为你累积自由轮回加成(×${C.freedomMul(s).toFixed(2)})。` : info.desc}</div>
|
|
|
</div>
|
|
|
<div class="esc-track">
|
|
|
<div class="esc-bar"><div class="fill" style="width:${(prog * 100).toFixed(2)}%"></div>${marks}</div>
|
|
|
- <span>第 ${fmt(Math.floor(s.layer), { int: true })} / 1000 层</span><span>${s.escaped ? '已抵达' : '目标:冲出空洞'}</span>
|
|
|
+ <span id="esc-layer">第 ${fmt(Math.floor(s.layer), { int: true })} / 1000 层</span><span id="esc-goal">${s.escaped ? '已抵达' : '目标:冲出空洞'}</span>
|
|
|
</div>`);
|
|
|
}
|
|
|
|
|
|
@@ -223,13 +236,19 @@ export class App {
|
|
|
|
|
|
renderUpgrades() {
|
|
|
const s = this.s;
|
|
|
+ // 首次渲染后只动态刷新价格/收益数值,避免每次重绘整块 DOM
|
|
|
+ if (this.upgBuilt) {
|
|
|
+ for (const k of C.UPGRADE_KINDS) { const lv = s.upgrades[k] || 0; this.setText('#upg-n-' + k, 'Lv ' + lv); }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.upgBuilt = true;
|
|
|
const rows = C.UPGRADE_KINDS.map((k) => {
|
|
|
const c = C.COST[k];
|
|
|
const lv = s.upgrades[k] || 0;
|
|
|
const ic = k === 'root' ? I.tree() : I.canopy();
|
|
|
return `<div class="upg">
|
|
|
<div class="ic">${ic}</div>
|
|
|
- <div class="info"><div class="n"><span>${c.name}</span><span class="lv">Lv ${lv}</span></div><div class="d" data-desc="${k}">${this.upgradeDesc(k, lv)}</div></div>
|
|
|
+ <div class="info"><div class="n"><span>${c.name}</span><span class="lv" id="upg-n-${k}">Lv ${lv}</span></div><div class="d" data-desc="${k}">${this.upgradeDesc(k, lv)}</div></div>
|
|
|
<button class="buy" data-act="upg" data-k="${k}" id="buy-${k}"><span class="c" id="cost-${k}">—</span><span class="n2">点击购买</span></button>
|
|
|
</div>`;
|
|
|
}).join('');
|
|
|
@@ -238,7 +257,7 @@ export class App {
|
|
|
|
|
|
upgradeDesc(k, lv) {
|
|
|
if (k === 'root') return `产出 <b>×${C.rootProdMul(lv + BATCH / 2).toFixed(2)}</b> · 推进速度 <b>×${C.rootSpeedMul(lv).toFixed(2)}</b>`;
|
|
|
- return `跳关触发率 <b>${fmtPct(C.canopySkip(lv), 1)}</b>(每级 +1.2%,封顶 60%)`;
|
|
|
+ return `跳关触发率 <b>${fmtPct(C.canopySkip(lv), 1)}</b>(每级 +0.5%,封顶 60%)`;
|
|
|
}
|
|
|
|
|
|
refreshUpgradeButtons() {
|
|
|
@@ -547,7 +566,7 @@ export class App {
|
|
|
$('#main').classList.remove('show-right');
|
|
|
this.scene._resize();
|
|
|
}));
|
|
|
- window.addEventListener('beforeunload', () => this.saveNow());
|
|
|
+ window.addEventListener('beforeunload', () => { if (!this._importing) this.saveNow(); });
|
|
|
document.addEventListener('visibilitychange', () => {
|
|
|
if (document.hidden) this.saveNow();
|
|
|
else this.checkOffline();
|
|
|
@@ -648,7 +667,7 @@ export class App {
|
|
|
}
|
|
|
|
|
|
// ───────────── 存档 ─────────────
|
|
|
- saveNow() { S.save.write(localStorage, this.s, this.riftRun ? { run: this.riftRun } : null); }
|
|
|
+ saveNow() { if (this._importing) return; S.save.write(localStorage, this.s, this.riftRun ? { run: this.riftRun } : null); }
|
|
|
|
|
|
openSave() { this._saveSub = null; this.dialogQueue.push({ kind: 'save' }); if (!this.modalOpen) this.nextDialog(); }
|
|
|
|
|
|
@@ -673,20 +692,20 @@ export class App {
|
|
|
this.setModal('存档', '', '导入存档', `<p style="margin-top:0">粘贴之前导出的 JSON。非法存档会被拒绝,不会覆盖当前进度。</p><textarea id="save-in" placeholder='{"v":1,"state":{...}}'></textarea><div id="save-msg" style="font-size:12px;color:var(--muted);margin-top:6px"></div>`,
|
|
|
`<button class="btn ghost" data-mact="save" data-sub="">返回</button><button class="btn" id="do-import">导入并覆盖</button>`);
|
|
|
setTimeout(() => {
|
|
|
- $('#do-import').onclick = () => {
|
|
|
+ $('#do-import').addEventListener('click', () => {
|
|
|
const r = S.save.parse($('#save-in').value);
|
|
|
const msg = $('#save-msg');
|
|
|
if (!r.ok) { msg.style.color = 'var(--danger)'; msg.textContent = '导入失败:' + r.error; return; }
|
|
|
S.save.write(localStorage, r.data.state, r.data.rift);
|
|
|
- if (window.__wt && window.__wt !== this) { location.reload(); return; }
|
|
|
+ this._importing = true; // 导入后刷新前禁止再写旧存档
|
|
|
msg.style.color = 'var(--life)'; msg.textContent = '导入成功,正在恢复…';
|
|
|
setTimeout(() => location.reload(), 120);
|
|
|
- };
|
|
|
+ });
|
|
|
}, 0);
|
|
|
} else if (sub === 'reset') {
|
|
|
this.setModal('存档', '', '硬重置', `<p style="margin-top:0">将清空本地存档并重新开始,<b>不可撤销</b>。确定要这样做吗?</p>`,
|
|
|
`<button class="btn ghost" data-mact="save" data-sub="">取消</button><button class="btn" id="do-reset" style="background:#c0492e;border-color:#c0492e">确认清空</button>`);
|
|
|
- setTimeout(() => { $('#do-reset').onclick = () => { S.save.clear(localStorage); location.reload(); }; }, 0);
|
|
|
+ setTimeout(() => { $('#do-reset').onclick = () => { S.save.clear(localStorage); this._importing = true; location.reload(); }; }, 0);
|
|
|
} else {
|
|
|
const info = S.save.load(localStorage);
|
|
|
let when = '尚未存档';
|
|
|
@@ -766,11 +785,11 @@ export class App {
|
|
|
}).join('');
|
|
|
panel.innerHTML = `<div class="rift-head"><span class="elite-tag" style="background:${env.color}">里世界 · ${C.PLANES[r.plane].tier}</span><span class="nm">${env.name}</span><span class="kb">规则浓度 ×${r.density.toFixed(2)}</span></div>
|
|
|
<div style="font-size:12px;color:var(--muted)">${env.desc}</div>
|
|
|
- <div class="build-hint">开局分配规则(本源点):剩余 <b>${left}</b> / ${r.budget}——规则总和越高,你可以调动的战力越多,同时敌人的威胁 = 你的规则总和。</div>
|
|
|
+ <div class="build-hint">开局分配规则(本源点):剩余 <b>${left}</b> / ${r.budget}——可分配的“规则槽”决定你的下限,本源点决定你的上限。</div>
|
|
|
<div class="slot-bar">${slots}</div>
|
|
|
<div style="font-size:11px;color:var(--muted);margin-top:10px;line-height:1.6">知识 → 攻击 +1.5 誓约 → 生命 +4(最大项时首击豁免)<br>信念 → 生命 +1.5(最大项时每次受击回 0.5×信念) 裁决 → 攻击 +2(并额外削敌)</div>
|
|
|
- <div style="display:grid;grid-template-columns:1fr 96px;gap:8px;margin-top:10px">
|
|
|
- <button class="btn" data-r="build">进入 ${env.name}</button><button class="btn danger" data-r="abandon">放弃本局</button>
|
|
|
+ <div style="display:grid;grid-template-columns:1fr 96px 96px;gap:8px;margin-top:10px">
|
|
|
+ <button class="btn" data-r="build">进入 ${env.name}</button><button class="btn ghost" data-r="auto">自动分配</button><button class="btn danger" data-r="abandon">放弃本局</button>
|
|
|
</div>`;
|
|
|
} else if (r.state === 'event') {
|
|
|
const m = r.mouth;
|
|
|
@@ -836,6 +855,7 @@ export class App {
|
|
|
else if (act === 'abandon') this.confirmAbandon();
|
|
|
else if (act === 'opt') this.riftOption(+i);
|
|
|
else if (act === 'roll') this.rollRift(+k);
|
|
|
+ else if (act === 'auto') { const r = this.riftRun; if (r && r.state === 'build') { R.autoSpend(r); this.riftPanelKey = null; this.renderRiftPanel(); } }
|
|
|
}
|
|
|
|
|
|
confirmAbandon() {
|