import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; import {SimpleState} from "../../gamesystems/SimpleState"; import {SimpleTransition} from "../../gamesystems/SimpleTransition"; export class SimpleGamesystemParser { static parseSimpleGamesystem(jsonObject: any) : SimpleGamesystem { const gamesystemName = jsonObject.componentName; const gamesystemDescription = jsonObject.componentDescription; const simpleStates = SimpleGamesystemParser.parseSimpleStates(jsonObject) const simpleTransitions = SimpleGamesystemParser.parseSimpleTransitions(jsonObject, simpleStates); const gamesystem = new SimpleGamesystem(gamesystemName, gamesystemDescription); gamesystem.states = simpleStates; gamesystem.transitions = simpleTransitions; return gamesystem; } static parseSimpleStates(jsonObject: any): SimpleState[] { const states: SimpleState[] = []; for(let i=0; i state.stateLabel === startingStateLabel); const endingState = states.find(state => state.stateLabel === endingStateLabel); if(startingState != undefined && endingState != undefined) { transitions.push(new SimpleTransition(startingState, endingState)); } else { console.error("Starting or Ending State are not defined!", startingState, endingState) } } return transitions; } }