diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index c9e990a..f1246c4 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -3,6 +3,9 @@ {{templateGamesystem.referenceGamesystem.componentName}} - + + diff --git a/src/app/editor/character-editor/character-editor.component.ts b/src/app/editor/character-editor/character-editor.component.ts index 4d5e3a0..40007cf 100644 --- a/src/app/editor/character-editor/character-editor.component.ts +++ b/src/app/editor/character-editor/character-editor.component.ts @@ -30,4 +30,12 @@ export class CharacterEditorComponent implements OnInit{ }) } + onRemoveLastTemplateState(templateGamesystem: TemplateGamesystem) { + this.character!.removeCharacterSpecificGamesystem(templateGamesystem) + } + + onAddFirstTemplateState(templateGamesystem: TemplateGamesystem) { + this.character!.addCharacterSpecificGamesystem(templateGamesystem) + } + } diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html index d201e9c..052645f 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html @@ -1 +1,3 @@ - + diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts index e04554d..7795b23 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts @@ -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 = new EventEmitter(); + @Output('onRemoveLastTemplateState') removeLastTemplateStateEmitter: EventEmitter = new EventEmitter(); + + onAddFirstTemplateState() { + this.addFirstTemplateStateEmitter.emit(this.gamesystem!) + } + + onRemoveLastTemplateState() { + this.removeLastTemplateStateEmitter.emit(this.gamesystem!) + } } diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-state-editor/template-state-editor.component.ts b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-state-editor/template-state-editor.component.ts index e0cb89c..bb3314a 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-state-editor/template-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-state-editor/template-state-editor.component.ts @@ -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 = new EventEmitter() + @Output() onRemoveLastTemplateState: EventEmitter = new EventEmitter() dataSource = new MatTableDataSource(); 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) { diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 07acf19..8e6b864 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -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) + } }