alt-templatesystem-impl #29

Closed
sebastian wants to merge 23 commits from alt-templatesystem-impl into character-specific-gamesystems
8 changed files with 34 additions and 15 deletions
Showing only changes of commit 9d530e48f9 - Show all commits

View File

@ -2,14 +2,16 @@ import {SimpleGamesystem} from "./SimpleGamesystem";
import {ProductGamesystem} from "./ProductGamesystem"; import {ProductGamesystem} from "./ProductGamesystem";
import {ModelComponent} from "../ModelComponent"; import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType"; import {ModelComponentType} from "../ModelComponentType";
import {TemplateType} from "./TemplateType"; import {TemplateType} from "../TemplateType";
export abstract class Gamesystem<S, T> extends ModelComponent{ export abstract class Gamesystem<S, T> extends ModelComponent{
states: S[] = []; states: S[] = [];
transitions: T[] = []; transitions: T[] = [];
parentGamesystem: ProductGamesystem | undefined parentGamesystem: ProductGamesystem | undefined
template: TemplateType = TemplateType.NONE
templateType: TemplateType = TemplateType.NORMAL
constructor(gamesystemName: string, gamesystemDescription: string) { constructor(gamesystemName: string, gamesystemDescription: string) {
super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM); super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM);

View File

@ -1,14 +1,10 @@
import {SimpleGamesystem} from "./SimpleGamesystem";
import {SimpleTemplateState} from "./states/SimpleTemplateState"; import {SimpleTemplateState} from "./states/SimpleTemplateState";
import {Gamesystem} from "./Gamesystem"; import {Gamesystem} from "./Gamesystem";
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>> {
createState(label: string, description: string): SimpleState | undefined { createState(label: string, description: string): SimpleState | undefined {
if(label == null) { if(label == null) {
return undefined; return undefined;

View File

@ -6,6 +6,9 @@ import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
import {StateParser} from "./StateParser"; import {StateParser} from "./StateParser";
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
import {TransitionParser} from "./TransitionParser"; 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 { export class GamesystemParser {
@ -40,7 +43,11 @@ export class GamesystemParser {
} }
parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem { 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); const stateParser = new StateParser(this.scriptAccounts);
simpleGamesystem.states = stateParser.parseStates(gamesystemData.states) simpleGamesystem.states = stateParser.parseStates(gamesystemData.states)
@ -48,7 +55,7 @@ export class GamesystemParser {
const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts)
simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions) simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions)
simpleGamesystem.template = gamesystemData.template;
return simpleGamesystem return simpleGamesystem
} }

View File

@ -4,10 +4,11 @@ import {SimpleGamesystem} from "../game-model/gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../game-model/gamesystems/ProductGamesystem"; import {ProductGamesystem} from "../game-model/gamesystems/ProductGamesystem";
import {SerializeConstants} from "./SerializeConstants"; import {SerializeConstants} from "./SerializeConstants";
import {ModelComponentType} from "../game-model/ModelComponentType"; import {ModelComponentType} from "../game-model/ModelComponentType";
import {SimpleTemplateGamesystem} from "../game-model/gamesystems/SimpleTemplateGamesystem";
export class GamesystemSerializer { 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[] { public static serializeGamesystems(gamesystems: Gamesystem<any, any>[]): StoreComponent[] {
let storedGamesystems: StoreComponent[] = [] let storedGamesystems: StoreComponent[] = []
@ -16,7 +17,7 @@ export class GamesystemSerializer {
} }
private static serializeSingleGamesystem(gamesystem: Gamesystem<any, any>): StoreComponent[] { private static serializeSingleGamesystem(gamesystem: Gamesystem<any, any>): StoreComponent[] {
if(gamesystem instanceof SimpleGamesystem) { if(gamesystem instanceof SimpleGamesystem || gamesystem instanceof SimpleTemplateGamesystem) {
console.log("Simple Gamesystem") console.log("Simple Gamesystem")
return [this.serializeSimpleGamesystem(gamesystem as SimpleGamesystem)] return [this.serializeSimpleGamesystem(gamesystem as SimpleGamesystem)]
} else { } else {

View File

@ -1,7 +1,20 @@
{ {
"componentName": "Characterstimmung", "componentName": "Characterstimmung",
"componentDescription": "", "componentDescription": "",
"states": [], "states": [
"transitions": [], {
"template": 1 "initial": true,
"conditions": [],
"stateLabel": "Fröhlich",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "Wütend",
"stateDescription": ""
}
],
"transitions": [],
"templateType": 1
} }

View File

@ -34,5 +34,5 @@
"endingState": "B" "endingState": "B"
} }
], ],
"template": 0 "templateType": 0
} }

View File

@ -77,5 +77,5 @@
"endingState": "Frühling" "endingState": "Frühling"
} }
], ],
"template": 0 "templateType": 0
} }

View File

@ -77,5 +77,5 @@
"endingState": "Wolke" "endingState": "Wolke"
} }
], ],
"template": 0 "templateType": 0
} }