Added conditions to action resources
This commit is contained in:
@@ -80,6 +80,15 @@ function linkAction(dependencyGraph, prop, { propsById }) {
|
||||
key: `resources.attributesConsumed[${index}].quantity`,
|
||||
});
|
||||
});
|
||||
// Link conditions
|
||||
prop.resources.conditions?.forEach((con, index) => {
|
||||
// Link the property to its condition calculation
|
||||
dependOnCalc({
|
||||
dependencyGraph,
|
||||
prop,
|
||||
key: `resources.conditions[${index}].condition`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function linkAdjustment(dependencyGraph, prop) {
|
||||
|
||||
@@ -8,13 +8,20 @@ export default function computeAction(computation, node) {
|
||||
}
|
||||
computeResources(computation, node);
|
||||
if (!prop.resources) return;
|
||||
prop.resources.itemsConsumed.forEach(itemConsumed => {
|
||||
prop.resources.conditions?.forEach(conObj => {
|
||||
const condition = conObj.condition;
|
||||
if (!condition) return;
|
||||
if (condition.calculation && !condition.value) {
|
||||
prop.insufficientResources = true;
|
||||
}
|
||||
});
|
||||
prop.resources.itemsConsumed?.forEach(itemConsumed => {
|
||||
if (!itemConsumed.itemId) return;
|
||||
if (itemConsumed.available < itemConsumed.quantity?.value) {
|
||||
prop.insufficientResources = true;
|
||||
}
|
||||
});
|
||||
prop.resources.attributesConsumed.forEach(attConsumed => {
|
||||
prop.resources.attributesConsumed?.forEach(attConsumed => {
|
||||
if (!attConsumed.variableName) return;
|
||||
if (!(attConsumed.available >= attConsumed.quantity?.value)) {
|
||||
prop.insufficientResources = true;
|
||||
|
||||
Reference in New Issue
Block a user