diff --git a/star-raid/js/net.js b/star-raid/js/net.js index 09008b4..a917d42 100644 --- a/star-raid/js/net.js +++ b/star-raid/js/net.js @@ -45,19 +45,19 @@ const NET = { async logout() { await this.api("/api/logout", "POST"); this.user = null; this.stats = null; this.online = false; + SAVE.codex = {}; persist(); // 防同机下一账号继承图鉴 }, - /* 应用服务端返回的用户数据:同步图鉴解锁到本地存档(并集) */ + /* 应用服务端返回的用户数据:图鉴以服务端为准【替换】本地 + (不能并集合并——localStorage 是浏览器级共享,同机多账号会互相污染,已踩坑) */ _apply(d) { this.user = d.user; this.stats = d.stats; this.codexTotal = d.codexTotal || 62; this.online = true; - if (Array.isArray(d.codex)) { - SAVE.codex = SAVE.codex || {}; - for (const k of d.codex) SAVE.codex[k] = true; - persist(); - } + SAVE.codex = {}; + if (Array.isArray(d.codex)) for (const k of d.codex) SAVE.codex[k] = true; + persist(); }, /* 结算上报(fire-and-forget):成功后回写最新统计 */ diff --git a/star-raid/js/ui.js b/star-raid/js/ui.js index f5cec3e..d56360e 100644 --- a/star-raid/js/ui.js +++ b/star-raid/js/ui.js @@ -242,8 +242,7 @@ function submitRun(win){ if(typeof NET==="undefined"||!NET.user)return; NET.submitRun({mode:G.mode,diff:G.diff,score:G.score,wave:G.wave,stage:G.stage, timeSec:Math.round(G.time/60),bossKills:G.bossKills||0,win:!!win, - bestEndless:Math.max(SAVE.best.e0||0,SAVE.best.e1||0), - codex:Object.keys(SAVE.codex)}); + codex:Object.keys(SAVE.codex)}); // 注意:不上报 localStorage 历史最高分(SAVE.best 是浏览器级共享,会串号) } function endRun(win){ if(UI==="over")return; diff --git a/star-raid/server/api.js b/star-raid/server/api.js index deed187..1b91c24 100644 --- a/star-raid/server/api.js +++ b/star-raid/server/api.js @@ -113,11 +113,11 @@ function run(req, res, ctx, body) { if (!vInt(b.wave, 0, 9999) || !vInt(b.stage, 0, 99)) return ctx.fail(400, "非法进度"); if (!vInt(b.timeSec, 0, 86400)) return ctx.fail(400, "非法时长"); if (!vInt(b.bossKills, 0, 60)) return ctx.fail(400, "非法击坠数"); - if (!vInt(b.bestEndless === undefined ? 0 : b.bestEndless, 0, 1e8)) return ctx.fail(400, "非法纪录"); const keys = Array.isArray(b.codex) ? b.codex.slice(0, 100).filter((k) => CODEX_KEYS.has(k)) : []; const uid = ctx.user.id, now = Date.now(); - const endlessCand = Math.max(b.mode === "endless" ? b.score : 0, b.bestEndless || 0); + /* endless_high 只认本账号实际上报的无尽对局分数(不收 localStorage 历史值——浏览器级共享会串号,已踩坑) */ + const endlessCand = b.mode === "endless" ? b.score : 0; db.exec("BEGIN"); try { qInsRun.run(uid, b.mode, b.diff, b.score, b.wave, b.stage, b.timeSec, b.bossKills, b.win ? 1 : 0, now);