Improved typing of creature properties

This commit is contained in:
ThaumRystra
2025-01-12 23:28:43 +02:00
parent 0125367085
commit 1b05b8d3bf
9 changed files with 147 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
import { PropTask } from '/imports/api/engine/action/tasks/Task';
import TaskResult from 'imports/api/engine/action/tasks/TaskResult';
import TaskResult from '/imports/api/engine/action/tasks/TaskResult';
import getPropertyTitle from '/imports/api/utility/getPropertyTitle';
import { findLast, filter, difference, intersection } from 'lodash';
import { getPropertiesOfType, getPropertyAncestors } from '/imports/api/engine/loadCreatures';
@@ -53,9 +53,10 @@ export default async function applyBuffRemoverProperty(
} else {
// Get all the buffs targeted by tags
const allBuffs = getPropertiesOfType(targetId, 'buff');
const targetedBuffs = filter(allBuffs, buff => {
const targetedBuffs = filter(allBuffs, (buff): boolean => {
if (buff.inactive) return false;
if (buffRemoverMatchTags(prop, buff)) return true;
return false;
});
// Remove the buffs
if (prop.removeAll) {
@@ -65,7 +66,7 @@ export default async function applyBuffRemoverProperty(
});
} else {
// Sort in reverse order
targetedBuffs.sort((a, b) => b.order - a.order);
targetedBuffs.sort((a, b) => b.left - a.left);
// Remove the one with the highest order
const buff = targetedBuffs[0];
if (buff) {