Fixed errors with empty quantity ammo resources
This commit is contained in:
@@ -225,7 +225,7 @@ function spendResources(prop, actionContext) {
|
|||||||
throw 'The prop\'s ammo was not found on the creature';
|
throw 'The prop\'s ammo was not found on the creature';
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!itemConsumed.quantity.value ||
|
!itemConsumed?.quantity?.value ||
|
||||||
!isFinite(itemConsumed.quantity.value)
|
!isFinite(itemConsumed.quantity.value)
|
||||||
) return;
|
) return;
|
||||||
itemQuantityAdjustments.push({
|
itemQuantityAdjustments.push({
|
||||||
@@ -247,8 +247,9 @@ function spendResources(prop, actionContext) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
actionContext.addLog({
|
actionContext.addLog({
|
||||||
name: 'Error',
|
name: 'Error',
|
||||||
value: e,
|
value: e.toString(),
|
||||||
});
|
});
|
||||||
|
console.error(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// No more errors should be thrown after this line
|
// No more errors should be thrown after this line
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ export default function linkTypeDependencies(dependencyGraph, prop, computation)
|
|||||||
|
|
||||||
function dependOnCalc({ dependencyGraph, prop, key }) {
|
function dependOnCalc({ dependencyGraph, prop, key }) {
|
||||||
let calc = get(prop, key);
|
let calc = get(prop, key);
|
||||||
if (!calc) return;
|
if (!calc?.type) return;
|
||||||
if (calc.type !== '_calculation') {
|
if (calc.type !== '_calculation') {
|
||||||
throw `Expected calculation got ${calc.type}`
|
throw `Failed to dependOnCal for prop: ${prop._id}, key: ${key}. Expected calculation got ${calc.type}`
|
||||||
}
|
}
|
||||||
dependencyGraph.addLink(prop._id, `${prop._id}.${key}`, 'calculation');
|
dependencyGraph.addLink(prop._id, `${prop._id}.${key}`, 'calculation');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user