From 244222bc5b56c92a9e1bce273f06efc8490db7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Thu, 11 Apr 2024 13:40:40 +0200 Subject: [PATCH] Add Reference to CharacterSpecific Gamesystems in relevant characters --- .../game-model/characters/Character.ts | 29 ++++++------------- .../gamesystems/SimpleTemplateGamesystem.ts | 19 ++++++++++++ .../gamesystems/states/SimpleTemplateState.ts | 2 +- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 7b87f7b..9934a79 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -1,35 +1,24 @@ import {ModelComponent} from "../ModelComponent"; import {ModelComponentType} from "../ModelComponentType"; -import { Gamesystem } from "../gamesystems/Gamesystem"; -import { ProductGamesystem } from "../gamesystems/ProductGamesystem"; -import { ProductTemplateGamesystem } from "../gamesystems/ProductTemplateGamesystem"; -import { SimpleGamesystem } from "../gamesystems/SimpleGamesystem"; -import { SimpleTemplateGamesystem } from "../gamesystems/SimpleTemplateGamesystem"; +import {SimpleTemplateGamesystem} from "../gamesystems/SimpleTemplateGamesystem"; export class Character extends ModelComponent{ - characterSpecificGamesystems: Gamesystem[] = [] + private characterSpecificGamesystems: SimpleTemplateGamesystem[] = [] constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); } - addCharacterSpecificSimpleGamesystem(referenceSystem: SimpleGamesystem) { - if(!this.findCharacterSpecificGameystemByName(referenceSystem.componentName)) { - const templateGamesystem = new SimpleTemplateGamesystem(referenceSystem); - this.characterSpecificGamesystems.push(templateGamesystem) + addCharacterSpecificGamesystem(templateGamesystem: SimpleTemplateGamesystem) { + if(!this.isGamesystemCharacterSpecific(templateGamesystem.componentName)) { + this.characterSpecificGamesystems.push(templateGamesystem); + templateGamesystem.addReferenceKey(this); } } - addCharacterSpecificProductTemplateGamesystem(referenceSystem: ProductGamesystem) { - if(!this.findCharacterSpecificGameystemByName(referenceSystem.componentName)) { - const templateGamesystem = new ProductTemplateGamesystem(referenceSystem); - this.characterSpecificGamesystems.push(templateGamesystem) - } - } - - - findCharacterSpecificGameystemByName(referenceName: string) { - return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === referenceName) != undefined + private isGamesystemCharacterSpecific(gamesystemName: string) { + const characterSpecificGamesystem = this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName); + return characterSpecificGamesystem != undefined } } diff --git a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts index 4e635ae..6eabd03 100644 --- a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts +++ b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts @@ -5,6 +5,7 @@ import {SimpleTransition} from "./transitions/SimpleTransition"; import {SimpleState} from "./states/SimpleState"; import {SimpleTemplateTransition} from "./transitions/SimpleTemplateTransition"; import {TemplateType} from "../TemplateType"; +import {state} from "@angular/animations"; export class SimpleTemplateGamesystem extends Gamesystem, SimpleTemplateTransition> { @@ -52,4 +53,22 @@ export class SimpleTemplateGamesystem extends Gamesystem { + if(!state.conditionMap.has(reference)) { + state.conditionMap.set(reference, state.conditions.concat()) + } + }) + + this.transitions.forEach(transition => { + if(!transition.conditions.has(reference)) { + transition.conditions.set(reference, transition.scriptAccountConditions.concat()) + } + + if(!transition.actions.has(reference)) { + transition.actions.set(reference, transition.scriptAccountActions.concat()) + } + }) + } + } diff --git a/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts b/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts index f10055c..52bb80c 100644 --- a/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts +++ b/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts @@ -3,6 +3,6 @@ import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; export class SimpleTemplateState extends SimpleState { - conditionMap: Map = new Map() + conditionMap: Map = new Map() }