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 {
|
.long-form {
|
||||||
width: 100%;
|
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")
|
console.log("Loaded Model should be an instance of recursivemodel")
|
||||||
if(parsedJsonString.hasOwnProperty('states') && parsedJsonString.hasOwnProperty('transitions')) {
|
if(parsedJsonString.hasOwnProperty('states') && parsedJsonString.hasOwnProperty('transitions')) {
|
||||||
//SimpleGamesystem
|
//SimpleGamesystem
|
||||||
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString);
|
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString, gameModel.scriptAccounts);
|
||||||
const parentModel: ProductGamesystem = gameModel.findGamesystem(recursiveLoadModel.parentLoadModelname) as ProductGamesystem
|
const parentModel: ProductGamesystem = gameModel.findGamesystem(recursiveLoadModel.parentLoadModelname) as ProductGamesystem
|
||||||
parentModel.addChildGamesystem(simpleGamesystem);
|
parentModel.addChildGamesystem(simpleGamesystem);
|
||||||
} else {
|
} else {
|
||||||
@ -61,7 +61,7 @@ export class ProcessLoadedProject {
|
|||||||
//Top Gamesystem
|
//Top Gamesystem
|
||||||
if(parsedJsonString.hasOwnProperty('states') && parsedJsonString.hasOwnProperty('transitions')) {
|
if(parsedJsonString.hasOwnProperty('states') && parsedJsonString.hasOwnProperty('transitions')) {
|
||||||
//SimpleGamesystem
|
//SimpleGamesystem
|
||||||
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString);
|
const simpleGamesystem: SimpleGamesystem = SimpleGamesystemParser.parseSimpleGamesystem(parsedJsonString, gameModel.scriptAccounts);
|
||||||
gameModel.addGamesystem(simpleGamesystem);
|
gameModel.addGamesystem(simpleGamesystem);
|
||||||
} else {
|
} else {
|
||||||
//ProductGamesystem
|
//ProductGamesystem
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
|
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
|
||||||
import {SimpleState} from "../../gamesystems/states/SimpleState";
|
import {SimpleState} from "../../gamesystems/states/SimpleState";
|
||||||
import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition";
|
import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition";
|
||||||
|
import {ScriptAccount} from "../../scriptAccounts/ScriptAccount";
|
||||||
|
import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition";
|
||||||
|
|
||||||
export class SimpleGamesystemParser {
|
export class SimpleGamesystemParser {
|
||||||
|
|
||||||
static parseSimpleGamesystem(jsonObject: any) : SimpleGamesystem {
|
static parseSimpleGamesystem(jsonObject: any, scriptAccounts: ScriptAccount[] = []) : SimpleGamesystem {
|
||||||
const gamesystemName = jsonObject.componentName;
|
const gamesystemName = jsonObject.componentName;
|
||||||
const gamesystemDescription = jsonObject.componentDescription;
|
const gamesystemDescription = jsonObject.componentDescription;
|
||||||
const simpleStates = SimpleGamesystemParser.parseSimpleStates(jsonObject)
|
const simpleStates = SimpleGamesystemParser.parseSimpleStates(jsonObject, scriptAccounts)
|
||||||
const simpleTransitions = SimpleGamesystemParser.parseSimpleTransitions(jsonObject, simpleStates);
|
const simpleTransitions = SimpleGamesystemParser.parseSimpleTransitions(jsonObject, simpleStates);
|
||||||
|
|
||||||
const gamesystem = new SimpleGamesystem(gamesystemName, gamesystemDescription);
|
const gamesystem = new SimpleGamesystem(gamesystemName, gamesystemDescription);
|
||||||
@ -17,16 +19,28 @@ export class SimpleGamesystemParser {
|
|||||||
return gamesystem;
|
return gamesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parseSimpleStates(jsonObject: any): SimpleState[] {
|
static parseSimpleStates(jsonObject: any, scriptAccounts: ScriptAccount[] = []): SimpleState[] {
|
||||||
const states: SimpleState[] = [];
|
const states: SimpleState[] = [];
|
||||||
for(let i=0; i<jsonObject.states.length; i++) {
|
for(let i=0; i<jsonObject.states.length; i++) {
|
||||||
const state = new SimpleState("", "");
|
const state = new SimpleState(jsonObject.states[i].stateLabel, jsonObject.states[i].stateDescription);
|
||||||
Object.assign(state, jsonObject.states[i]);
|
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);
|
states.push(state);
|
||||||
}
|
}
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static parseSimpleTransitions(jsonObject: any, states: SimpleState[]): SimpleTransition[] {
|
static parseSimpleTransitions(jsonObject: any, states: SimpleState[]): SimpleTransition[] {
|
||||||
const transitions: SimpleTransition[] = [];
|
const transitions: SimpleTransition[] = [];
|
||||||
for(let i=0; i<jsonObject.transitions.length; i++) {
|
for(let i=0; i<jsonObject.transitions.length; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user