From 6d8b82ca1a614797cbc8d40d494779defa92eed2 Mon Sep 17 00:00:00 2001 From: Elena Date: Sun, 2 Jun 2024 23:32:29 +0200 Subject: [PATCH] refactor: send message event --- src/component/event/EventMapping.js | 2 +- src/component/event/design/ExecutedAction.js | 87 +++++++++++--------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/component/event/EventMapping.js b/src/component/event/EventMapping.js index 8ce97c3..1757af9 100644 --- a/src/component/event/EventMapping.js +++ b/src/component/event/EventMapping.js @@ -60,7 +60,7 @@ const EventMapping = { MailBoxMessages: {implementation: , design: <>}, NewSpeechActMessage: {implementation: , design: }, SelectedMessage: {implementation: , design: <>}, - SendMessage: {implementation: , design: } + SendMessage: {implementation: , design: } }; export default EventMapping; \ No newline at end of file diff --git a/src/component/event/design/ExecutedAction.js b/src/component/event/design/ExecutedAction.js index 6b3bd90..e829691 100644 --- a/src/component/event/design/ExecutedAction.js +++ b/src/component/event/design/ExecutedAction.js @@ -3,50 +3,57 @@ import Event from "../Event"; import {Level} from "../../../model/Level"; function ExecutedAction(props) { - const type = "Executed action" - const deed = props.event.message.event.deedInfo - let description - let info = "Type: " - const intentionInfo = props.event.message.event.intentionInfo.value ? props.event.message.event.intentionInfo.value : props.log.slice(0, props.log.indexOf(props.event)).find(e => e.message.type === "IntentionCreated" && e.message.event.intentionInfo.intendedMeansInfo[0].plan.body.includes(deed.term)).message.event.intentionInfo - const intentionId = intentionInfo.id - const intentionTrigger = intentionInfo.intendedMeansInfo[0] + if (props.event.message.type === "SendMessage") { + const message = props.event.message.event.messageInfo + const description = "I sent a " + message.type + " message to " + message.receiver + ": " + message.message + return ( + + ) + } else { + const deed = props.event.message.event.deedInfo + let description + let info = "Type: " + const intentionInfo = props.event.message.event.intentionInfo.value ? props.event.message.event.intentionInfo.value : props.log.slice(0, props.log.indexOf(props.event)).find(e => e.message.type === "IntentionCreated" && e.message.event.intentionInfo.intendedMeansInfo[0].plan.body.includes(deed.term)).message.event.intentionInfo + const intentionId = intentionInfo.id + const intentionTrigger = intentionInfo.intendedMeansInfo[0] + 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 === intentionId) - 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 === intentionId) + switch (deed.type) { + case "addBel": + description = "I believe " + break; + case "delBel": + description = "I no longer believe in " + break; + case "delAddBel": + description = "I updated belief " + break; + case "test": + description = "I executed test goal " + break; + case "internalAction": + description = "I executed internal action " + break; + case "constraint": + description = "I evaluated expression " + break; + default: + description = "I executed action " + break; + } - switch (deed.type) { - case "addBel": - description = "I believe " - break; - case "delBel": - description = "I no longer believe in " - break; - case "delAddBel": - description = "I updated belief " - break; - case "test": - description = "I executed test goal " - break; - case "internalAction": - description = "I executed internal action " - break; - case "constraint": - description = "I evaluated expression " - break; - default: - description = "I executed action " - break; - } + const intention = "intention int-" + intentionId + "-" + intentionTrigger.plan.trigger + description = description + deed.term + " because of " + intention + info = info + deed.type - const intention = "intention int-" + intentionId + "-" + intentionTrigger.plan.trigger - description = description + deed.term + " because of " + intention - info = info + deed.type - - if (deed.type !== "achieve" && !deed.type.includes("Bel")) { - return ( - - ) + if (deed.type !== "achieve" && !deed.type.includes("Bel")) { + return ( + + ) + } } }