From b679cadd1be82ee838dd98680c392220379de324 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 9 Dec 2024 23:33:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=95=86=E5=BA=97=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin/game/replay.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugin/game/replay.ts b/src/plugin/game/replay.ts index 2ab960a..a8fcb8b 100644 --- a/src/plugin/game/replay.ts +++ b/src/plugin/game/replay.ts @@ -1,5 +1,6 @@ import { HeroSkill } from '@/game/mechanism/misc'; import { getSkillFromIndex, upgradeSkill } from './skillTree'; +import { canOpenShop } from './shop'; const replayableSettings = ['autoSkill']; @@ -73,9 +74,17 @@ export function init() { // 商店 let shopOpened = false; let openedShopId = ''; + + Mota.require('var', 'hook').on('reset', () => { + shopOpened = false; + openedShopId = ''; + }); + core.registerReplayAction('openShop', name => { if (!name.startsWith('openShop:')) return false; - if (shopOpened) return false; + const id = name.slice(9); + if (!canOpenShop(id)) return false; + if (shopOpened && openedShopId === id) return true; openedShopId = name.slice(9); shopOpened = true; core.status.route.push(name); @@ -87,9 +96,8 @@ export function init() { if (!name.startsWith('buy:') && !name.startsWith('sell:')) return false; if (!shopOpened) return false; if (!openedShopId) return false; - const [type, id, num] = name - .split(':') - .map(v => (/^\d+$/.test(v) ? parseInt(v) : v)); + const [type, id, n] = name.split(':'); + const num = parseInt(n); const shop = core.status.shops[openedShopId] as ItemShopEvent; const item = shop.choices.find(v => v.id === id); if (!item) return false; @@ -122,7 +130,6 @@ export function init() { core.registerReplayAction('closeShop', name => { if (name !== 'closeShop') return false; - if (!shopOpened) return false; shopOpened = false; openedShopId = ''; core.status.route.push(name);