diff --git a/src/app/project/game-model/gamesystems/Gamesystem.ts b/src/app/project/game-model/gamesystems/Gamesystem.ts index 41e13f1..e41d1a0 100644 --- a/src/app/project/game-model/gamesystems/Gamesystem.ts +++ b/src/app/project/game-model/gamesystems/Gamesystem.ts @@ -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 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); diff --git a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts index 6eabd03..022a703 100644 --- a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts +++ b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts @@ -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 extends Gamesystem, SimpleTemplateTransition> { - createState(label: string, description: string): SimpleState | undefined { if(label == null) { return undefined; diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index cc6ee69..959c3dc 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -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(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 } diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index 8ffcafc..717da47 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -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[]): StoreComponent[] { let storedGamesystems: StoreComponent[] = [] @@ -16,7 +17,7 @@ export class GamesystemSerializer { } private static serializeSingleGamesystem(gamesystem: Gamesystem): StoreComponent[] { - if(gamesystem instanceof SimpleGamesystem) { + if(gamesystem instanceof SimpleGamesystem || gamesystem instanceof SimpleTemplateGamesystem) { console.log("Simple Gamesystem") return [this.serializeSimpleGamesystem(gamesystem as SimpleGamesystem)] } else { diff --git a/testModel/gamesystems/Characterstimmung.json b/testModel/gamesystems/Characterstimmung.json index 8ff9ec1..fe49734 100644 --- a/testModel/gamesystems/Characterstimmung.json +++ b/testModel/gamesystems/Characterstimmung.json @@ -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 } \ No newline at end of file diff --git a/testModel/gamesystems/Testsystem.json b/testModel/gamesystems/Testsystem.json index 71ada4d..9c53926 100644 --- a/testModel/gamesystems/Testsystem.json +++ b/testModel/gamesystems/Testsystem.json @@ -34,5 +34,5 @@ "endingState": "B" } ], - "template": 0 + "templateType": 0 } \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Season.json b/testModel/gamesystems/Weathersystem/Season.json index 0d38734..246c9ab 100644 --- a/testModel/gamesystems/Weathersystem/Season.json +++ b/testModel/gamesystems/Weathersystem/Season.json @@ -77,5 +77,5 @@ "endingState": "Frühling" } ], - "template": 0 + "templateType": 0 } \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Weather.json b/testModel/gamesystems/Weathersystem/Weather.json index 39afb9f..4a0388d 100644 --- a/testModel/gamesystems/Weathersystem/Weather.json +++ b/testModel/gamesystems/Weathersystem/Weather.json @@ -77,5 +77,5 @@ "endingState": "Wolke" } ], - "template": 0 + "templateType": 0 } \ No newline at end of file