mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-16 20:24:31 +08:00
refactor: 脚本编辑部分内容
This commit is contained in:
1 parent
43937c9a54
commit
9adcb5543f
14 files changed
+127
-145
No files matched your search
@@ -8,6 +8,14 @@ export interface GameEvent extends EmitableEvent {
|
||||
mounted: () => void;
|
||||
/** Emitted in plugin/ui.js */
|
||||
statusBarUpdate: () => void;
|
||||
/** Emitted in libs/events.js */
|
||||
afterGetItem: (
|
||||
itemId: AllIdsOf<'items'>,
|
||||
x: number,
|
||||
y: number,
|
||||
isGentleClick: boolean
|
||||
) => void;
|
||||
afterOpenDoor: (doorId: AllIdsOf<'animates'>, x: number, y: number) => void;
|
||||
}
|
||||
|
||||
export const hook = new EventEmitter<GameEvent>();
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
export {};
|
||||
|
||||
const potionItems: AllIdsOf<'items'>[] = [
|
||||
'redPotion',
|
||||
'bluePotion',
|
||||
'yellowPotion',
|
||||
'greenPotion',
|
||||
'I482',
|
||||
'I484',
|
||||
'I487',
|
||||
'I491'
|
||||
];
|
||||
|
||||
mota.game.hook.on('afterGetItem', (itemId, x, y, isGentleClick) => {
|
||||
// 获得一个道具后触发的事件
|
||||
// itemId:获得的道具ID;x和y是该道具所在的坐标
|
||||
// isGentleClick:是否是轻按触发的
|
||||
if (potionItems.includes(itemId)) core.playSound('回血');
|
||||
else core.playSound('获得道具');
|
||||
|
||||
const todo: any[] = [];
|
||||
// 检查该点的获得道具后事件。
|
||||
if (core.status.floorId == null) return;
|
||||
const event = core.floors[core.status.floorId].afterGetItem[`${x},${y}`];
|
||||
if (
|
||||
event &&
|
||||
(event instanceof Array ||
|
||||
!isGentleClick ||
|
||||
!event.disableOnGentleClick)
|
||||
) {
|
||||
core.unshift(todo, event as any[]);
|
||||
}
|
||||
if (core.hasFlag('spring')) {
|
||||
if (!core.hasFlag('springCount')) core.setFlag('springCount', 0);
|
||||
if (potionItems.includes(itemId)) {
|
||||
core.addFlag('springCount', 1);
|
||||
}
|
||||
if (core.getFlag<number>('springCount', 0) === 50) {
|
||||
core.setFlag('springCount', 0);
|
||||
core.status.hero.hpmax += core.getNakedStatus('hpmax') * 0.1;
|
||||
}
|
||||
core.updateStatusBar();
|
||||
}
|
||||
|
||||
if (todo.length > 0) core.insertAction(todo, x, y);
|
||||
});
|
||||
|
||||
mota.game.hook.on('afterOpenDoor', (doorId, x, y) => {
|
||||
// 开一个门后触发的事件
|
||||
|
||||
const todo: any[] = [];
|
||||
// 检查该点的获得开门后事件。
|
||||
if (core.status.floorId == null) return;
|
||||
const event = core.floors[core.status.floorId].afterOpenDoor[`${x},${y}`];
|
||||
if (event) core.unshift(todo, event as any[]);
|
||||
|
||||
if (todo.length > 0) core.insertAction(todo, x, y);
|
||||
|
||||
if (core.status.event.id == null) core.continueAutomaticRoute();
|
||||
else core.clearContinueAutomaticRoute();
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { has } from '../utils';
|
||||
import { getStatusLabel, has } from '../utils';
|
||||
|
||||
/**
|
||||
* 获取所有装备
|
||||
@@ -28,9 +28,7 @@ export function getAddStatus(equip: Equip) {
|
||||
|
||||
return (
|
||||
<span style="display: flex">
|
||||
<span style="flex-basis: 50%">
|
||||
{core.getStatusLabel(v)}
|
||||
</span>
|
||||
<span style="flex-basis: 50%">{getStatusLabel(v)}</span>
|
||||
|
||||
<span
|
||||
style={{
|
||||
@@ -84,7 +82,7 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) {
|
||||
return (
|
||||
<div class="hero-status-one">
|
||||
<span class="hero-status-label">
|
||||
{core.getStatusLabel(v)}
|
||||
{getStatusLabel(v)}
|
||||
</span>
|
||||
<div class="hero-status-value">
|
||||
<span style="margin-right: 20%">{status}</span>
|
||||
|
||||
@@ -307,3 +307,29 @@ export function generateBinary(arr: boolean[]) {
|
||||
});
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得某个状态的中文名
|
||||
* @param name 要获取的属性名
|
||||
*/
|
||||
export function getStatusLabel(name: string) {
|
||||
return (
|
||||
{
|
||||
name: '名称',
|
||||
lv: '等级',
|
||||
hpmax: '生命回复',
|
||||
hp: '生命',
|
||||
manamax: '魔力上限',
|
||||
mana: '额外攻击',
|
||||
atk: '攻击',
|
||||
def: '防御',
|
||||
mdef: '智慧',
|
||||
money: '金币',
|
||||
exp: '经验',
|
||||
point: '加点',
|
||||
steps: '步数',
|
||||
up: '升级',
|
||||
none: '无'
|
||||
}[name] || name
|
||||
);
|
||||
}
|
||||
@@ -93,3 +93,21 @@
|
||||
z-index: 999;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.changable {
|
||||
border-radius: 4px;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
.changable[change='true'] {
|
||||
animation: changable-animate 1s linear alternate 1;
|
||||
}
|
||||
|
||||
@keyframes changable-animate {
|
||||
0% {
|
||||
background-color: #7cc9;
|
||||
}
|
||||
100% {
|
||||
background-color: #0000;
|
||||
}
|
||||
}
|
||||
Vendored
-5
@@ -86,11 +86,6 @@ interface Actions extends VoidedActionFuncs {
|
||||
*/
|
||||
readonly _HY_: number;
|
||||
|
||||
/**
|
||||
* 脚本编辑中的交互函数
|
||||
*/
|
||||
readonly actionsdata: ActionData;
|
||||
|
||||
/**
|
||||
* 所有已注册的交互操作
|
||||
*/
|
||||
|
||||
Vendored
-6
@@ -698,12 +698,6 @@ interface Control {
|
||||
*/
|
||||
getNakedStatus(name?: keyof NumbericHeroStatus): number;
|
||||
|
||||
/**
|
||||
* 获得某个状态的中文名
|
||||
* @param name 要获取的属性名
|
||||
*/
|
||||
getStatusLabel(name: string): string;
|
||||
|
||||
/**
|
||||
* 设置主角某个属性的百分比修正倍率,初始值为1,
|
||||
* 倍率存放在flag: `__${name}_${buff}__` 中
|
||||
|
||||
Vendored
-6
@@ -20,12 +20,6 @@ interface ControlData {
|
||||
*/
|
||||
loadData(data: Save, callback?: () => void): void;
|
||||
|
||||
/**
|
||||
* 获取一个属性对应的中文名
|
||||
* @param name 要获取的状态名称
|
||||
*/
|
||||
getStatusLabel(name: string): string;
|
||||
|
||||
/**
|
||||
* 立即仅更新状态栏
|
||||
*/
|
||||
|
||||
Vendored
+1
-1
@@ -215,7 +215,7 @@ interface ResolvedFloor<T extends FloorIds = FloorIds> extends FloorBase<T> {
|
||||
/**
|
||||
* 获得道具后事件
|
||||
*/
|
||||
afterGetItem: Record<LocString, MotaEvent>;
|
||||
afterGetItem: Record<LocString, MotaAction>;
|
||||
|
||||
/**
|
||||
* 开门后事件
|
||||
|
||||
+4
-6
@@ -13,7 +13,7 @@
|
||||
<div id="filter">
|
||||
<a-select v-model:value="norm" class="select">
|
||||
<a-select-option v-for="t of normList" :value="t">{{
|
||||
t === 'none' ? '所有' : label(t)
|
||||
t === 'none' ? '所有' : getStatusLabel(t)
|
||||
}}</a-select-option>
|
||||
</a-select>
|
||||
<a-divider type="vertical" class="divider"></a-divider>
|
||||
@@ -191,12 +191,12 @@ import {
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { getAddStatus, getEquips, getNowStatus } from '../plugin/ui/equipbox';
|
||||
import BoxAnimate from '../components/boxAnimate.vue';
|
||||
import { has, keycode, tip, type } from '../plugin/utils';
|
||||
import { has, tip, type } from '../plugin/utils';
|
||||
import { cancelGlobalDrag, isMobile, useDrag } from '../plugin/use';
|
||||
import { hyper, sleep } from 'mutate-animate';
|
||||
import { KeyCode } from '../plugin/keyCodes';
|
||||
import { hyper } from 'mutate-animate';
|
||||
import { GameUi } from '@/core/main/custom/ui';
|
||||
import { gameKey } from '@/core/main/init/hotkey';
|
||||
import { getStatusLabel } from '../plugin/utils';
|
||||
|
||||
const props = defineProps<{
|
||||
num: number;
|
||||
@@ -223,8 +223,6 @@ const sType = ref<'value' | 'percentage'>('value');
|
||||
// 攻击 防御 回血 额外攻击
|
||||
const normList = ['none', 'atk', 'def', 'hpmax', 'mana'];
|
||||
|
||||
const label = core.getStatusLabel;
|
||||
|
||||
watch(sort, n => {
|
||||
selected.value = toShow.value.length - selected.value - 1;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user