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" <app-template-state-editor [templateGamesystem]="gamesystem" [scriptAccounts]="scriptAccunts"
(onAddFirstTemplateState)="onAddFirstTemplateState()" (onRemoveLastTemplateState)="onRemoveLastTemplateState()" (onAddFirstTemplateState)="onSpecifyTemplate()" (onRemoveLastTemplateState)="onUnspecifyTemplate()"
></app-template-state-editor> ></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() gamesystem: TemplateGamesystem | undefined
@Input() scriptAccunts: ScriptAccount[] = [] @Input() scriptAccunts: ScriptAccount[] = []
@Output('onAddFirstTemplateState') addFirstTemplateStateEmitter: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>(); @Output('onSpecifyTemplate') specifyTemplate: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>();
@Output('onRemoveLastTemplateState') removeLastTemplateStateEmitter: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>(); @Output('onUnspecifyTemplate') unspecifyTemplate: EventEmitter<TemplateGamesystem> = new EventEmitter<TemplateGamesystem>();
onAddFirstTemplateState() { onSpecifyTemplate() {
this.addFirstTemplateStateEmitter.emit(this.gamesystem!) if(this.gamesystem!.templateTransitions.length > 0 && this.gamesystem!.templateStates.length > 0) {
this.specifyTemplate.emit(this.gamesystem!)
}
} }
onRemoveLastTemplateState() { onUnspecifyTemplate() {
this.removeLastTemplateStateEmitter.emit(this.gamesystem!) 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"> <ng-container matColumnDef="starting-state">
<th mat-header-cell *matHeaderCellDef>Starting State</th> <th mat-header-cell *matHeaderCellDef>Starting State</th>
<td mat-cell *matCellDef="let transition"> <td mat-cell *matCellDef="let transition">
<span *ngIf="editedTransition !== transition">{{transition.startingState.stateLabel}}</span> <span>{{transition.startingState.stateLabel}}</span>
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="ending-state"> <ng-container matColumnDef="ending-state">
<th mat-header-cell *matHeaderCellDef>Ending State</th> <th mat-header-cell *matHeaderCellDef>Ending State</th>
<td mat-cell *matCellDef="let transition"> <td mat-cell *matCellDef="let transition">
<span *ngIf="editedTransition !== transition">{{transition.endingState.stateLabel}}</span> <span>{{transition.endingState.stateLabel}}</span>
</td> </td>
</ng-container> </ng-container>

View File

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

View File

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