ConceptCreator/src/app/project/game-model/characters/CharacterRelation.ts
Sebastian Böckelmann f98ad400e3
All checks were successful
E2E Testing / test (push) Successful in 1m34s
Fix Product Template Generation for Relations (generation was not triggered)
2024-04-19 16:07:08 +02:00

37 lines
1.7 KiB
TypeScript

import {TemplateElement} from "../templates/TemplateElement";
import {Character} from "./Character";
import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem";
import {Gamesystem} from "../gamesystems/Gamesystem";
import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem";
import {TemplateType} from "../templates/TemplateType";
import {ProductTemplateCreator} from "../templates/productGamesystem/ProductTemplateCreator";
export class CharacterRelation implements TemplateElement{
firstCharacter: Character
secondCharacter: Character
characterRelationGamesystems: ProductTemplateSystem[] = []
constructor(firstCharacter: Character, secondCharacter: Character) {
this.firstCharacter = firstCharacter;
this.secondCharacter = secondCharacter;
}
addCharacterRelationSystem(gamesystem: Gamesystem<any, any>) {
if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) {
const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION);
templateGamesystem.addChildGamesystem(gamesystem);
templateGamesystem.addChildGamesystem(gamesystem);
this.characterRelationGamesystems.push(templateGamesystem);
templateGamesystem.addTemplateElement(this);
} else {
console.log("Test")
}
}
private isGamesystemCharacterRelationSpecific(gamesystemName: string) {
return this.characterRelationGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined
}
}