From 02ba26ea44ba682a9199182c0f67ecfa8aaeb22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 17:05:18 +0100 Subject: [PATCH] Load Conditions from Disk for States --- ...scriptaccount-action-editor.component.scss | 4 ++++ src/app/game-model/fs/ProcessLoadedProject.ts | 4 ++-- .../fs/parser/SimpleGamesystemParser.ts | 24 +++++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss index 1caa532..68b2712 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss @@ -5,3 +5,7 @@ table { .long-form { width: 100%; } + +.mat-column-edit, .mat-column-delete, .mat-column-expand { + width: 32px; +} diff --git a/src/app/game-model/fs/ProcessLoadedProject.ts b/src/app/game-model/fs/ProcessLoadedProject.ts index b6fe4d1..7c427a1 100644 --- a/src/app/game-model/fs/ProcessLoadedProject.ts +++ b/src/app/game-model/fs/ProcessLoadedProject.ts @@ -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 diff --git a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts index 2105569..34b88ea 100644 --- a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts +++ b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts @@ -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 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