diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html
index 9fc0955..b13fddf 100644
--- a/src/app/editor/character-editor/character-editor.component.html
+++ b/src/app/editor/character-editor/character-editor.component.html
@@ -8,7 +8,7 @@
{{templateSystem.componentName}}
-
+
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 2dd2e3b..a7ac8c2 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/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 386684e..f09ff92 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
@@ -43,6 +43,7 @@ export class SimpleStateEditorComponent implements OnInit{
this.dataSource.filterPredicate = (data: SimpleState, filter: string) => {
return data.stateLabel.toLowerCase().includes(filter);
}
+ console.log(this.templateElement)
}
editState(state: SimpleState) {
diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts
index e8392ee..67ae272 100644
--- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts
+++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts
@@ -3,6 +3,10 @@ import {MatTableDataSource} from "@angular/material/table";
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition";
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
+import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement";
+import {
+ SimpleTemplateTransition
+} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition";
@Component({
selector: 'app-scriptaccount-action-editor',
@@ -13,6 +17,7 @@ export class ScriptaccountActionEditorComponent implements OnInit{
@Input() transition: Transition | undefined
@Input() scriptAccounts: ScriptAccount[] = []
@Input() enableEditing: boolean = false;
+ @Input() templateElement: TemplateElement | undefined
dataSource: MatTableDataSource = new MatTableDataSource();
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
@@ -21,7 +26,9 @@ export class ScriptaccountActionEditorComponent implements OnInit{
addedAction: ScriptAccountAction | undefined
ngOnInit() {
- this.dataSource.data = this.transition!.scriptAccountActions.map(action => action);
+ this.dataSource.data = this.getDisplayedActions()
+
+
if(!this.enableEditing) {
this.displayedColumns = this.displayedColumns.slice(0, -2);
@@ -41,17 +48,42 @@ export class ScriptaccountActionEditorComponent implements OnInit{
finishEditing() {
if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') {
- this.transition?.addScriptAccountAction(this.addedAction)
- console.log(this.addedAction.scriptAccount)
- this.dataSource.data = this.transition!.scriptAccountActions;
- console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length)
+ if(this.templateElement != undefined && this.transition instanceof SimpleTemplateTransition) {
+ if(this.transition.actionMap.has(this.templateElement!)) {
+ this.transition.actionMap.get(this.templateElement!)!.push(this.addedAction)
+ } else {
+ this.transition.actionMap.set(this.templateElement!, [this.addedAction])
+ }
+ } else {
+ this.transition?.addScriptAccountAction(this.addedAction)
+ }
+
+
+ this.dataSource.data = this.getDisplayedActions();
this.addedAction = undefined;
}
this.editedAction = undefined;
}
+ getDisplayedActions(): ScriptAccountAction[] {
+ if(this.templateElement == undefined) {
+ return this.transition!.scriptAccountActions.map(action => action);
+ } else if(this.transition instanceof SimpleTemplateTransition) {
+ return this.transition!.actionMap.get(this.templateElement)!
+ } else {
+ return []
+ }
+ }
+
deleteAction(action: ScriptAccountAction) {
- this.transition!.removeScriptAccountAction(action.scriptAccount)
- this.dataSource.data = this.transition!.scriptAccountActions
+ if(this.templateElement != undefined && this.transition instanceof SimpleTemplateTransition && this.transition.actionMap.has(this.templateElement!)) {
+ const updatedAction = this.transition.actionMap.get(this.templateElement)!.filter(currentAction =>
+ currentAction.scriptAccount !== action.scriptAccount)
+ this.transition.actionMap.set(this.templateElement!, updatedAction)
+ } else {
+ this.transition!.removeScriptAccountAction(action.scriptAccount)
+ }
+
+ this.dataSource.data = this.getDisplayedActions()
}
}
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html
index 91f3790..7a57e18 100644
--- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html
+++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html
@@ -42,10 +42,10 @@
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts
index d26acd6..ceaf686 100644
--- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts
+++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts
@@ -8,6 +8,10 @@ import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/Scrip
import {SimpleTransition} from "../../../../project/game-model/gamesystems/transitions/SimpleTransition";
import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState";
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
+import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement";
+import {
+ SimpleTemplateTransition
+} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition";
@Component({
selector: 'app-simple-transition-editor',
templateUrl: './simple-transition-editor.component.html',
@@ -24,6 +28,8 @@ export class SimpleTransitionEditorComponent implements OnInit {
@Input() gamesystem: SimpleGamesystem | undefined
@Input() scriptAccounts: ScriptAccount[] = []
+ @Input() templateElement: TemplateElement | undefined
+
displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"];
dataSource = new MatTableDataSource();
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
@@ -91,10 +97,33 @@ export class SimpleTransitionEditorComponent implements OnInit {
protected readonly transition = transition;
onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) {
- transition.addScriptAccountCondition(condition);
+ if(this.templateElement != undefined && transition instanceof SimpleTemplateTransition) {
+ transition.conditionMap.get(this.templateElement)!.push(condition)
+ } else {
+ transition.addScriptAccountCondition(condition);
+ }
+
}
deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
- trasition.removeScriptAccountCondition(condition.scriptAccount);
+ if(this.templateElement != undefined && trasition instanceof SimpleTemplateTransition) {
+ let updatedConditions = trasition.conditionMap.get(this.templateElement)!
+ updatedConditions = updatedConditions.filter(currentCondition => condition.scriptAccount !== currentCondition.scriptAccount);
+ trasition.conditionMap.set(this.templateElement, updatedConditions);
+ } else {
+ console.log(this.templateElement)
+ trasition.removeScriptAccountCondition(condition.scriptAccount);
+ }
+
+ }
+
+ getDisplayedConditions(transition: SimpleTransition) {
+ if(this.templateElement == undefined) {
+ return transition.scriptAccountConditions
+ } else if(transition instanceof SimpleTemplateTransition) {
+ return transition.conditionMap.get(this.templateElement)!
+ } else {
+ return [];
+ }
}
}
diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json
index 0678c2b..9437d7c 100644
--- a/testModel/characters/Astrid Hofferson.json
+++ b/testModel/characters/Astrid Hofferson.json
@@ -1,4 +1,5 @@
{
"componentName": "Astrid Hofferson",
- "componentDescription": ""
+ "componentDescription": "",
+ "characterSpecificTemplateSystems": []
}
\ No newline at end of file
diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json
index 1e611d7..d929721 100644
--- a/testModel/characters/Hicks Haddock.json
+++ b/testModel/characters/Hicks Haddock.json
@@ -1,4 +1,40 @@
{
"componentName": "Hicks Haddock",
- "componentDescription": ""
+ "componentDescription": "",
+ "characterSpecificTemplateSystems": [
+ {
+ "componentName": "TemplateGamesystem",
+ "states": [
+ {
+ "stateLabel": "A",
+ "conditionMap": []
+ },
+ {
+ "stateLabel": "B",
+ "conditionMap": []
+ }
+ ],
+ "transitions": [
+ {
+ "scriptAccountActions": [
+ {
+ "changingValue": 10,
+ "scriptAccount": "Luftfeuchtigkeit"
+ }
+ ],
+ "scriptAccountConditions": [
+ {
+ "scriptAccount": "Temperature",
+ "minValue": 0,
+ "maxValue": 10
+ }
+ ],
+ "startingState": "A",
+ "endingState": "B",
+ "conditionMap": [],
+ "actionMap": []
+ }
+ ]
+ }
+ ]
}
\ No newline at end of file