Load Templatetransition as TemplateTransition and not as SimpleTransition
All checks were successful
E2E Testing / test (push) Successful in 1m56s

This commit is contained in:
Sebastian Böckelmann 2024-04-11 17:35:09 +02:00
parent 5f59726bdd
commit b9b5384ca4
2 changed files with 11 additions and 5 deletions

View File

@ -54,7 +54,7 @@ export class GamesystemParser {
simpleGamesystem.states = stateParser.parseStates(gamesystemData.states, templateType) simpleGamesystem.states = stateParser.parseStates(gamesystemData.states, templateType)
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, templateType)
return simpleGamesystem return simpleGamesystem

View File

@ -3,6 +3,8 @@ import {ScriptAccountConditionParser} from "./ScriptAccountConditionParser";
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
import {SimpleTransition} from "../../game-model/gamesystems/transitions/SimpleTransition"; import {SimpleTransition} from "../../game-model/gamesystems/transitions/SimpleTransition";
import {ScriptAccountActionParser} from "./ScriptAccountActionParser"; import {ScriptAccountActionParser} from "./ScriptAccountActionParser";
import {TemplateType} from "../../game-model/TemplateType";
import {SimpleTemplateTransition} from "../../game-model/gamesystems/transitions/SimpleTemplateTransition";
export class TransitionParser { export class TransitionParser {
@ -18,10 +20,10 @@ export class TransitionParser {
this.actionParser = new ScriptAccountActionParser(scriptAccounts) this.actionParser = new ScriptAccountActionParser(scriptAccounts)
} }
public parseTransitions(transitionData: any): SimpleTransition[] { public parseTransitions(transitionData: any, templateType: TemplateType): SimpleTransition[] {
const transitions: SimpleTransition[] = [] const transitions: SimpleTransition[] = []
for(let i=0; i<transitionData.length; i++) { for(let i=0; i<transitionData.length; i++) {
const parsedTransition = this.parseSingleTransition(transitionData[i]); const parsedTransition = this.parseSingleTransition(transitionData[i], templateType);
if(parsedTransition != undefined) { if(parsedTransition != undefined) {
transitions.push(parsedTransition) transitions.push(parsedTransition)
} }
@ -29,7 +31,7 @@ export class TransitionParser {
return transitions return transitions
} }
private parseSingleTransition(transitionData: any): SimpleTransition | undefined{ private parseSingleTransition(transitionData: any, templateType: TemplateType): SimpleTransition | undefined{
const startingState = this.findStateByLabel(transitionData.startingState) const startingState = this.findStateByLabel(transitionData.startingState)
const endingState = this.findStateByLabel(transitionData.endingState); const endingState = this.findStateByLabel(transitionData.endingState);
@ -37,7 +39,11 @@ export class TransitionParser {
return undefined return undefined
} }
const simpleTransition = new SimpleTransition(startingState, endingState) let simpleTransition = new SimpleTransition(startingState, endingState);
if(templateType === TemplateType.CHARACTER) {
simpleTransition = new SimpleTemplateTransition(startingState, endingState);
}
simpleTransition.scriptAccountConditions = this.conditionParser.parseStoredConditions(transitionData.scriptAccountConditions) simpleTransition.scriptAccountConditions = this.conditionParser.parseStoredConditions(transitionData.scriptAccountConditions)
simpleTransition.scriptAccountActions = this.actionParser.parseActions(transitionData.scriptAccountActions); simpleTransition.scriptAccountActions = this.actionParser.parseActions(transitionData.scriptAccountActions);