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 717e165..77614fe 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/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..b409151 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 {Character} from "../../../../project/game-model/characters/Character";
+import {
+ SimpleTemplateTransition
+} from "../../../../project/game-model/gamesystems/transitions/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() templateReference: Character | undefined
dataSource: MatTableDataSource = new MatTableDataSource();
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
@@ -21,7 +26,17 @@ export class ScriptaccountActionEditorComponent implements OnInit{
addedAction: ScriptAccountAction | undefined
ngOnInit() {
- this.dataSource.data = this.transition!.scriptAccountActions.map(action => action);
+ if(this.transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
+ if(this.transition!.actionMap.has(this.templateReference!)) {
+ this.dataSource.data = this.transition!.actionMap.get(this.templateReference)!
+ } else {
+ this.dataSource.data = this.transition!.scriptAccountActions
+ }
+
+ } else {
+ this.dataSource.data = this.transition!.scriptAccountActions
+ }
+
if(!this.enableEditing) {
this.displayedColumns = this.displayedColumns.slice(0, -2);
@@ -41,12 +56,21 @@ 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.transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
+ const templateTransition = this.transition as SimpleTemplateTransition
+ if(templateTransition.actionMap.has(this.templateReference!)) {
+ templateTransition.actionMap.get(this.templateReference!)!.push(this.addedAction)
+ } else {
+ templateTransition.actionMap.set(this.templateReference!, [this.addedAction]);
+ }
+ this.dataSource.data = this.transition!.actionMap.get(this.templateReference)!;
+ } else {
+ this.transition?.addScriptAccountAction(this.addedAction)
+ this.dataSource.data = this.transition!.scriptAccountActions;
+ }
this.addedAction = undefined;
}
+
this.editedAction = undefined;
}
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 18c7981..75a20e3 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,7 +42,7 @@
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
= new EventEmitter()
displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"];
dataSource = new MatTableDataSource();
diff --git a/testModel/gamesystems/Weathersystem/Season.json b/testModel/gamesystems/Weathersystem/Season.json
index 246c9ab..0e5c2df 100644
--- a/testModel/gamesystems/Weathersystem/Season.json
+++ b/testModel/gamesystems/Weathersystem/Season.json
@@ -71,7 +71,12 @@
"endingState": "Winter"
},
{
- "scriptAccountActions": [],
+ "scriptAccountActions": [
+ {
+ "changingValue": 10,
+ "scriptAccount": "Temperature"
+ }
+ ],
"scriptAccountConditions": [],
"startingState": "Winter",
"endingState": "Frühling"