mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-02-28 17:37:07 +08:00
fix: 获取buff性能优化
This commit is contained in:
parent
c476303527
commit
e9b9e4b069
@ -2896,22 +2896,17 @@ control.prototype.getStatusLabel = function (name) {
|
||||
|
||||
////// 设置某个属性的增幅值 //////
|
||||
control.prototype.setBuff = function (name, value) {
|
||||
// 仅保留三位有效buff值
|
||||
value = parseFloat(value.toFixed(3));
|
||||
this.setFlag('__' + name + '_buff__', value);
|
||||
core.status.hero.buff[name] = value;
|
||||
};
|
||||
|
||||
////// 加减某个属性的增幅值 //////
|
||||
control.prototype.addBuff = function (name, value) {
|
||||
var buff = this.getBuff(name) + value;
|
||||
// 仅保留三位有效buff值
|
||||
buff = parseFloat(buff.toFixed(3));
|
||||
this.setFlag('__' + name + '_buff__', buff);
|
||||
core.status.hero.buff[name] += value;
|
||||
};
|
||||
|
||||
////// 获得某个属性的增幅值 //////
|
||||
control.prototype.getBuff = function (name) {
|
||||
return core.getFlag('__' + name + '_buff__', 1);
|
||||
return core.status.hero.buff[name] ?? 1;
|
||||
};
|
||||
|
||||
////// 设置勇士的位置 //////
|
||||
|
@ -62,6 +62,21 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
if (h.magicDef === void 0 || h.magicDef === null) {
|
||||
h.magicDef = 0;
|
||||
}
|
||||
if (!core.status.hero.buff) {
|
||||
const buff = {};
|
||||
core.status.hero.buff = buff;
|
||||
const toDelete = [];
|
||||
for (const [key, value] of Object.entries(flags)) {
|
||||
if (/__\w+_buff__/.test(key)) {
|
||||
const name = key.slice(2, -7);
|
||||
buff[name] = value;
|
||||
toDelete.push(key);
|
||||
}
|
||||
}
|
||||
toDelete.forEach(v => {
|
||||
delete flags[v];
|
||||
});
|
||||
}
|
||||
},
|
||||
win: function (reason, norank, noexit) {
|
||||
// 游戏获胜事件
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { WeatherController } from './../module/weather/weather';
|
||||
import '@/module/weather/snow';
|
||||
import { BgmController, bgm } from './audio/bgm';
|
||||
import { SoundController, SoundEffect, sound } from './audio/sound';
|
||||
import { Focus, GameUi, UiController } from './main/custom/ui';
|
||||
@ -176,8 +174,3 @@ Mota.register('module', 'Animation', Animation);
|
||||
|
||||
main.renderLoaded = true;
|
||||
Mota.require('var', 'hook').emit('renderLoaded');
|
||||
|
||||
const weather = new WeatherController();
|
||||
Mota.require('var', 'hook').once('reset', () => {
|
||||
weather.activate('snow');
|
||||
});
|
||||
|
@ -71,19 +71,30 @@ function getRealStatus(
|
||||
|
||||
if (name === 'all') {
|
||||
const res: any = {};
|
||||
Object.keys(core.status.hero).forEach(v => {
|
||||
res[v] = getRealStatus(status, v as keyof HeroStatus, floorId);
|
||||
});
|
||||
for (const [key, value] of Object.entries(core.status.hero)) {
|
||||
if (typeof value === 'number') {
|
||||
res[key] = getRealStatus(
|
||||
status,
|
||||
key as keyof HeroStatus,
|
||||
floorId
|
||||
);
|
||||
} else {
|
||||
res[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
let s = (status?.[name] ?? core.status.hero[name]) as number;
|
||||
let s = (status[name] ?? core.status.hero[name]) as number;
|
||||
if (s === null || s === void 0) {
|
||||
throw new ReferenceError(
|
||||
`Wrong hero status property name is delivered: ${name}`
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof s !== 'number') return s;
|
||||
|
||||
// 永夜、极昼
|
||||
if (name === 'atk' || name === 'def') {
|
||||
s += NightSpecial.getNight(floorId);
|
||||
@ -108,10 +119,8 @@ function getRealStatus(
|
||||
}
|
||||
|
||||
// buff
|
||||
if (typeof s === 'number') {
|
||||
s *= flags[`__${name}_buff__`] ?? 1;
|
||||
s *= core.status.hero.buff[name] ?? 1;
|
||||
s = Math.floor(s);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
2
src/types/status.d.ts
vendored
2
src/types/status.d.ts
vendored
@ -965,4 +965,6 @@ interface HeroStatus {
|
||||
x?: number;
|
||||
y?: number;
|
||||
floorId?: FloorIds;
|
||||
|
||||
buff: Partial<Record<keyof NumbericHeroStatus, number>>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user