Add Reference to CharacterSpecific Gamesystems in relevant characters
All checks were successful
E2E Testing / test (push) Successful in 2m9s
All checks were successful
E2E Testing / test (push) Successful in 2m9s
This commit is contained in:
parent
312a684a17
commit
3aaf505365
@ -1,9 +1,24 @@
|
|||||||
import {ModelComponent} from "../ModelComponent";
|
import {ModelComponent} from "../ModelComponent";
|
||||||
import {ModelComponentType} from "../ModelComponentType";
|
import {ModelComponentType} from "../ModelComponentType";
|
||||||
|
import {SimpleTemplateGamesystem} from "../gamesystems/SimpleTemplateGamesystem";
|
||||||
|
|
||||||
export class Character extends ModelComponent{
|
export class Character extends ModelComponent{
|
||||||
|
|
||||||
|
private characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[] = []
|
||||||
|
|
||||||
constructor(componentName: string, componentDescription: string) {
|
constructor(componentName: string, componentDescription: string) {
|
||||||
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addCharacterSpecificGamesystem(templateGamesystem: SimpleTemplateGamesystem<Character>) {
|
||||||
|
if(!this.isGamesystemCharacterSpecific(templateGamesystem.componentName)) {
|
||||||
|
this.characterSpecificGamesystems.push(templateGamesystem);
|
||||||
|
templateGamesystem.addReferenceKey(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private isGamesystemCharacterSpecific(gamesystemName: string) {
|
||||||
|
const characterSpecificGamesystem = this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName);
|
||||||
|
return characterSpecificGamesystem != undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import {SimpleTransition} from "./transitions/SimpleTransition";
|
|||||||
import {SimpleState} from "./states/SimpleState";
|
import {SimpleState} from "./states/SimpleState";
|
||||||
import {SimpleTemplateTransition} from "./transitions/SimpleTemplateTransition";
|
import {SimpleTemplateTransition} from "./transitions/SimpleTemplateTransition";
|
||||||
import {TemplateType} from "../TemplateType";
|
import {TemplateType} from "../TemplateType";
|
||||||
|
import {state} from "@angular/animations";
|
||||||
|
|
||||||
export class SimpleTemplateGamesystem<ReferenceType> extends Gamesystem<SimpleTemplateState<ReferenceType>, SimpleTemplateTransition<ReferenceType>> {
|
export class SimpleTemplateGamesystem<ReferenceType> extends Gamesystem<SimpleTemplateState<ReferenceType>, SimpleTemplateTransition<ReferenceType>> {
|
||||||
|
|
||||||
@ -52,4 +53,22 @@ export class SimpleTemplateGamesystem<ReferenceType> extends Gamesystem<SimpleTe
|
|||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addReferenceKey(reference: ReferenceType) {
|
||||||
|
this.states.forEach(state => {
|
||||||
|
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())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@ import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
|
|||||||
|
|
||||||
export class SimpleTemplateState<ReferenceType> extends SimpleState {
|
export class SimpleTemplateState<ReferenceType> extends SimpleState {
|
||||||
|
|
||||||
conditionMap: Map<ReferenceType, ScriptAccountCondition> = new Map<ReferenceType, ScriptAccountCondition>()
|
conditionMap: Map<ReferenceType, ScriptAccountCondition[]> = new Map<ReferenceType, ScriptAccountCondition[]>()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user