fix: 获取buff性能优化

This commit is contained in:
AncTe committed 2024-11-06 12:41:46 +08:00
1 parent c476303527
commit e9b9e4b069
5 files changed
+37 -23

No files matched your search

-7
View File
@@ -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');
});
+17 -8
View File
@@ -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 = Math.floor(s);
}
s *= core.status.hero.buff[name] ?? 1;
s = Math.floor(s);
return s;
}
+2
View File
@@ -965,4 +965,6 @@ interface HeroStatus {
x?: number;
y?: number;
floorId?: FloorIds;
buff: Partial<Record<keyof NumbericHeroStatus, number>>;
}