Load Conditions from Disk for States
All checks were successful
E2E Testing / test (push) Successful in 1m30s
All checks were successful
E2E Testing / test (push) Successful in 1m30s
This commit is contained in:
parent
413d5eb925
commit
02ba26ea44
@ -5,3 +5,7 @@ table {
|
||||
.long-form {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mat-column-edit, .mat-column-delete, .mat-column-expand {
|
||||
width: 32px;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export class ProcessLoadedProject {
|
||||
console.log("Loaded Model should be an instance of recursivemodel")
|
||||
if(parsedJsonString.hasOwnProperty('states') && parsedJsonString.hasOwnProperty('transitions')) {
|
||||
//SimpleGamesystem
|
||||
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString);
|
||||
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString, gameModel.scriptAccounts);
|
||||
const parentModel: ProductGamesystem = gameModel.findGamesystem(recursiveLoadModel.parentLoadModelname) as ProductGamesystem
|
||||
parentModel.addChildGamesystem(simpleGamesystem);
|
||||
} else {
|
||||
@ -61,7 +61,7 @@ export class ProcessLoadedProject {
|
||||
//Top Gamesystem
|
||||
if(parsedJsonString.hasOwnProperty('states') && parsedJsonString.hasOwnProperty('transitions')) {
|
||||
//SimpleGamesystem
|
||||
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString);
|
||||
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString, gameModel.scriptAccounts);
|
||||
gameModel.addGamesystem(simpleGamesystem);
|
||||
} else {
|
||||
//ProductGamesystem
|
||||
|
@ -1,13 +1,15 @@
|
||||
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
|
||||
import {SimpleState} from "../../gamesystems/states/SimpleState";
|
||||
import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition";
|
||||
import {ScriptAccount} from "../../scriptAccounts/ScriptAccount";
|
||||
import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition";
|
||||
|
||||
export class SimpleGamesystemParser {
|
||||
|
||||
static parseSimpleGamesystem(jsonObject: any) : SimpleGamesystem {
|
||||
static parseSimpleGamesystem(jsonObject: any, scriptAccounts: ScriptAccount[] = []) : SimpleGamesystem {
|
||||
const gamesystemName = jsonObject.componentName;
|
||||
const gamesystemDescription = jsonObject.componentDescription;
|
||||
const simpleStates = SimpleGamesystemParser.parseSimpleStates(jsonObject)
|
||||
const simpleStates = SimpleGamesystemParser.parseSimpleStates(jsonObject, scriptAccounts)
|
||||
const simpleTransitions = SimpleGamesystemParser.parseSimpleTransitions(jsonObject, simpleStates);
|
||||
|
||||
const gamesystem = new SimpleGamesystem(gamesystemName, gamesystemDescription);
|
||||
@ -17,16 +19,28 @@ export class SimpleGamesystemParser {
|
||||
return gamesystem;
|
||||
}
|
||||
|
||||
static parseSimpleStates(jsonObject: any): SimpleState[] {
|
||||
static parseSimpleStates(jsonObject: any, scriptAccounts: ScriptAccount[] = []): SimpleState[] {
|
||||
const states: SimpleState[] = [];
|
||||
for(let i=0; i<jsonObject.states.length; i++) {
|
||||
const state = new SimpleState("", "");
|
||||
Object.assign(state, jsonObject.states[i]);
|
||||
const state = new SimpleState(jsonObject.states[i].stateLabel, jsonObject.states[i].stateDescription);
|
||||
const conditions = jsonObject.states[i].conditions
|
||||
for(let j=0; j<conditions.length; j++) {
|
||||
const searchedScriptAccount = scriptAccounts.find(scriptAccount => scriptAccount.componentName === conditions[j].scriptAccount)
|
||||
if(searchedScriptAccount != undefined) {
|
||||
const scriptAccountCondition =
|
||||
ScriptAccountCondition.constructScriptAccountCondition(searchedScriptAccount, conditions[j].minValue, conditions[j].maxValue)
|
||||
|
||||
state.conditions.push(scriptAccountCondition!)
|
||||
}
|
||||
}
|
||||
|
||||
states.push(state);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static parseSimpleTransitions(jsonObject: any, states: SimpleState[]): SimpleTransition[] {
|
||||
const transitions: SimpleTransition[] = [];
|
||||
for(let i=0; i<jsonObject.transitions.length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user