Consider TemplateType of Gamesystems to load and store
Some checks failed
E2E Testing / test (push) Failing after 1m52s

This commit is contained in:
Sebastian Böckelmann 2024-04-11 13:56:13 +02:00
parent 9a51cb3a80
commit 61e3e90395
10 changed files with 48 additions and 12 deletions

View File

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

View File

@ -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;

View File

@ -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,13 +43,19 @@ 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)
const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts)
simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions)
return simpleGamesystem
}

View File

@ -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 {

View File

@ -1,4 +1,5 @@
{
"componentName": "Astrid Hofferson",
"componentDescription": ""
"componentDescription": "",
"characterSpecificGamesystems": []
}

View File

@ -1,4 +1,5 @@
{
"componentName": "Hicks Haddock",
"componentDescription": ""
"componentDescription": "",
"characterSpecificGamesystems": []
}

View File

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

View File

@ -33,5 +33,6 @@
"startingState": "A",
"endingState": "B"
}
]
],
"templateType": 0
}

View File

@ -76,5 +76,6 @@
"startingState": "Winter",
"endingState": "Frühling"
}
]
],
"templateType": 0
}

View File

@ -76,5 +76,6 @@
"startingState": "Schnee",
"endingState": "Wolke"
}
]
],
"templateType": 0
}