mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-03 01:54:58 +08:00
道具栏
This commit is contained in:
1 parent
c29a958689
commit
9b2c56f829
25 files changed
+3088
-3265
No files matched your search
@@ -0,0 +1,134 @@
|
||||
import { has } from '../utils';
|
||||
|
||||
/**
|
||||
* 获取怪物的特殊技能描述
|
||||
* @param enemy 怪物实例
|
||||
*/
|
||||
export function getSpecialHint(enemy: Enemy & DetailedEnemy) {
|
||||
const all = core
|
||||
.getSpecials()
|
||||
.filter(v => enemy.special.includes(v[0]))
|
||||
.sort((a, b) => a[0] - b[0]);
|
||||
|
||||
const des = all.map(v => {
|
||||
const des = v[2];
|
||||
if (des instanceof Function) {
|
||||
return des(enemy);
|
||||
}
|
||||
return des;
|
||||
});
|
||||
const name = all.map(v => {
|
||||
const name = v[1];
|
||||
if (name instanceof Function) {
|
||||
return name(enemy);
|
||||
}
|
||||
return name;
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
{all.map((v, i) => {
|
||||
return (
|
||||
<div class="special">
|
||||
<span style={{ color: core.arrayToRGBA(v[3]) }}>
|
||||
{name[i]}:
|
||||
</span>
|
||||
<span innerHTML={des[i]}></span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得怪物的最近100个加防减伤
|
||||
* @param enemy 怪物实例
|
||||
*/
|
||||
export function getDefDamage(
|
||||
enemy: Enemy & DetailedEnemy,
|
||||
addDef: number = 0,
|
||||
addAtk: number = 0
|
||||
) {
|
||||
const ratio = core.status.thisMap.ratio;
|
||||
const res: [number, number][] = [];
|
||||
|
||||
let origin: number | undefined;
|
||||
let last = 0;
|
||||
|
||||
const max = 100 - Math.floor(addDef / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = core.getDamageInfo(enemy, {
|
||||
def: core.status.hero.def + ratio * i + addDef,
|
||||
atk: core.status.hero.atk + addAtk
|
||||
});
|
||||
|
||||
if (res.length === 0) {
|
||||
origin = dam?.damage;
|
||||
if (has(origin)) {
|
||||
res.push([addDef + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!has(dam)) continue;
|
||||
if (dam.damage === origin) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
if (last <= 0) break;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addDef, dam.damage]);
|
||||
}
|
||||
|
||||
if ((res.at(-1)?.[1] ?? 1) <= 0) {
|
||||
res.push([res.at(-1)![0] + 1, 0]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取怪物的临界信息
|
||||
* @param enemy 怪物实例
|
||||
*/
|
||||
export function getCriticalDamage(
|
||||
enemy: Enemy & DetailedEnemy,
|
||||
addAtk: number = 0,
|
||||
addDef: number = 0
|
||||
): [number, number][] {
|
||||
const ratio = core.status.thisMap.ratio;
|
||||
const res: [number, number][] = [];
|
||||
|
||||
let origin: number | undefined;
|
||||
let last = 0;
|
||||
|
||||
const max = 100 - Math.floor(addAtk / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = core.getDamageInfo(enemy, {
|
||||
atk: core.status.hero.atk + ratio * i + addAtk,
|
||||
def: core.status.hero.def + addDef
|
||||
});
|
||||
|
||||
if (res.length === 0) {
|
||||
origin = dam?.damage;
|
||||
if (has(origin)) {
|
||||
res.push([addAtk + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!has(dam)) continue;
|
||||
if (dam.damage === origin) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
if (last <= 0) break;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addAtk, dam.damage]);
|
||||
}
|
||||
|
||||
if ((res.at(-1)?.[1] ?? 1) <= 0) {
|
||||
res.push([res.at(-1)![0] + 1, 0]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { has } from '../utils';
|
||||
|
||||
interface ClsMap {
|
||||
tools: '消耗道具';
|
||||
constants: '永久道具';
|
||||
all: '全部道具';
|
||||
}
|
||||
|
||||
interface AllItem {
|
||||
tools: [string, number][];
|
||||
constants: [string, number][];
|
||||
}
|
||||
|
||||
const clsMap: ClsMap = {
|
||||
tools: '消耗道具',
|
||||
constants: '永久道具',
|
||||
all: '全部道具'
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据道具的cls获取中文类型
|
||||
* @param cls 道具的cls
|
||||
*/
|
||||
export function getClsName<T extends keyof ClsMap | 'all'>(cls: T): ClsMap[T] {
|
||||
return clsMap[cls];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个类型的所有道具
|
||||
* @param cls 道具类型
|
||||
*/
|
||||
export function getItems(cls: 'all'): AllItem;
|
||||
export function getItems(cls: keyof ClsMap): [string, number][];
|
||||
export function getItems(cls: keyof ClsMap | 'all') {
|
||||
const i = core.status.hero.items;
|
||||
if (cls === 'all') {
|
||||
return {
|
||||
tools: Object.entries(i.tools),
|
||||
constants: Object.entries(i.constants)
|
||||
};
|
||||
}
|
||||
const items = i[cls];
|
||||
const data = Object.entries(items);
|
||||
return data;
|
||||
}
|
||||
Reference in new issue
Block a user