From 78da370cb83d4c58a91d23bbe745a682a278fcce Mon Sep 17 00:00:00 2001 From: Mael Date: Tue, 23 Jul 2019 12:11:26 +0200 Subject: [PATCH] =?UTF-8?q?:bug:=20Certaines=20cons=C3=A9quences=20des=20v?= =?UTF-8?q?ariations=20ne=20s'affichaient=20pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/mecanisms/variations.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/engine/mecanisms/variations.js b/source/engine/mecanisms/variations.js index b8887c23c..a2bee0173 100644 --- a/source/engine/mecanisms/variations.js +++ b/source/engine/mecanisms/variations.js @@ -22,9 +22,7 @@ export default (recurse, k, v, devariate) => { let evaluate = (cache, situationGate, parsedRules, node) => { let evaluateVariationProp = prop => - prop === undefined - ? undefined - : evaluateNode(cache, situationGate, parsedRules, prop), + prop && evaluateNode(cache, situationGate, parsedRules, prop), // mark the satisfied variation if any in the explanation [, resolvedExplanation] = reduce( ([resolved, result], variation) => { @@ -34,7 +32,7 @@ export default (recurse, k, v, devariate) => { let evaluatedCondition = evaluateVariationProp(variation.condition) if (evaluatedCondition == undefined) { - // We've reached the eventual defaut case + // No condition : we've reached the eventual defaut case let evaluatedVariation = { consequence: evaluateVariationProp(variation.consequence), satisfied: true @@ -43,8 +41,11 @@ export default (recurse, k, v, devariate) => { } if (evaluatedCondition.nodeValue === null) - // one case has missing variables => we can't go further - return [true, [...result, { condition: evaluatedCondition }]] + // the current variation case has missing variables => we can't go further + return [ + true, + [...result, { ...variation, condition: evaluatedCondition }] + ] if (evaluatedCondition.nodeValue === true) { let evaluatedVariation = { @@ -76,6 +77,7 @@ export default (recurse, k, v, devariate) => { missingVariables = satisfiedVariation ? collectNodeMissing(satisfiedVariation.consequence) : mergeMissing(bonus(leftMissing), rightMissing) + console.log(resolvedExplanation) return rewriteNode(node, nodeValue, resolvedExplanation, missingVariables) }