mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-10 23:44:31 +08:00
refactor: 勇士属性
This commit is contained in:
1 parent
a9c64565e1
commit
fa73b47d02
5 files changed
+6
-13
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { getHeroStatusOf, getHeroStatusOn } from '@/plugin/game/hero';
|
||||
import { getHeroStatusOf, getHeroStatusOn } from '@/game/hero';
|
||||
import { Range, RangeCollection } from '@/plugin/game/range';
|
||||
import {
|
||||
checkV2,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getHeroStatusOn } from '@/plugin/game/hero';
|
||||
import { getHeroStatusOn } from '@/game/hero';
|
||||
|
||||
export interface SpecialDeclaration {
|
||||
code: number;
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 获取勇士在某一点的属性
|
||||
* @param name 要获取的勇士属性
|
||||
* @param floorId 勇士所在楼层
|
||||
*/
|
||||
export function getHeroStatusOn(name: 'all', floorId?: FloorIds): HeroStatus;
|
||||
export function getHeroStatusOn(
|
||||
name: (keyof HeroStatus)[],
|
||||
floorId?: FloorIds
|
||||
): Partial<HeroStatus>;
|
||||
export function getHeroStatusOn<K extends keyof HeroStatus>(
|
||||
name: K,
|
||||
floorId?: FloorIds
|
||||
): HeroStatus[K];
|
||||
export function getHeroStatusOn(
|
||||
name: keyof HeroStatus | 'all' | (keyof HeroStatus)[],
|
||||
floorId?: FloorIds
|
||||
) {
|
||||
// @ts-ignore
|
||||
return getHeroStatusOf(core.status.hero, name, floorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一定状态下的勇士在某一点的属性
|
||||
* @param status 勇士的状态
|
||||
* @param name 要获取的勇士属性
|
||||
* @param floorId 勇士所在楼层
|
||||
*/
|
||||
export function getHeroStatusOf(
|
||||
status: Partial<HeroStatus>,
|
||||
name: 'all',
|
||||
floorId?: FloorIds
|
||||
): HeroStatus;
|
||||
export function getHeroStatusOf(
|
||||
status: Partial<HeroStatus>,
|
||||
name: (keyof HeroStatus)[],
|
||||
floorId?: FloorIds
|
||||
): Partial<HeroStatus>;
|
||||
export function getHeroStatusOf<K extends keyof HeroStatus>(
|
||||
status: Partial<HeroStatus>,
|
||||
name: K,
|
||||
floorId?: FloorIds
|
||||
): HeroStatus[K];
|
||||
export function getHeroStatusOf(
|
||||
status: DeepPartial<HeroStatus>,
|
||||
name: keyof HeroStatus | 'all' | (keyof HeroStatus)[],
|
||||
floorId?: FloorIds
|
||||
) {
|
||||
return getRealStatus(status, name, floorId);
|
||||
}
|
||||
|
||||
function getRealStatus(
|
||||
status: DeepPartial<HeroStatus>,
|
||||
name: keyof HeroStatus | 'all' | (keyof HeroStatus)[],
|
||||
floorId: FloorIds = core.status.floorId
|
||||
): any {
|
||||
const { getSkillLevel } = Mota.Plugin.require('skillTree_g');
|
||||
if (name instanceof Array) {
|
||||
return Object.fromEntries(
|
||||
name.map(v => [v, getRealStatus(status, v, floorId)])
|
||||
);
|
||||
}
|
||||
|
||||
if (name === 'all') {
|
||||
return Object.fromEntries(
|
||||
Object.keys(core.status.hero).map(v => [
|
||||
v,
|
||||
v !== 'all' &&
|
||||
getRealStatus(status, v as keyof HeroStatus, floorId)
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
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 (name === 'atk' || name === 'def') {
|
||||
s += window.flags?.[`night_${floorId}`] ?? 0;
|
||||
}
|
||||
|
||||
// 技能
|
||||
if (flags.bladeOn && flags.blade) {
|
||||
const level = getSkillLevel(2);
|
||||
if (name === 'atk') {
|
||||
s *= 1 + 0.1 * level;
|
||||
}
|
||||
if (name === 'def') {
|
||||
s *= 1 - 0.1 * level;
|
||||
}
|
||||
}
|
||||
if (flags.shield && flags.shieldOn) {
|
||||
const level = getSkillLevel(10);
|
||||
if (name === 'atk') {
|
||||
s *= 1 - 0.1 * level;
|
||||
}
|
||||
if (name === 'def') {
|
||||
s *= 1 + 0.1 * level;
|
||||
}
|
||||
}
|
||||
|
||||
// buff
|
||||
if (typeof s === 'number')
|
||||
s *= core.getBuff(name as keyof NumbericHeroStatus);
|
||||
|
||||
// 取整
|
||||
if (typeof s === 'number') s = Math.floor(s);
|
||||
return s;
|
||||
}
|
||||
+3
-1
@@ -516,7 +516,9 @@ function rewrite<O, K extends SelectKey<O, _Func>, T = O>(
|
||||
|
||||
/**
|
||||
* 在渲染进程包裹下执行一段代码,该段代码不会在录像验证中执行,因此里面的内容一定不会引起录像报错
|
||||
* 一般特效,或者是ui显示、内容显示、交互监听等内容应当在渲染进程包裹下执行
|
||||
* 一般特效,或者是ui显示、内容显示、交互监听等内容应当在渲染进程包裹下执行。
|
||||
* 无法获取到执行内容的返回值,因为渲染进程中的值不应当直接出现在游戏进程中,否则很可能导致录像出错,
|
||||
* 如果需要其返回值,应当直接在函数后面新增内容,而不是在游戏进程中使用
|
||||
* @param fn 要执行的函数,传入一个参数,表示所有的第三方库,也就是`Mota.Package.requireAll()`的内容
|
||||
* @param thisArg 函数的执行上下文,即函数中`this`指向
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user