alt-templatesystem-impl #29
@ -2,14 +2,16 @@ import {SimpleGamesystem} from "./SimpleGamesystem";
|
||||
import {ProductGamesystem} from "./ProductGamesystem";
|
||||
import {ModelComponent} from "../ModelComponent";
|
||||
import {ModelComponentType} from "../ModelComponentType";
|
||||
import {TemplateType} from "./TemplateType";
|
||||
import {TemplateType} from "../TemplateType";
|
||||
|
||||
export abstract class Gamesystem<S, T> extends ModelComponent{
|
||||
|
||||
states: S[] = [];
|
||||
transitions: T[] = [];
|
||||
parentGamesystem: ProductGamesystem | undefined
|
||||
template: TemplateType = TemplateType.NONE
|
||||
|
||||
templateType: TemplateType = TemplateType.NORMAL
|
||||
|
||||
|
||||
constructor(gamesystemName: string, gamesystemDescription: string) {
|
||||
super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM);
|
||||
|
@ -1,14 +1,10 @@
|
||||
import {SimpleGamesystem} from "./SimpleGamesystem";
|
||||
import {SimpleTemplateState} from "./states/SimpleTemplateState";
|
||||
import {Gamesystem} from "./Gamesystem";
|
||||
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<ReferenceType> extends Gamesystem<SimpleTemplateState<ReferenceType>, SimpleTemplateTransition<ReferenceType>> {
|
||||
|
||||
createState(label: string, description: string): SimpleState | undefined {
|
||||
if(label == null) {
|
||||
return undefined;
|
||||
|
@ -6,6 +6,9 @@ import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
|
||||
import {StateParser} from "./StateParser";
|
||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
||||
import {TransitionParser} from "./TransitionParser";
|
||||
import {TemplateType} from "../../game-model/TemplateType";
|
||||
import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTemplateGamesystem";
|
||||
import {Character} from "../../game-model/characters/Character";
|
||||
|
||||
export class GamesystemParser {
|
||||
|
||||
@ -40,7 +43,11 @@ export class GamesystemParser {
|
||||
}
|
||||
|
||||
parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem {
|
||||
const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
|
||||
const templateType = gamesystemData.templateType
|
||||
let simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
|
||||
if(templateType == TemplateType.CHARACTER) {
|
||||
simpleGamesystem = new SimpleTemplateGamesystem<Character>(gamesystemData.componentName, gamesystemData.componentDescription)
|
||||
}
|
||||
|
||||
const stateParser = new StateParser(this.scriptAccounts);
|
||||
simpleGamesystem.states = stateParser.parseStates(gamesystemData.states)
|
||||
@ -48,7 +55,7 @@ export class GamesystemParser {
|
||||
const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts)
|
||||
simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions)
|
||||
|
||||
simpleGamesystem.template = gamesystemData.template;
|
||||
|
||||
return simpleGamesystem
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,11 @@ import {SimpleGamesystem} from "../game-model/gamesystems/SimpleGamesystem";
|
||||
import {ProductGamesystem} from "../game-model/gamesystems/ProductGamesystem";
|
||||
import {SerializeConstants} from "./SerializeConstants";
|
||||
import {ModelComponentType} from "../game-model/ModelComponentType";
|
||||
import {SimpleTemplateGamesystem} from "../game-model/gamesystems/SimpleTemplateGamesystem";
|
||||
|
||||
export class GamesystemSerializer {
|
||||
|
||||
private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type"]
|
||||
private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap"]
|
||||
|
||||
public static serializeGamesystems(gamesystems: Gamesystem<any, any>[]): StoreComponent[] {
|
||||
let storedGamesystems: StoreComponent[] = []
|
||||
@ -16,7 +17,7 @@ export class GamesystemSerializer {
|
||||
}
|
||||
|
||||
private static serializeSingleGamesystem(gamesystem: Gamesystem<any, any>): StoreComponent[] {
|
||||
if(gamesystem instanceof SimpleGamesystem) {
|
||||
if(gamesystem instanceof SimpleGamesystem || gamesystem instanceof SimpleTemplateGamesystem) {
|
||||
console.log("Simple Gamesystem")
|
||||
return [this.serializeSimpleGamesystem(gamesystem as SimpleGamesystem)]
|
||||
} else {
|
||||
|
@ -1,7 +1,20 @@
|
||||
{
|
||||
"componentName": "Characterstimmung",
|
||||
"componentDescription": "",
|
||||
"states": [],
|
||||
"states": [
|
||||
{
|
||||
"initial": true,
|
||||
"conditions": [],
|
||||
"stateLabel": "Fröhlich",
|
||||
"stateDescription": ""
|
||||
},
|
||||
{
|
||||
"initial": false,
|
||||
"conditions": [],
|
||||
"stateLabel": "Wütend",
|
||||
"stateDescription": ""
|
||||
}
|
||||
],
|
||||
"transitions": [],
|
||||
"template": 1
|
||||
"templateType": 1
|
||||
}
|
@ -34,5 +34,5 @@
|
||||
"endingState": "B"
|
||||
}
|
||||
],
|
||||
"template": 0
|
||||
"templateType": 0
|
||||
}
|
@ -77,5 +77,5 @@
|
||||
"endingState": "Frühling"
|
||||
}
|
||||
],
|
||||
"template": 0
|
||||
"templateType": 0
|
||||
}
|
@ -77,5 +77,5 @@
|
||||
"endingState": "Wolke"
|
||||
}
|
||||
],
|
||||
"template": 0
|
||||
"templateType": 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user