From 2416e226fc8ee84db1fa9e35744b183cb0e258ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:34:54 +0100 Subject: [PATCH] Load ScriptAccountActions --- .../ScriptAccountActionParser.ts | 36 ++++++++++++++++++ .../gamesystemParser/TransitionParser.ts | 4 ++ testModel/gamesystems/Testsystem.json | 37 +++++++++++++++++++ .../Weathersystem/Weathersystem.json | 13 +------ 4 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts create mode 100644 testModel/gamesystems/Testsystem.json diff --git a/src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts b/src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts new file mode 100644 index 0000000..b0d071f --- /dev/null +++ b/src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts @@ -0,0 +1,36 @@ +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountAction} from "../../game-model/gamesystems/actions/ScriptAccountAction"; + +export class ScriptAccountActionParser { + private scriptAccounts: ScriptAccount[] + + + constructor(scriptAccounts: ScriptAccount[]) { + this.scriptAccounts = scriptAccounts; + } + + parseActions(actionData: any) { + const actions: ScriptAccountAction[] = [] + for(let i=0; i scriptAccount.componentName === scriptAccountName); + } +} diff --git a/src/app/project/parser/gamesystemParser/TransitionParser.ts b/src/app/project/parser/gamesystemParser/TransitionParser.ts index f886d34..2bd13df 100644 --- a/src/app/project/parser/gamesystemParser/TransitionParser.ts +++ b/src/app/project/parser/gamesystemParser/TransitionParser.ts @@ -2,17 +2,20 @@ import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; import {ScriptAccountConditionParser} from "./ScriptAccountConditionParser"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {SimpleTransition} from "../../game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccountActionParser} from "./ScriptAccountActionParser"; export class TransitionParser { private states: SimpleState[] private conditionParser: ScriptAccountConditionParser + private actionParser: ScriptAccountActionParser constructor(states: SimpleState[], scriptAccounts: ScriptAccount[]) { this.states = states; this.conditionParser = new ScriptAccountConditionParser(scriptAccounts); + this.actionParser = new ScriptAccountActionParser(scriptAccounts) } public parseTransitions(transitionData: any): SimpleTransition[] { @@ -36,6 +39,7 @@ export class TransitionParser { const simpleTransition = new SimpleTransition(startingState, endingState) simpleTransition.scriptAccountConditions = this.conditionParser.parseStoredConditions(transitionData.scriptAccountConditions) + simpleTransition.scriptAccountActions = this.actionParser.parseActions(transitionData.scriptAccountActions); return simpleTransition; } diff --git a/testModel/gamesystems/Testsystem.json b/testModel/gamesystems/Testsystem.json new file mode 100644 index 0000000..654df19 --- /dev/null +++ b/testModel/gamesystems/Testsystem.json @@ -0,0 +1,37 @@ +{ + "componentName": "Testsystem", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "A", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "B", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "changingValue": 5, + "scriptAccount": "New ScriptAccount" + } + ], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": "10" + } + ], + "startingState": "A", + "endingState": "B" + } + ] +} \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Weathersystem.json b/testModel/gamesystems/Weathersystem/Weathersystem.json index 47d644a..df066e7 100644 --- a/testModel/gamesystems/Weathersystem/Weathersystem.json +++ b/testModel/gamesystems/Weathersystem/Weathersystem.json @@ -1,12 +1 @@ -{ - "componentName": "Weathersystem", - "componentDescription": "Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt.", - "childsystems": [ - { - "componentName": "Season" - }, - { - "componentName": "Weather" - } - ] -} \ No newline at end of file +{"componentName":"Weathersystem","componentDescription":"Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt.","childsystems":[{"componentName":"Season"},{"componentName":"Weather"}]} \ No newline at end of file