mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-18 20:09:27 +08:00
fix: 商店录像报错
This commit is contained in:
parent
40c4120445
commit
b679cadd1b
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user