Add SimpleTemplateSystems to Character
All checks were successful
E2E Testing / test (push) Successful in 1m37s

This commit is contained in:
Sebastian Böckelmann 2024-04-13 12:52:55 +02:00
parent 7e6dd4aa27
commit 3c9efa1bd5
3 changed files with 20 additions and 3 deletions

View File

@ -1,10 +1,27 @@
import {ModelComponent} from "../ModelComponent"; import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType"; import {ModelComponentType} from "../ModelComponentType";
import {TemplateElement} from "../templates/TemplateElement"; import {TemplateElement} from "../templates/TemplateElement";
import {TemplateGamesystem} from "../templates/TemplateGamesystem";
import {Gamesystem} from "../gamesystems/Gamesystem";
import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem";
export class Character extends ModelComponent implements TemplateElement { export class Character extends ModelComponent implements TemplateElement {
characterSpecificTemplateSystems: Gamesystem<any, any>[] = []
constructor(componentName: string, componentDescription: string) { constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.CHARACTER); super(componentName, componentDescription, ModelComponentType.CHARACTER);
} }
addCharacterSpecificSimpleTemplatesystem(gamesystem: SimpleTemplateGamesystem) {
if(!this.isTemplateSystemCharacterSpecific(gamesystem.componentName)) {
this.characterSpecificTemplateSystems.push(gamesystem)
gamesystem.addTemplateElement(this)
}
}
private isTemplateSystemCharacterSpecific(gamesystemName: string) {
return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined
}
} }

View File

@ -7,7 +7,7 @@ export class SimpleTemplateState extends SimpleState {
conditionMap: Map<TemplateElement, ScriptAccountCondition[]> = new Map(); conditionMap: Map<TemplateElement, ScriptAccountCondition[]> = new Map();
addTemplateElement(templateElement: TemplateElement) { addTemplateElement(templateElement: TemplateElement) {
this.conditionMap.set(templateElement, []) this.conditionMap.set(templateElement, this.conditions)
} }
removeTemplateElement(templateElement: TemplateElement) { removeTemplateElement(templateElement: TemplateElement) {

View File

@ -8,8 +8,8 @@ export class SimpleTemplateTransition extends SimpleTransition{
actionMap: Map<TemplateElement, ScriptAccountAction[]> = new Map(); actionMap: Map<TemplateElement, ScriptAccountAction[]> = new Map();
addTemplateElement(templateElement: TemplateElement) { addTemplateElement(templateElement: TemplateElement) {
this.conditionMap.set(templateElement, []) this.conditionMap.set(templateElement, this.scriptAccountConditions.concat())
this.actionMap.set(templateElement, []) this.actionMap.set(templateElement, this.scriptAccountActions.concat())
} }
removeTemplateElement(templateElement: TemplateElement) { removeTemplateElement(templateElement: TemplateElement) {