From 413d16392be8bc1f6b9e66fd8864c6026a522e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 18:07:11 +0100 Subject: [PATCH] Load Character Specific States of Character Specific Gamesystems --- .../character-editor/character-editor.component.ts | 11 ++++++++++- .../template-gamesystem-editor.component.ts | 2 +- .../template-state-editor.component.ts | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app/editor/character-editor/character-editor.component.ts b/src/app/editor/character-editor/character-editor.component.ts index 40007cf..d431c7b 100644 --- a/src/app/editor/character-editor/character-editor.component.ts +++ b/src/app/editor/character-editor/character-editor.component.ts @@ -23,13 +23,22 @@ export class CharacterEditorComponent implements OnInit{ ngOnInit() { this.referenceGamesystems.forEach(referenceGamesystem => { if(referenceGamesystem instanceof SimpleGamesystem) { - this.templateSimpleGamesystems.push(new TemplateGamesystem(referenceGamesystem)) + const characterSpecificGamesystem = this.findReferencedGamesystemInCharacter(referenceGamesystem.componentName) + if(characterSpecificGamesystem != undefined) { + this.templateSimpleGamesystems.push(characterSpecificGamesystem) + } else { + this.templateSimpleGamesystems.push(new TemplateGamesystem(referenceGamesystem)) + } } else { this.templateProductGamesystems.push(referenceGamesystem as ProductGamesystem) } }) } + private findReferencedGamesystemInCharacter(referenceGamesystemName: string) { + return this.character!.characterSpecificGamesystems.find(system => system.referenceGamesystem.componentName === referenceGamesystemName) + } + onRemoveLastTemplateState(templateGamesystem: TemplateGamesystem) { this.character!.removeCharacterSpecificGamesystem(templateGamesystem) } 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 7795b23..6d94a87 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, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnChanges, 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"; 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 bb3314a..44c5125 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, EventEmitter, Input, Output, ViewChild} from '@angular/core'; +import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, 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"; @@ -19,7 +19,7 @@ import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems ]), ], }) -export class TemplateStateEditorComponent { +export class TemplateStateEditorComponent implements OnChanges { @Input() templateGamesystem: TemplateGamesystem | undefined @Input() scriptAccounts: ScriptAccount[] = [] @@ -34,6 +34,10 @@ export class TemplateStateEditorComponent { editedStateLabelError: boolean = false; + ngOnChanges() { + this.dataSource.data = this.templateGamesystem!.templateStates + } + onExtractReferenceState(state: SimpleState) { if(this.templateGamesystem!.templateStates.length == 0) { this.onAddFirstTemplateState.emit(state)