From 8dce60627a441aa8969b8cf90a6daa054c5ee13b Mon Sep 17 00:00:00 2001 From: Elena Date: Tue, 7 May 2024 16:45:47 +0200 Subject: [PATCH] refactor: add intention in the actions --- .../event/implementation/actionEvent/ExecutedDeed.js | 5 +++-- .../implementation/actionEvent/ExternalActionFinished.js | 5 +++-- .../implementation/actionEvent/ExternalActionTriggered.js | 5 +++-- .../implementation/actionEvent/InternalActionFinished.js | 5 +++-- .../event/implementation/intentionEvent/IntentionCreated.js | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/component/event/implementation/actionEvent/ExecutedDeed.js b/src/component/event/implementation/actionEvent/ExecutedDeed.js index e1787b6..77472e6 100644 --- a/src/component/event/implementation/actionEvent/ExecutedDeed.js +++ b/src/component/event/implementation/actionEvent/ExecutedDeed.js @@ -5,10 +5,11 @@ import {Level} from "../../../../model/Level"; function ExecutedDeed(props) { const deed = props.event.message.event.deedInfo + const intention = props.event.message.event.intentionInfo.value const type = "Executed deed" let description = "Deed " + deed.term + " executed" - let info = "Type: " + deed.type - const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && props.event.message.event.intentionInfo.value && e.message.event.goalInfo.intention.value.id === props.event.message.event.intentionInfo.value.id) + const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.goalFunctor === intention.trigger) + const info = "Type: " + deed.type + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "") return (
diff --git a/src/component/event/implementation/actionEvent/ExternalActionFinished.js b/src/component/event/implementation/actionEvent/ExternalActionFinished.js index ae8fb14..6fddf7b 100644 --- a/src/component/event/implementation/actionEvent/ExternalActionFinished.js +++ b/src/component/event/implementation/actionEvent/ExternalActionFinished.js @@ -4,10 +4,11 @@ import {Level} from "../../../../model/Level"; function ExternalActionFinished(props) { const deed = props.event.message.event.deedInfo + const intention = props.event.message.event.intentionInfo.value const type = "External Action Finished" let description = "External action " + deed.term + " executed" - let info = "Type: external " + deed.type - const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === props.event.message.event.intentionInfo.value.id) + const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.goalFunctor === intention.trigger) + const info = "Type: external " + deed.type + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "") return (
diff --git a/src/component/event/implementation/actionEvent/ExternalActionTriggered.js b/src/component/event/implementation/actionEvent/ExternalActionTriggered.js index c00ca31..68b52cf 100644 --- a/src/component/event/implementation/actionEvent/ExternalActionTriggered.js +++ b/src/component/event/implementation/actionEvent/ExternalActionTriggered.js @@ -5,9 +5,10 @@ import {Level} from "../../../../model/Level"; function ExternalActionTriggered(props) { const deed = props.event.message.event.action const type = "External Action Triggered" + const intention = props.event.message.event.intentionInfo.value let description = "External action " + deed.term + " triggered" - let info = "Type: external action" - const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === props.event.message.event.action.intention.id) + const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.goalFunctor === intention.trigger) + const info = "Type: external action" + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "") return (
diff --git a/src/component/event/implementation/actionEvent/InternalActionFinished.js b/src/component/event/implementation/actionEvent/InternalActionFinished.js index f8313d4..f49d97f 100644 --- a/src/component/event/implementation/actionEvent/InternalActionFinished.js +++ b/src/component/event/implementation/actionEvent/InternalActionFinished.js @@ -5,9 +5,10 @@ import {Level} from "../../../../model/Level"; function InternalActionFinished(props) { const type = "Internal Action Finished" const action = props.event.message.event.deedInfo + const intention = props.event.message.event.intentionInfo.value let description = "Internal action " + action.term + " finished" - let info = "Type: " + action.type - let explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && props.event.message.event.intentionInfo.value && e.message.event.goalInfo.intention.value.id === props.event.message.event.intentionInfo.value.id) + const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.goalFunctor === intention.trigger) + const info = "Type: " + action.type + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "") return (
diff --git a/src/component/event/implementation/intentionEvent/IntentionCreated.js b/src/component/event/implementation/intentionEvent/IntentionCreated.js index a9c7878..eec8c31 100644 --- a/src/component/event/implementation/intentionEvent/IntentionCreated.js +++ b/src/component/event/implementation/intentionEvent/IntentionCreated.js @@ -6,7 +6,7 @@ function IntentionCreated(props) { const im = props.event.message.event.intentionInfo.intendedMeansInfo const unifier = im[0].unifier - const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === props.event.message.event.intentionInfo.id) + const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.goalFunctor === props.event.message.event.intentionInfo.trigger) if (props.event.message.event.intentionInfo.state === "undefined") { return (