alt-templatesystem-impl #29
@ -1,35 +1,24 @@
|
|||||||
import {ModelComponent} from "../ModelComponent";
|
import {ModelComponent} from "../ModelComponent";
|
||||||
import {ModelComponentType} from "../ModelComponentType";
|
import {ModelComponentType} from "../ModelComponentType";
|
||||||
import { Gamesystem } from "../gamesystems/Gamesystem";
|
import {SimpleTemplateGamesystem} from "../gamesystems/SimpleTemplateGamesystem";
|
||||||
import { ProductGamesystem } from "../gamesystems/ProductGamesystem";
|
|
||||||
import { ProductTemplateGamesystem } from "../gamesystems/ProductTemplateGamesystem";
|
|
||||||
import { SimpleGamesystem } from "../gamesystems/SimpleGamesystem";
|
|
||||||
import { SimpleTemplateGamesystem } from "../gamesystems/SimpleTemplateGamesystem";
|
|
||||||
|
|
||||||
export class Character extends ModelComponent{
|
export class Character extends ModelComponent{
|
||||||
|
|
||||||
characterSpecificGamesystems: Gamesystem<any, any>[] = []
|
private characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[] = []
|
||||||
|
|
||||||
constructor(componentName: string, componentDescription: string) {
|
constructor(componentName: string, componentDescription: string) {
|
||||||
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCharacterSpecificSimpleGamesystem(referenceSystem: SimpleGamesystem) {
|
addCharacterSpecificGamesystem(templateGamesystem: SimpleTemplateGamesystem<Character>) {
|
||||||
if(!this.findCharacterSpecificGameystemByName(referenceSystem.componentName)) {
|
if(!this.isGamesystemCharacterSpecific(templateGamesystem.componentName)) {
|
||||||
const templateGamesystem = new SimpleTemplateGamesystem(referenceSystem);
|
this.characterSpecificGamesystems.push(templateGamesystem);
|
||||||
this.characterSpecificGamesystems.push(templateGamesystem)
|
templateGamesystem.addReferenceKey(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addCharacterSpecificProductTemplateGamesystem(referenceSystem: ProductGamesystem) {
|
private isGamesystemCharacterSpecific(gamesystemName: string) {
|
||||||
if(!this.findCharacterSpecificGameystemByName(referenceSystem.componentName)) {
|
const characterSpecificGamesystem = this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName);
|
||||||
const templateGamesystem = new ProductTemplateGamesystem(referenceSystem);
|
return characterSpecificGamesystem != undefined
|
||||||
this.characterSpecificGamesystems.push(templateGamesystem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
findCharacterSpecificGameystemByName(referenceName: string) {
|
|
||||||
return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === referenceName) != 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