Pass Template Editing on to Character
All checks were successful
E2E Testing / test (push) Successful in 1m31s

This commit is contained in:
Sebastian Böckelmann 2024-03-22 17:30:05 +01:00
parent 10e2ca92d0
commit ef489b19ef
6 changed files with 48 additions and 4 deletions

View File

@ -3,6 +3,9 @@
<mat-expansion-panel-header>
<mat-panel-title>{{templateGamesystem.referenceGamesystem.componentName}}</mat-panel-title>
</mat-expansion-panel-header>
<app-template-gamesystem-editor [gamesystem]="templateGamesystem" [scriptAccunts]="scriptAccounts"></app-template-gamesystem-editor>
<app-template-gamesystem-editor [gamesystem]="templateGamesystem" [scriptAccunts]="scriptAccounts"
(onAddFirstTemplateState)="onAddFirstTemplateState($event)"
(onRemoveLastTemplateState)="onRemoveLastTemplateState($event)">
</app-template-gamesystem-editor>
</mat-expansion-panel>
</mat-accordion>

View File

@ -30,4 +30,12 @@ export class CharacterEditorComponent implements OnInit{
})
}
onRemoveLastTemplateState(templateGamesystem: TemplateGamesystem) {
this.character!.removeCharacterSpecificGamesystem(templateGamesystem)
}
onAddFirstTemplateState(templateGamesystem: TemplateGamesystem) {
this.character!.addCharacterSpecificGamesystem(templateGamesystem)
}
}

View File

@ -1 +1,3 @@
<app-template-state-editor [templateGamesystem]="gamesystem" [scriptAccounts]="scriptAccunts"></app-template-state-editor>
<app-template-state-editor [templateGamesystem]="gamesystem" [scriptAccounts]="scriptAccunts"
(onAddFirstTemplateState)="onAddFirstTemplateState()" (onRemoveLastTemplateState)="onRemoveLastTemplateState()"
></app-template-state-editor>

View File

@ -1,4 +1,4 @@
import {Component, Input} from '@angular/core';
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
import {Gamesystem} from "../../../project/game-model/gamesystems/Gamesystem";
@ -14,4 +14,14 @@ 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>();
onAddFirstTemplateState() {
this.addFirstTemplateStateEmitter.emit(this.gamesystem!)
}
onRemoveLastTemplateState() {
this.removeLastTemplateStateEmitter.emit(this.gamesystem!)
}
}

View File

@ -1,4 +1,4 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState";
import {TemplateGamesystem} from "../../../../project/game-model/gamesystems/TemplateGamesystem";
import {SimpleStateEditorComponent} from "../../state-editor/simple-state-editor/simple-state-editor.component";
@ -23,6 +23,8 @@ export class TemplateStateEditorComponent {
@Input() templateGamesystem: TemplateGamesystem | undefined
@Input() scriptAccounts: ScriptAccount[] = []
@Output() onAddFirstTemplateState: EventEmitter<SimpleState> = new EventEmitter<SimpleState>()
@Output() onRemoveLastTemplateState: EventEmitter<SimpleState> = new EventEmitter<SimpleState>()
dataSource = new MatTableDataSource<SimpleState>();
displayedColumns = ["name", "initial", "edit", "delete"];
@ -33,6 +35,10 @@ export class TemplateStateEditorComponent {
editedStateLabelError: boolean = false;
onExtractReferenceState(state: SimpleState) {
if(this.templateGamesystem!.templateStates.length == 0) {
this.onAddFirstTemplateState.emit(state)
}
this.templateGamesystem!.addReferenceState(state)
this.dataSource.data = this.templateGamesystem!.templateStates
}
@ -53,6 +59,10 @@ export class TemplateStateEditorComponent {
onDeleteState(state: SimpleState) {
this.templateGamesystem!.templateStates = this.templateGamesystem!.templateStates.filter(templateState => templateState.stateLabel !== state.stateLabel)
this.dataSource.data = this.templateGamesystem!.templateStates
if(this.templateGamesystem!.templateStates.length == 0) {
this.onRemoveLastTemplateState.emit(state)
}
}
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) {

View File

@ -1,9 +1,20 @@
import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType";
import {TemplateGamesystem} from "../gamesystems/TemplateGamesystem";
export class Character extends ModelComponent{
characterSpecificGamesystems: TemplateGamesystem[] = []
constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.CHARACTER);
}
addCharacterSpecificGamesystem(gamesystem: TemplateGamesystem) {
this.characterSpecificGamesystems.push(gamesystem)
}
removeCharacterSpecificGamesystem(gamesystem: TemplateGamesystem) {
this.characterSpecificGamesystems = this.characterSpecificGamesystems.filter(templateSystem => templateSystem.referenceGamesystem.componentName !== gamesystem.referenceGamesystem.componentName)
}
}