Persist ScriptAccountActions to TemplateTransition
All checks were successful
E2E Testing / test (push) Successful in 2m9s
All checks were successful
E2E Testing / test (push) Successful in 2m9s
This commit is contained in:
parent
b9b5384ca4
commit
f11e290a6b
@ -1,4 +1,4 @@
|
||||
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts" [templateReference]="templateReference"></app-simple-state-editor>
|
||||
<div id="transition-editor">
|
||||
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
||||
<app-simple-transition-editor [templateReference]="templateReference" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
||||
</div>
|
||||
|
@ -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<any> | undefined
|
||||
@Input() scriptAccounts: ScriptAccount[] = []
|
||||
@Input() enableEditing: boolean = false;
|
||||
@Input() templateReference: Character | undefined
|
||||
|
||||
dataSource: MatTableDataSource<ScriptAccountAction> = 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 !== '') {
|
||||
if(this.transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
|
||||
const templateTransition = this.transition as SimpleTemplateTransition<Character>
|
||||
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)
|
||||
console.log(this.addedAction.scriptAccount)
|
||||
this.dataSource.data = this.transition!.scriptAccountActions;
|
||||
console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length)
|
||||
}
|
||||
this.addedAction = undefined;
|
||||
}
|
||||
|
||||
this.editedAction = undefined;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
||||
<div class="condition-action-container">
|
||||
<div class="action-container">
|
||||
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true"></app-scriptaccount-action-editor>
|
||||
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true" [templateReference]="templateReference"></app-scriptaccount-action-editor>
|
||||
</div>
|
||||
<div class="condition-container">
|
||||
<app-scriptaccount-condition-editor [conditions]="element.scriptAccountConditions" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
||||
|
@ -12,6 +12,7 @@ import {SimpleTemplateGamesystem} from "../../../../project/game-model/gamesyste
|
||||
import {
|
||||
SimpleTemplateTransition
|
||||
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
|
||||
import {Character} from "../../../../project/game-model/characters/Character";
|
||||
@Component({
|
||||
selector: 'app-simple-transition-editor',
|
||||
templateUrl: './simple-transition-editor.component.html',
|
||||
@ -29,6 +30,7 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
||||
@Input() gamesystem: SimpleGamesystem | undefined
|
||||
@Input() scriptAccounts: ScriptAccount[] = []
|
||||
@Input() referenceEditor: boolean = false
|
||||
@Input() templateReference: Character | undefined
|
||||
@Output() referenceTransitionEmitter: EventEmitter<SimpleTransition> = new EventEmitter<SimpleTransition>()
|
||||
displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"];
|
||||
dataSource = new MatTableDataSource<SimpleTransition>();
|
||||
|
@ -71,7 +71,12 @@
|
||||
"endingState": "Winter"
|
||||
},
|
||||
{
|
||||
"scriptAccountActions": [],
|
||||
"scriptAccountActions": [
|
||||
{
|
||||
"changingValue": 10,
|
||||
"scriptAccount": "Temperature"
|
||||
}
|
||||
],
|
||||
"scriptAccountConditions": [],
|
||||
"startingState": "Winter",
|
||||
"endingState": "Frühling"
|
||||
|
Loading…
Reference in New Issue
Block a user