chore: 怪物伤害计算与特殊属性调整为样板

This commit is contained in:
AncTe committed 2025-10-14 13:38:39 +08:00
1 parent fe46a7b397
commit 7c9847aa40
24 files changed
+578 -751

No files matched your search

+5
View File
@@ -3,6 +3,7 @@ import { isNil } from 'lodash-es';
interface RangeTypeData {
square: { x: number; y: number; d: number };
rect: { x: number; y: number; w: number; h: number };
manhattan: { x: number; y: number; d: number };
}
type InRangeFn<E extends Partial<Loc>, T> = (item: E, data: T) => boolean;
@@ -79,3 +80,7 @@ Range.register('rect', (item, { x, y, w, h }) => {
const ey = y + h;
return item.x >= x && item.y >= y && item.x < ex && item.y < ey;
});
Range.register('manhattan', (item, { x, y, d }) => {
if (isNil(item.x) || isNil(item.y)) return false;
return Math.abs(item.x - x) + Math.abs(item.y - y) < d;
});
+6 -6
View File
@@ -168,12 +168,12 @@ export function boundary(arr: any, key?: any) {
* @param from 初始坐标
* @param to 指向坐标
*/
export function findDir(from: Loc, to: Loc): Dir2 | 'none' {
const dx = to.x - from.x;
const dy = to.y - from.y;
export function findDir(from: Loc, to: Loc): Dir | 'none' {
const dx = Math.sign(to.x - from.x);
const dy = Math.sign(to.y - from.y);
return (
(Object.entries(core.utils.scan2).find(v => {
v[1].x === dx && v[1].y === dy;
})?.[0] as Dir2) ?? 'none'
(Object.entries(core.utils.scan).find(v => {
return v[1].x === dx && v[1].y === dy;
})?.[0] as Dir) ?? 'none'
);
}