Allowed some properties to return damaged action values

When a prop is damaged during an action, it now tries
to show its new value during the rest of that action
This commit is contained in:
Stefan Zermatten
2022-08-25 15:10:36 +02:00
parent 11a527481e
commit 249aebea0f
2 changed files with 25 additions and 1 deletions

View File

@@ -219,6 +219,16 @@ function dealDamage({target, damageType, amount, actionContext}){
if (damageType === 'healing') damageLeft = -totalDamage;
healthBars.forEach(healthBar => {
if (damageLeft === 0) return;
// Replace the healthbar by the one in the action context if we can
// The damagePropertyWork function bashes the prop with the damage
// So we can use the new value in later action properties
if (healthBar.variableName) {
const targetHealthBar = target.variables[healthBar.variableName];
if (targetHealthBar?._id === healthBar._id) {
healthBar = targetHealthBar;
}
}
// Do the damage
let damageAdded = damagePropertyWork({
prop: healthBar,
operation: 'increment',