Improved dependencies-only recalculations and fixed many calculation bugs
This commit is contained in:
@@ -4,7 +4,7 @@ import SimpleSchema from 'simpl-schema';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { recomputePropertyDependencies, recomputeCreatureByDoc, recomputeCreature } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
import { recomputePropertyDependencies } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
|
||||
const damageProperty = new ValidatedMethod({
|
||||
name: 'creatureProperties.damage',
|
||||
|
||||
@@ -48,7 +48,8 @@ const dealDamage = new ValidatedMethod({
|
||||
let totalDamage = Math.floor(amount * multiplier);
|
||||
let damageLeft = totalDamage;
|
||||
if (damageType === 'healing') damageLeft = -totalDamage;
|
||||
let dependencies = [];
|
||||
let propertyIds = [];
|
||||
let propertiesDependedAponIds = [];
|
||||
healthBars.forEach(healthBar => {
|
||||
if (damageLeft === 0) return;
|
||||
let damageAdded = damagePropertyWork({
|
||||
@@ -57,10 +58,14 @@ const dealDamage = new ValidatedMethod({
|
||||
value: damageLeft,
|
||||
});
|
||||
damageLeft -= damageAdded;
|
||||
dependencies.push(healthBar.variableName);
|
||||
dependencies.push(...healthBar.dependencies);
|
||||
propertyIds.push(healthBar._id);
|
||||
propertiesDependedAponIds.push(...healthBar.dependencies);
|
||||
});
|
||||
recomputeCreatureByDependencies({
|
||||
creature,
|
||||
propertyIds,
|
||||
propertiesDependedAponIds,
|
||||
});
|
||||
recomputeCreatureByDependencies({creature, dependencies});
|
||||
return totalDamage;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user