From 49521cba87f5157c78ae839a8a4092eb2036e239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:35:24 +0200 Subject: [PATCH] Add related Templatesystem as specified Gamesystems --- .../project/game-model/characters/Character.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 8f2fe49..a35e773 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -4,6 +4,8 @@ import {TemplateElement} from "../templates/TemplateElement"; import {TemplateGamesystem} from "../templates/TemplateGamesystem"; import {Gamesystem} from "../gamesystems/Gamesystem"; import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; +import {ProductGamesystem} from "../gamesystems/ProductGamesystem"; export class Character extends ModelComponent implements TemplateElement { @@ -13,10 +15,20 @@ export class Character extends ModelComponent implements TemplateElement { super(componentName, componentDescription, ModelComponentType.CHARACTER); } - addCharacterSpecificSimpleTemplatesystem(gamesystem: SimpleTemplateGamesystem) { + addCharacterSpecificSimpleTemplatesystem(gamesystem: Gamesystem) { if(!this.isTemplateSystemCharacterSpecific(gamesystem.componentName)) { - this.characterSpecificTemplateSystems.push(gamesystem) - gamesystem.addTemplateElement(this) + if(gamesystem instanceof SimpleTemplateGamesystem) { + this.characterSpecificTemplateSystems.push(gamesystem) + gamesystem.addTemplateElement(this) + } else if(gamesystem instanceof ProductTemplateSystem) { + this.characterSpecificTemplateSystems.push(gamesystem) + gamesystem.addTemplateElement(this) + gamesystem.innerGamesystems.forEach(innerGamesystem => this.addCharacterSpecificSimpleTemplatesystem(innerGamesystem)) + } + + if(gamesystem.parentGamesystem != undefined) { + this.addCharacterSpecificSimpleTemplatesystem(gamesystem.parentGamesystem) + } } }