feat: 一些无法展示的录像操作添加顶端提示

This commit is contained in:
unanmed 2024-11-20 16:56:38 +08:00
parent c6cf6287de
commit fb5df24895

View File

@ -1,5 +1,5 @@
import { HeroSkill } from '@/game/mechanism/misc'; import { HeroSkill } from '@/game/mechanism/misc';
import { upgradeSkill } from './skillTree'; import { getSkillFromIndex, upgradeSkill } from './skillTree';
const replayableSettings = ['autoSkill']; const replayableSettings = ['autoSkill'];
@ -20,8 +20,20 @@ export function clip(...replace: string[]) {
} }
export function init() { export function init() {
const { HeroSkill } = Mota.require('module', 'Mechanism'); function tipAndWait(content: string, time: number) {
const speed = core.status.replay.speed;
if (main.replayChecking || speed === 24) return Promise.resolve();
const { tip } = Mota.Plugin.require('utils_r');
tip('info', '录像播放操作:' + content);
return new Promise<void>(res => {
setTimeout(res, time / speed);
});
}
// 注册修改设置的录像操作 // 注册修改设置的录像操作
const settingNameMap: Record<string, string> = {
autoSkill: '自动切换技能'
};
core.registerReplayAction('settings', name => { core.registerReplayAction('settings', name => {
if (!name.startsWith('set:')) return false; if (!name.startsWith('set:')) return false;
const [, setting, value] = name.split(':'); const [, setting, value] = name.split(':');
@ -33,8 +45,15 @@ export function init() {
HeroSkill.setAutoSkill(v); HeroSkill.setAutoSkill(v);
break; break;
} }
core.status.route.push(name); const settingName = settingNameMap[setting];
if (settingName) {
tipAndWait(`切换设置:${settingName}`, 1000).then(() => {
core.replay(); core.replay();
});
} else {
core.replay();
}
core.status.route.push(name);
return true; return true;
}); });
@ -42,8 +61,12 @@ export function init() {
if (!name.startsWith('skill:')) return false; if (!name.startsWith('skill:')) return false;
const skill = parseInt(name.slice(6)); const skill = parseInt(name.slice(6));
upgradeSkill(skill); upgradeSkill(skill);
core.status.route.push(name); const s = getSkillFromIndex(skill);
const skillName = s?.title;
tipAndWait(`升级技能:${skillName}`, 1000).then(() => {
core.replay(); core.replay();
});
core.status.route.push(name);
return true; return true;
}); });
@ -89,8 +112,11 @@ export function init() {
id as AllIdsOf<'items'>, id as AllIdsOf<'items'>,
(type === 'buy' ? num : -num) as number (type === 'buy' ? num : -num) as number
); );
core.status.route.push(name); const { name: itemName } = core.material.items[id as AllIdsOf<'items'>];
tipAndWait(`购买物品:${itemName}`, 1000).then(() => {
core.replay(); core.replay();
});
core.status.route.push(name);
return true; return true;
}); });
@ -104,6 +130,10 @@ export function init() {
return true; return true;
}); });
const skillNameMap: Record<string, string> = {
Blade: '断灭之刃',
Shield: '铸剑为盾'
};
function skillAction(skill: string) { function skillAction(skill: string) {
let toEmit = skill; let toEmit = skill;
@ -146,8 +176,15 @@ export function init() {
HeroSkill.toggleSkill(num); HeroSkill.toggleSkill(num);
} }
core.updateStatusBar(); core.updateStatusBar();
core.status.route.push(`skill:${toEmit}`); const name = skillNameMap[toEmit];
if (name) {
tipAndWait(`切换技能:${name}`, 1000).then(() => {
core.replay(); core.replay();
});
} else {
core.replay();
}
core.status.route.push(`skill:${toEmit}`);
return true; return true;
} }
@ -172,4 +209,20 @@ export function init() {
return false; return false;
}); });
core.registerReplayAction('fly', action => {
if (!action.startsWith('fly:')) return false;
const floorId = action.slice(4) as FloorIds;
const toIndex = core.floorIds.indexOf(floorId);
if (
!core.canUseItem('fly') ||
(core.flags.flyNearStair && !core.nearStair())
)
return false;
if (core.flyTo(floorId, core.replay)) {
tipAndWait(`飞往:${floorId}`, 1000);
return true;
}
return false;
});
} }