Fixed error with damage failing to apply if existing damage was undefined
This commit is contained in:
@@ -47,7 +47,7 @@ const damageProperty = new ValidatedMethod({
|
|||||||
export function damagePropertyWork({property, operation, value}){
|
export function damagePropertyWork({property, operation, value}){
|
||||||
let damage, newValue;
|
let damage, newValue;
|
||||||
if (operation === 'set'){
|
if (operation === 'set'){
|
||||||
const total = property.total;
|
const total = property.total || 0;
|
||||||
// Set represents what we want the value to be after damage
|
// Set represents what we want the value to be after damage
|
||||||
// So we need the actual damage to get to that value
|
// So we need the actual damage to get to that value
|
||||||
damage = total - value;
|
damage = total - value;
|
||||||
@@ -57,8 +57,8 @@ export function damagePropertyWork({property, operation, value}){
|
|||||||
if (damage < 0) damage = 0;
|
if (damage < 0) damage = 0;
|
||||||
newValue = property.total - damage;
|
newValue = property.total - damage;
|
||||||
} else if (operation === 'increment'){
|
} else if (operation === 'increment'){
|
||||||
let currentValue = property.value;
|
let currentValue = property.value || 0;
|
||||||
let currentDamage = property.damage;
|
let currentDamage = property.damage || 0;
|
||||||
let increment = value;
|
let increment = value;
|
||||||
// Can't increase damage above the remaining value
|
// Can't increase damage above the remaining value
|
||||||
if (increment > currentValue) increment = currentValue;
|
if (increment > currentValue) increment = currentValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user