diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html
index 2eb564e..0537cf2 100644
--- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html
+++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html
@@ -1,3 +1,3 @@
-
+
diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts
index f14dda3..2174be0 100644
--- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts
+++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts
@@ -5,6 +5,7 @@ import { Transition } from '../../project/game-model/gamesystems/transitions/Tra
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
+import {TemplateElement} from "../../project/game-model/templates/TemplateElement";
@Component({
selector: 'app-gamesystem-editor',
@@ -15,6 +16,7 @@ export class GamesystemEditorComponent implements OnInit{
@Input() gamesystem: Gamesystem, Transition> | undefined
@Input() scriptAccounts: ScriptAccount[] = [];
+ @Input() templateElement: TemplateElement | undefined
@Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter();
ngOnInit() {
diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html
index 7d7dc52..2dd2e3b 100644
--- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html
+++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts
index 36af424..af11955 100644
--- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts
+++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts
@@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core';
import {MatTableDataSource} from "@angular/material/table";
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
+import {TemplateElement} from "../../../project/game-model/templates/TemplateElement";
@Component({
selector: 'app-simple-gamesystem-editor',
@@ -12,6 +13,7 @@ export class SimpleGamesystemEditorComponent {
@Input() simpleGamesystem: SimpleGamesystem | undefined
@Input() scriptAccunts: ScriptAccount[] = []
+ @Input() templateElement: TemplateElement | undefined
}
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html
index 4e74bda..c8f2e06 100644
--- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html
+++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html
@@ -27,7 +27,7 @@
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts
index 049814c..6d00617 100644
--- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts
+++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts
@@ -6,6 +6,8 @@ import {SimpleState} from "../../../../project/game-model/gamesystems/states/Sim
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
+import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement";
+import {SimpleTemplateState} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateState";
@Component({
selector: 'app-simple-state-editor',
@@ -24,6 +26,7 @@ export class SimpleStateEditorComponent implements OnInit{
@Input() states: SimpleState[] = [];
@Input() gamesystem: SimpleGamesystem | undefined
@Input() scriptAccounts: ScriptAccount[] = []
+ @Input() templateElement: TemplateElement | undefined
dataSource = new MatTableDataSource();
displayedColumns = ["name", "initial", "edit", "delete"];
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
@@ -96,11 +99,29 @@ export class SimpleStateEditorComponent implements OnInit{
}
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) {
- state.addScriptAccountCondition(condition);
+ if(this.templateElement != undefined && state instanceof SimpleTemplateState) {
+ state.conditionMap.get(this.templateElement)!.push(condition)
+ } else {
+ state.addScriptAccountCondition(condition);
+ }
}
deleteCondition(state: SimpleState, condition: ScriptAccountCondition) {
- state.removeScriptAccountCondition(condition.scriptAccount);
+ if(this.templateElement != undefined && state instanceof SimpleTemplateState) {
+ let conditions = state.conditionMap.get(this.templateElement)!
+ conditions = conditions.filter(currentCondition => condition.scriptAccount !== currentCondition.scriptAccount)!;
+ state.conditionMap.set(this.templateElement, conditions);
+ } else {
+ state.removeScriptAccountCondition(condition.scriptAccount);
+ }
+ }
+
+ getDisplayedConditions(state: SimpleState) {
+ if(this.templateElement == undefined) {
+ return state.conditions
+ } else if(state instanceof SimpleTemplateState){
+ return (state as SimpleTemplateState).conditionMap.get(this.templateElement)!
+ }
}
}
diff --git a/testModel/gamesystems/TemplateGamesystem.json b/testModel/gamesystems/TemplateGamesystem.json
index dd2b785..0a1da3d 100644
--- a/testModel/gamesystems/TemplateGamesystem.json
+++ b/testModel/gamesystems/TemplateGamesystem.json
@@ -1,7 +1,50 @@
{
"componentName": "TemplateGamesystem",
"componentDescription": "",
- "states": [],
- "transitions": [],
+ "states": [
+ {
+ "initial": false,
+ "conditions": [
+ {
+ "scriptAccount": "Luftfeuchtigkeit",
+ "minValue": 0,
+ "maxValue": "10"
+ }
+ ],
+ "stateLabel": "A",
+ "stateDescription": ""
+ },
+ {
+ "initial": false,
+ "conditions": [
+ {
+ "scriptAccount": "New ScriptAccount",
+ "minValue": 0,
+ "maxValue": 100
+ }
+ ],
+ "stateLabel": "B",
+ "stateDescription": ""
+ }
+ ],
+ "transitions": [
+ {
+ "scriptAccountActions": [
+ {
+ "changingValue": 10,
+ "scriptAccount": "Luftfeuchtigkeit"
+ }
+ ],
+ "scriptAccountConditions": [
+ {
+ "scriptAccount": "Temperature",
+ "minValue": 0,
+ "maxValue": 10
+ }
+ ],
+ "startingState": "A",
+ "endingState": "B"
+ }
+ ],
"templateType": 0
}
\ No newline at end of file