Unspecify CharacterSystem and Specify Charactersystem on correct occasions
Some checks failed
E2E Testing / test (push) Failing after 1m35s

This commit is contained in:
Sebastian Böckelmann 2024-03-22 19:58:48 +01:00
parent 38a11ad628
commit c38dcc556c
5 changed files with 43 additions and 25 deletions

View File

@ -1,4 +1,6 @@
<app-template-state-editor [templateGamesystem]="gamesystem" [scriptAccounts]="scriptAccunts"
(onAddFirstTemplateState)="onAddFirstTemplateState()" (onRemoveLastTemplateState)="onRemoveLastTemplateState()"
(onAddFirstTemplateState)="onSpecifyTemplate()" (onRemoveLastTemplateState)="onUnspecifyTemplate()"
></app-template-state-editor>
<app-template-transition-editor [templateGamesystem]="gamesystem"></app-template-transition-editor>
<app-template-transition-editor [templateGamesystem]="gamesystem" [scriptAccounts]="scriptAccunts"
(onAddFirstTemplateTransition)="onSpecifyTemplate()" (onRemoveLastTemplateTransition)="onUnspecifyTemplate()"
></app-template-transition-editor>

View File

@ -14,14 +14,18 @@ export class TemplateGamesystemEditorComponent {
@Input() gamesystem: TemplateGamesystem | undefined
@Input() scriptAccunts: ScriptAccount[] = []
@Output('onAddFirstTemplateState') addFirstTemplateStateEmitter: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>();
@Output('onRemoveLastTemplateState') removeLastTemplateStateEmitter: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>();
@Output('onSpecifyTemplate') specifyTemplate: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>();
@Output('onUnspecifyTemplate') unspecifyTemplate: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>();
onAddFirstTemplateState() {
this.addFirstTemplateStateEmitter.emit(this.gamesystem!)
onSpecifyTemplate() {
if(this.gamesystem!.templateTransitions.length > 0 && this.gamesystem!.templateStates.length > 0) {
this.specifyTemplate.emit(this.gamesystem!)
}
}
onRemoveLastTemplateState() {
this.removeLastTemplateStateEmitter.emit(this.gamesystem!)
onUnspecifyTemplate() {
if(this.gamesystem!.templateTransitions.length == 0 && this.gamesystem!.templateStates.length == 0) {
this.unspecifyTemplate.emit(this.gamesystem!)
}
}
}

View File

@ -11,14 +11,14 @@
<ng-container matColumnDef="starting-state">
<th mat-header-cell *matHeaderCellDef>Starting State</th>
<td mat-cell *matCellDef="let transition">
<span *ngIf="editedTransition !== transition">{{transition.startingState.stateLabel}}</span>
<span>{{transition.startingState.stateLabel}}</span>
</td>
</ng-container>
<ng-container matColumnDef="ending-state">
<th mat-header-cell *matHeaderCellDef>Ending State</th>
<td mat-cell *matCellDef="let transition">
<span *ngIf="editedTransition !== transition">{{transition.endingState.stateLabel}}</span>
<span>{{transition.endingState.stateLabel}}</span>
</td>
</ng-container>

View File

@ -24,19 +24,13 @@ export class TemplateTransitionEditorComponent {
@Input() templateGamesystem: TemplateGamesystem | undefined
@Input() scriptAccounts: ScriptAccount[] = []
@Output() onAddFirstTemplateTransition: EventEmitter<SimpleTransition> = new EventEmitter<SimpleTransition>()
@Output() onRemoveLastTemplateTransition: EventEmitter<SimpleTransition> = new EventEmitter<SimpleTransition>()
displayedColumns: string[] = ["starting-state", "ending-state", "delete"];
dataSource = new MatTableDataSource<SimpleTransition>();
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
expandedElement: SimpleTransition | null = null;
editedTransition: SimpleTransition | undefined
editedTransitionIndex = -1;
defaultStartingState: SimpleState = new SimpleState("None", "");
defaultEndingState: SimpleState = new SimpleState("None", "");
transitionError: boolean = false;
transitionStartingStateError = true;
transitionEndingStateError = true;
applyFilter(event: KeyboardEvent) {
const filterValue = (event.target as HTMLInputElement).value;
@ -56,9 +50,17 @@ export class TemplateTransitionEditorComponent {
templateTranstion.startingState.stateLabel !== transition.startingState.stateLabel &&
templateTranstion.endingState.stateLabel !== transition.endingState.stateLabel);
this.dataSource.data = this.templateGamesystem!.templateTransitions
if(this.templateGamesystem!.templateTransitions.length == 0) {
this.onRemoveLastTemplateTransition.emit(transition)
}
}
extractReferencedTransition(transition: SimpleTransition) {
if(this.templateGamesystem!.templateTransitions.length == 0) {
this.onAddFirstTemplateTransition.emit(transition)
}
this.templateGamesystem!.addReferenceTransition(transition)
this.dataSource.data = this.templateGamesystem!.templateTransitions
}

View File

@ -6,16 +6,26 @@
"templateStates": [
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "5"
}
],
"conditions": [],
"stateLabel": "Wütend"
}
],
"templateTransitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": {
"initial": true,
"conditions": [],
"stateLabel": "Glücklich"
},
"endingState": {
"initial": false,
"conditions": [],
"stateLabel": "Wütend"
}
}
],
"referenceGamesystem": "Characterstimmung"
}
]