From f38626683e279fb3b12e23bbcec0f83f8fb3e81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 15:38:51 +0100 Subject: [PATCH 01/58] Refactor Gamesystems --- .../productGamesystems/CreateProductStates.spec.ts | 2 +- .../CreateProductTransitions.spec.ts | 2 +- .../productGamesystems/EqualInnerStates.spec.ts | 2 +- .../ProductStateGeneration.spec.ts | 2 +- .../productGamesystems/ProductStateTrainer.ts | 4 ++-- src/app/app.component.ts | 2 +- src/app/editor/editor.component.ts | 4 ++-- .../gamesystem-editor/gamesystem-editor.component.ts | 4 ++-- .../LeafGamesystemCalculator.ts | 6 +++--- .../product-state-editor.component.ts | 8 ++++---- .../simple-state-editor.component.ts | 4 ++-- .../product-transition-editor.component.ts | 4 ++-- .../simple-transition-editor.component.ts | 6 +++--- src/app/game-model/GameModel.ts | 4 ++-- .../game-model/fs/parser/SimpleGamesystemParser.ts | 4 ++-- src/app/game-model/gamesystems/ProductGamesystem.ts | 10 +++++----- src/app/game-model/gamesystems/SimpleGamesystem.ts | 12 ++++++------ .../gamesystems/{ => states}/ProductState.ts | 4 ++-- .../gamesystems/{ => states}/SimpleState.ts | 4 ++-- src/app/game-model/gamesystems/{ => states}/State.ts | 2 +- .../{ => transitions}/ProductTransition.ts | 2 +- .../{ => transitions}/SimpleTransition.ts | 2 +- .../gamesystems/{ => transitions}/Transition.ts | 2 +- .../gamescript-overview.component.ts | 4 ++-- 24 files changed, 50 insertions(+), 50 deletions(-) rename src/app/game-model/gamesystems/{ => states}/ProductState.ts (91%) rename src/app/game-model/gamesystems/{ => states}/SimpleState.ts (80%) rename src/app/game-model/gamesystems/{ => states}/State.ts (90%) rename src/app/game-model/gamesystems/{ => transitions}/ProductTransition.ts (84%) rename src/app/game-model/gamesystems/{ => transitions}/SimpleTransition.ts (68%) rename src/app/game-model/gamesystems/{ => transitions}/Transition.ts (89%) diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts index 3ee77ef..165f9c6 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts @@ -11,7 +11,7 @@ import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/SimpleState"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; test.describe('Test Create ProductStates', () => { test("Adding already existent ProductState", async () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts index fc7dcab..dd687f3 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {ProductState} from "../../../../src/app/game-model/gamesystems/ProductState"; +import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; test.describe('Test Create ProductTransitions', () => { test("Test ProductTransition Creation with invalid inputs", async ()=> { diff --git a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts index 1b6415e..5479bf2 100644 --- a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts @@ -11,7 +11,7 @@ import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/SimpleState"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; test.describe('Test Check Equal of Innerstates', () => { test("Test invalid input for equal checking", async()=> { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts index c9991f3..9e71230 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts @@ -11,7 +11,7 @@ import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/SimpleState"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; import {ProductSystemGenerationTrainer} from "./ProductSystemGenerationTrainer"; test.describe('Test Create ProductStates', () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts index e473f9f..797ad83 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts @@ -1,7 +1,7 @@ import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../src/app/game-model/gamesystems/ProductState"; -import {ProductTransition} from "../../../../src/app/game-model/gamesystems/ProductTransition"; +import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; +import {ProductTransition} from "../../../../src/app/game-model/gamesystems/transitions/ProductTransition"; export class ProductStateTrainer { static INNERSTATE_LETTER_1 = "A"; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2c24f78..b416d2c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -16,7 +16,7 @@ import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount"; import {GamescriptOverviewComponent} from "./side-overviews/gamescript-overview/gamescript-overview.component"; import {SimpleGamesystem} from "./game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "./game-model/gamesystems/ProductGamesystem"; -import {ProductState} from "./game-model/gamesystems/ProductState"; +import {ProductState} from "./game-model/gamesystems/states/ProductState"; import {LoadModel} from "../../app/LoadModel"; import {LoadedProject} from "../../app/LoadedProject"; import {ProcessLoadedProject} from "./game-model/fs/ProcessLoadedProject"; diff --git a/src/app/editor/editor.component.ts b/src/app/editor/editor.component.ts index 77a8433..38ec9f8 100644 --- a/src/app/editor/editor.component.ts +++ b/src/app/editor/editor.component.ts @@ -4,8 +4,8 @@ import {ModelComponent} from "../game-model/ModelComponent"; import {ModelComponentType} from "../game-model/ModelComponentType"; import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount"; import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; -import {State} from "../game-model/gamesystems/State"; -import {Transition} from "../game-model/gamesystems/Transition"; +import {State} from "../game-model/gamesystems/states/State"; +import {Transition} from "../game-model/gamesystems/transitions/Transition"; @Component({ selector: 'app-editor', diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index e21373f..8bff8e1 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -1,8 +1,8 @@ import {Component, EventEmitter, Input, Output} from '@angular/core'; import {GameModel} from "../../game-model/GameModel"; import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; -import {State} from "../../game-model/gamesystems/State"; -import {Transition} from "../../game-model/gamesystems/Transition"; +import {State} from "../../game-model/gamesystems/states/State"; +import {Transition} from "../../game-model/gamesystems/transitions/Transition"; import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts b/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts index b505d93..d1951be 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts @@ -1,9 +1,9 @@ import {Gamesystem} from "../../../game-model/gamesystems/Gamesystem"; import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem"; -import {State} from "../../../game-model/gamesystems/State"; -import {ProductState} from "../../../game-model/gamesystems/ProductState"; -import {SimpleState} from "../../../game-model/gamesystems/SimpleState"; +import {State} from "../../../game-model/gamesystems/states/State"; +import {ProductState} from "../../../game-model/gamesystems/states/ProductState"; +import {SimpleState} from "../../../game-model/gamesystems/states/SimpleState"; export class LeafGamesystemCalculator { diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts index 79a5880..9b15ede 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts @@ -4,11 +4,11 @@ import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesys import { MatTableDataSource } from "@angular/material/table"; -import {SimpleState} from "../../../../game-model/gamesystems/SimpleState"; -import {State} from "../../../../game-model/gamesystems/State"; +import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; +import {State} from "../../../../game-model/gamesystems/states/State"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; -import {ProductTransition} from "../../../../game-model/gamesystems/ProductTransition"; -import {ProductState} from "../../../../game-model/gamesystems/ProductState"; +import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; +import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; @Component({ selector: 'app-product-state-editor', diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 3d4d1ed..8177aa6 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -1,10 +1,10 @@ import {Component, Input, OnInit} from '@angular/core'; -import {SimpleState} from "../../../../game-model/gamesystems/SimpleState"; +import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; import {MatTableDataSource} from "@angular/material/table"; import {animate, state, style, transition, trigger} from "@angular/animations"; import {MatSnackBar} from "@angular/material/snack-bar"; import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../game-model/gamesystems/ProductState"; +import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; @Component({ diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index 8a22044..6e99ce8 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -5,8 +5,8 @@ import { MatTableDataSource } from "@angular/material/table"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; -import {ProductTransition} from "../../../../game-model/gamesystems/ProductTransition"; -import {ProductState} from "../../../../game-model/gamesystems/ProductState"; +import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; +import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; class DisplayedColumnName { displayedName: string internalName: string diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index b159e13..5c8b3d4 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -10,10 +10,10 @@ import { MatTable, MatTableDataSource } from "@angular/material/table"; -import {SimpleTransition} from "../../../../game-model/gamesystems/SimpleTransition"; +import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/SimpleTransition"; import {animate, state, style, transition, trigger} from "@angular/animations"; -import {SimpleState} from "../../../../game-model/gamesystems/SimpleState"; -import {ProductTransition} from "../../../../game-model/gamesystems/ProductTransition"; +import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; +import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; @Component({ diff --git a/src/app/game-model/GameModel.ts b/src/app/game-model/GameModel.ts index 487f53f..e184c18 100644 --- a/src/app/game-model/GameModel.ts +++ b/src/app/game-model/GameModel.ts @@ -1,7 +1,7 @@ import {Gamesystem} from "./gamesystems/Gamesystem"; import {ScriptAccount} from "./scriptAccounts/ScriptAccount"; -import {Transition} from "./gamesystems/Transition"; -import {State} from "./gamesystems/State"; +import {Transition} from "./gamesystems/transitions/Transition"; +import {State} from "./gamesystems/states/State"; import {ProductGamesystem} from "./gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "./gamesystems/SimpleGamesystem"; import {StorageModel} from "./fs/StorageModel"; diff --git a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts index b36c282..2105569 100644 --- a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts +++ b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts @@ -1,6 +1,6 @@ import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; -import {SimpleState} from "../../gamesystems/SimpleState"; -import {SimpleTransition} from "../../gamesystems/SimpleTransition"; +import {SimpleState} from "../../gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition"; export class SimpleGamesystemParser { diff --git a/src/app/game-model/gamesystems/ProductGamesystem.ts b/src/app/game-model/gamesystems/ProductGamesystem.ts index 7795942..1757ca4 100644 --- a/src/app/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/game-model/gamesystems/ProductGamesystem.ts @@ -1,9 +1,9 @@ import {Gamesystem} from "./Gamesystem"; -import {ProductState} from "./ProductState"; -import {ProductTransition} from "./ProductTransition"; -import {State} from "./State"; -import {Transition} from "./Transition"; -import {SimpleState} from "./SimpleState"; +import {ProductState} from "./states/ProductState"; +import {ProductTransition} from "./transitions/ProductTransition"; +import {State} from "./states/State"; +import {Transition} from "./transitions/Transition"; +import {SimpleState} from "./states/SimpleState"; import {SimpleGamesystem} from "./SimpleGamesystem"; import {GameModel} from "../GameModel"; import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer"; diff --git a/src/app/game-model/gamesystems/SimpleGamesystem.ts b/src/app/game-model/gamesystems/SimpleGamesystem.ts index d5b4f1f..dedb8f2 100644 --- a/src/app/game-model/gamesystems/SimpleGamesystem.ts +++ b/src/app/game-model/gamesystems/SimpleGamesystem.ts @@ -1,10 +1,10 @@ import {Gamesystem} from "./Gamesystem"; -import {SimpleState} from "./SimpleState"; -import {SimpleTransition} from "./SimpleTransition"; -import {State} from "./State"; -import {Transition} from "./Transition"; -import {ProductState} from "./ProductState"; -import {ProductTransition} from "./ProductTransition"; +import {SimpleState} from "./states/SimpleState"; +import {SimpleTransition} from "./transitions/SimpleTransition"; +import {State} from "./states/State"; +import {Transition} from "./transitions/Transition"; +import {ProductState} from "./states/ProductState"; +import {ProductTransition} from "./transitions/ProductTransition"; import {ProductGamesystem} from "./ProductGamesystem"; export class SimpleGamesystem extends Gamesystem { diff --git a/src/app/game-model/gamesystems/ProductState.ts b/src/app/game-model/gamesystems/states/ProductState.ts similarity index 91% rename from src/app/game-model/gamesystems/ProductState.ts rename to src/app/game-model/gamesystems/states/ProductState.ts index 4831c3d..8a4c504 100644 --- a/src/app/game-model/gamesystems/ProductState.ts +++ b/src/app/game-model/gamesystems/states/ProductState.ts @@ -1,7 +1,7 @@ -import {ProductTransition} from "./ProductTransition"; +import {ProductTransition} from "../transitions/ProductTransition"; import {State} from "./State"; import {SimpleState} from "./SimpleState"; -import {Transition} from "./Transition"; +import {Transition} from "../transitions/Transition"; export class ProductState extends State { innerStates: State[] = []; diff --git a/src/app/game-model/gamesystems/SimpleState.ts b/src/app/game-model/gamesystems/states/SimpleState.ts similarity index 80% rename from src/app/game-model/gamesystems/SimpleState.ts rename to src/app/game-model/gamesystems/states/SimpleState.ts index e570ece..259f8fe 100644 --- a/src/app/game-model/gamesystems/SimpleState.ts +++ b/src/app/game-model/gamesystems/states/SimpleState.ts @@ -1,6 +1,6 @@ import {State} from "./State"; -import {SimpleTransition} from "./SimpleTransition"; -import {Transition} from "./Transition"; +import {SimpleTransition} from "../transitions/SimpleTransition"; +import {Transition} from "../transitions/Transition"; export class SimpleState extends State { stateLabel: string = ""; diff --git a/src/app/game-model/gamesystems/State.ts b/src/app/game-model/gamesystems/states/State.ts similarity index 90% rename from src/app/game-model/gamesystems/State.ts rename to src/app/game-model/gamesystems/states/State.ts index d6b78de..234c4ce 100644 --- a/src/app/game-model/gamesystems/State.ts +++ b/src/app/game-model/gamesystems/states/State.ts @@ -1,4 +1,4 @@ -import {Transition} from "./Transition"; +import {Transition} from "../transitions/Transition"; export abstract class State> { diff --git a/src/app/game-model/gamesystems/ProductTransition.ts b/src/app/game-model/gamesystems/transitions/ProductTransition.ts similarity index 84% rename from src/app/game-model/gamesystems/ProductTransition.ts rename to src/app/game-model/gamesystems/transitions/ProductTransition.ts index ebd0be5..04f86f0 100644 --- a/src/app/game-model/gamesystems/ProductTransition.ts +++ b/src/app/game-model/gamesystems/transitions/ProductTransition.ts @@ -1,5 +1,5 @@ import {Transition} from "./Transition"; -import {ProductState} from "./ProductState"; +import {ProductState} from "../states/ProductState"; export class ProductTransition extends Transition { diff --git a/src/app/game-model/gamesystems/SimpleTransition.ts b/src/app/game-model/gamesystems/transitions/SimpleTransition.ts similarity index 68% rename from src/app/game-model/gamesystems/SimpleTransition.ts rename to src/app/game-model/gamesystems/transitions/SimpleTransition.ts index e7356ed..2ddc912 100644 --- a/src/app/game-model/gamesystems/SimpleTransition.ts +++ b/src/app/game-model/gamesystems/transitions/SimpleTransition.ts @@ -1,4 +1,4 @@ -import {SimpleState} from "./SimpleState"; +import {SimpleState} from "../states/SimpleState"; import {Transition} from "./Transition"; export class SimpleTransition extends Transition { diff --git a/src/app/game-model/gamesystems/Transition.ts b/src/app/game-model/gamesystems/transitions/Transition.ts similarity index 89% rename from src/app/game-model/gamesystems/Transition.ts rename to src/app/game-model/gamesystems/transitions/Transition.ts index 5f75cbd..86c2c9c 100644 --- a/src/app/game-model/gamesystems/Transition.ts +++ b/src/app/game-model/gamesystems/transitions/Transition.ts @@ -1,4 +1,4 @@ -import {State} from "./State"; +import {State} from "../states/State"; export abstract class Transition> { startingState: S diff --git a/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts b/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts index 4c07292..a43a659 100644 --- a/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts +++ b/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts @@ -1,7 +1,7 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; -import {State} from "../../game-model/gamesystems/State"; -import {Transition} from "../../game-model/gamesystems/Transition"; +import {State} from "../../game-model/gamesystems/states/State"; +import {Transition} from "../../game-model/gamesystems/transitions/Transition"; import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; import {FlatTreeControl} from "@angular/cdk/tree"; import { From f07cb270f148a4a3308c1e1fb64ea374a5b95ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 16:04:31 +0100 Subject: [PATCH 02/58] Add and Remove Actions from Transition --- .../gamesystems/actions/AddActions.spec.ts | 59 +++++++++++++++++++ .../gamesystems/actions/RemoveActions.spec.ts | 33 +++++++++++ .../actions/SimpleActionTrainer.ts | 25 ++++++++ .../actions/ScriptAccountAction.ts | 12 ++++ .../gamesystems/transitions/Transition.ts | 24 ++++++++ 5 files changed, 153 insertions(+) create mode 100644 e2e/game-model/gamesystems/actions/AddActions.spec.ts create mode 100644 e2e/game-model/gamesystems/actions/RemoveActions.spec.ts create mode 100644 e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts create mode 100644 src/app/game-model/gamesystems/actions/ScriptAccountAction.ts diff --git a/e2e/game-model/gamesystems/actions/AddActions.spec.ts b/e2e/game-model/gamesystems/actions/AddActions.spec.ts new file mode 100644 index 0000000..3e1fd12 --- /dev/null +++ b/e2e/game-model/gamesystems/actions/AddActions.spec.ts @@ -0,0 +1,59 @@ + +import { test, expect } from '@playwright/test'; +import {GamesystemTrainer} from "../GamesystemTrainer"; +import {SimpleActionTrainer} from "./SimpleActionTrainer"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +test.describe('Test Create SimpleActions', () => { + + test('Test creating gamesystem with invalid name', async => { + const gameModel = GamesystemTrainer.givenEmptyGameModel(); + let result = gameModel.createGamesystem(undefined, undefined); + expect(result).toBeUndefined(); + + result = gameModel.createGamesystem(null, undefined); + expect(result).toBeUndefined(); + }) + + test("Adding invalid actions", async () => { + const transition = SimpleActionTrainer.withEmptyActions(); + + transition.addScriptAccountAction(null); + expect(transition.scriptAccountActions.length).toEqual(0); + + transition.addScriptAccountAction(undefined); + expect(transition.scriptAccountActions.length).toEqual(0); + }) + + test("Adding not existing action", async () => { + const transition = SimpleActionTrainer.withEmptyActions(); + const scriptAccount = new ScriptAccount("test", ""); + + const action = new ScriptAccountAction(scriptAccount, 10); + transition.addScriptAccountAction(action); + + expect(transition.scriptAccountActions.length).toEqual(1); + expect(transition.scriptAccountActions[0].scriptAccount).toEqual(action.scriptAccount); + expect(transition.scriptAccountActions[0].changingValue).toEqual(10); + }) + + test("Adding existing action", async () => { + const transition = SimpleActionTrainer.withSingleAction(); + const action = transition.scriptAccountActions[0]; + + transition.addScriptAccountAction(action); + expect(transition.scriptAccountActions.length).toEqual(1); + expect(transition.scriptAccountActions[0].changingValue).toEqual(20); + expect(transition.scriptAccountActions[0].scriptAccount).toEqual(action.scriptAccount); + }) + + test("Adding not existing action into non empty actions", async () => { + const transition = SimpleActionTrainer.withSingleAction(); + + const scriptAccount = new ScriptAccount("Tes", ""); + + transition.addScriptAccountAction(new ScriptAccountAction(scriptAccount, 10)); + expect(transition.scriptAccountActions.length).toEqual(2); + }) + +}); diff --git a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts new file mode 100644 index 0000000..931f7c9 --- /dev/null +++ b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts @@ -0,0 +1,33 @@ + +import { test, expect } from '@playwright/test'; +import {GamesystemTrainer} from "../GamesystemTrainer"; +import {SimpleActionTrainer} from "./SimpleActionTrainer"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +test.describe('Test Remove SimpleActions', () => { + + test("Test Removing invalid Actions", async () => { + const transition = SimpleActionTrainer.withSingleAction(); + + transition.removeScriptAccountAction(null); + expect(transition.scriptAccountActions.length).toEqual(1) + + transition.removeScriptAccountAction(undefined); + expect(transition.scriptAccountActions.length).toEqual(1); + }) + + test("Test removing unknown scriptAccount Action", async () => { + const transition = SimpleActionTrainer.withSingleAction(); + const scriptAccount = new ScriptAccount("Test"); + + transition.removeScriptAccountAction(scriptAccount); + expect(transition.scriptAccountActions.length).toEqual(1); + }) + + test("Test removing known ScriptAccount", async () => { + const transition = SimpleActionTrainer.withSingleAction(); + transition.removeScriptAccountAction(transition.scriptAccountActions[0].scriptAccount) + expect(transition.scriptAccountActions.length).toEqual(0); + }) +}); diff --git a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts new file mode 100644 index 0000000..219ae4d --- /dev/null +++ b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts @@ -0,0 +1,25 @@ +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {Script} from "node:vm"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; + +export class SimpleActionTrainer { + static withEmptyActions() { + const startingState = new SimpleState("Wolkig", ""); + const endingState = new SimpleState("Schnee", ""); + + return new SimpleTransition(startingState, endingState); + } + + static withSingleAction() { + const startingState = new SimpleState("Wolkig", ""); + const endingState = new SimpleState("Schnee", ""); + + const scriptAccount = new ScriptAccount("Temperature", ""); + const transition = new SimpleTransition(startingState, endingState); + transition.scriptAccountActions.push(new ScriptAccountAction(scriptAccount, 10)); + + return transition; + } +} diff --git a/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts b/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts new file mode 100644 index 0000000..d258760 --- /dev/null +++ b/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts @@ -0,0 +1,12 @@ +import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; + +export class ScriptAccountAction { + scriptAccount: ScriptAccount + changingValue: number = 0; + + + constructor(scriptAccount: ScriptAccount, changingValue: number) { + this.scriptAccount = scriptAccount; + this.changingValue = changingValue; + } +} diff --git a/src/app/game-model/gamesystems/transitions/Transition.ts b/src/app/game-model/gamesystems/transitions/Transition.ts index 86c2c9c..ca302c5 100644 --- a/src/app/game-model/gamesystems/transitions/Transition.ts +++ b/src/app/game-model/gamesystems/transitions/Transition.ts @@ -1,9 +1,12 @@ import {State} from "../states/State"; +import {ScriptAccountAction} from "../actions/ScriptAccountAction"; +import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; export abstract class Transition> { startingState: S endingState: S + scriptAccountActions: ScriptAccountAction[] = []; constructor(startingState: S, endingState: S) { this.startingState = startingState; @@ -12,4 +15,25 @@ export abstract class Transition> { this.startingState.addOutgoingTransition(this); this.endingState.addIncomingTransition(this); } + + addScriptAccountAction(scriptAccountAction: ScriptAccountAction) { + if(scriptAccountAction != undefined) { + const searchedScriptAccount = this.findScriptAccountActionByScriptAccount(scriptAccountAction.scriptAccount); + if(searchedScriptAccount == undefined) { + this.scriptAccountActions.push(scriptAccountAction) + } else { + searchedScriptAccount.changingValue += scriptAccountAction.changingValue; + } + } + } + + removeScriptAccountAction(scriptAccount: ScriptAccount) { + if(scriptAccount != undefined) { + this.scriptAccountActions = this.scriptAccountActions.filter(sA => sA.scriptAccount.componentName !== scriptAccount.componentName); + } + } + + findScriptAccountActionByScriptAccount(scriptAccount: ScriptAccount) { + return this.scriptAccountActions.find(sA => sA.scriptAccount.componentName === scriptAccount.componentName); + } } From b5e3b8ee5380a2016156ae26bbba5aa35a1f0a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 17:05:46 +0100 Subject: [PATCH 03/58] Visualize and Edit Actions for Transitions --- src/app/app.component.html | 2 +- src/app/app.module.ts | 120 +++++++++--------- src/app/editor/editor.component.html | 3 +- src/app/editor/editor.component.ts | 1 + .../gamesystem-editor.component.html | 2 +- .../gamesystem-editor.component.ts | 10 +- .../simple-gamesystem-editor.component.html | 4 +- .../simple-gamesystem-editor.component.ts | 3 +- .../product-transition-editor.component.ts | 1 - ...scriptaccount-action-editor.component.html | 45 +++++++ ...scriptaccount-action-editor.component.scss | 7 + ...iptaccount-action-editor.component.spec.ts | 23 ++++ .../scriptaccount-action-editor.component.ts | 53 ++++++++ .../simple-transition-editor.component.html | 2 +- .../simple-transition-editor.component.ts | 13 +- 15 files changed, 211 insertions(+), 78 deletions(-) create mode 100644 src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html create mode 100644 src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss create mode 100644 src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts create mode 100644 src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index 85d1f15..9b85948 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -27,7 +27,7 @@
- +
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5009811..87fe6af 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -62,6 +62,9 @@ import { } from "./editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component"; import {MatTooltip} from "@angular/material/tooltip"; import {MatCard, MatCardContent} from "@angular/material/card"; +import { + ScriptaccountActionEditorComponent +} from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -81,65 +84,66 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl SimpleTransitionEditorComponent, ProductTransitionEditorComponent, ProductStateEditorComponent, - ProductGamesystemEditorComponent - ], - imports: [ - BrowserModule, - FormsModule, - HttpClientModule, - CoreModule, - SharedModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: httpLoaderFactory, - deps: [HttpClient] - } - }), - BrowserAnimationsModule, - MatIcon, - MatToolbar, - MatButton, - MatFormField, - MatInput, - MatDrawerContainer, - MatDrawer, - MatIconButton, - MatMenuTrigger, - MatMenu, - MatMenuItem, - MatListItem, - MatActionList, - MatTabGroup, - MatTab, - MatTabLabel, - MatLabel, - MatFormField, - ReactiveFormsModule, - MatError, - MatDialogTitle, - MatDialogContent, - MatDialogActions, - MatMiniFabButton, - MatTreeModule, - MatTable, - MatColumnDef, - MatHeaderCell, - MatHeaderCellDef, - MatCellDef, - MatCell, - MatHeaderRow, - MatRow, - MatHeaderRowDef, - MatRowDef, - MatCheckbox, - MatSelect, - MatOption, - MatHint, - MatTooltip, - MatCard, - MatCardContent + ProductGamesystemEditorComponent, + ScriptaccountActionEditorComponent ], + imports: [ + BrowserModule, + FormsModule, + HttpClientModule, + CoreModule, + SharedModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: httpLoaderFactory, + deps: [HttpClient] + } + }), + BrowserAnimationsModule, + MatIcon, + MatToolbar, + MatButton, + MatFormField, + MatInput, + MatDrawerContainer, + MatDrawer, + MatIconButton, + MatMenuTrigger, + MatMenu, + MatMenuItem, + MatListItem, + MatActionList, + MatTabGroup, + MatTab, + MatTabLabel, + MatLabel, + MatFormField, + ReactiveFormsModule, + MatError, + MatDialogTitle, + MatDialogContent, + MatDialogActions, + MatMiniFabButton, + MatTreeModule, + MatTable, + MatColumnDef, + MatHeaderCell, + MatHeaderCellDef, + MatCellDef, + MatCell, + MatHeaderRow, + MatRow, + MatHeaderRowDef, + MatRowDef, + MatCheckbox, + MatSelect, + MatOption, + MatHint, + MatTooltip, + MatCard, + MatCardContent + ], providers: [], bootstrap: [AppComponent] }) diff --git a/src/app/editor/editor.component.html b/src/app/editor/editor.component.html index b43ce41..f51aa7a 100644 --- a/src/app/editor/editor.component.html +++ b/src/app/editor/editor.component.html @@ -12,7 +12,8 @@ [scriptAccount]="convertModelComponentToScriptAccount(modelComponent)"> + (onOpenGamesystemEditor)="openGameModelComponent($event)" + [scriptAccounts]="gameModel!.scriptAccounts"> diff --git a/src/app/editor/editor.component.ts b/src/app/editor/editor.component.ts index 38ec9f8..a1e377f 100644 --- a/src/app/editor/editor.component.ts +++ b/src/app/editor/editor.component.ts @@ -16,6 +16,7 @@ export class EditorComponent { gameModelComponents: ModelComponent[] = []; @Output("onModelNameUpdate") onModelNameUpdateEmitter = new EventEmitter(); activeTab: number = this.gameModelComponents.length; + @Input() gameModel: GameModel | undefined openGameModelComponent(gameModelComponent: ModelComponent) { if(!this.gameModelComponents.includes(gameModelComponent)) { diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index 624b252..2eb564e 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,3 +1,3 @@ - + diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index 8bff8e1..a35cc1b 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -1,21 +1,27 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {GameModel} from "../../game-model/GameModel"; import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; import {State} from "../../game-model/gamesystems/states/State"; import {Transition} from "../../game-model/gamesystems/transitions/Transition"; import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-gamesystem-editor', templateUrl: './gamesystem-editor.component.html', styleUrl: './gamesystem-editor.component.scss' }) -export class GamesystemEditorComponent { +export class GamesystemEditorComponent implements OnInit{ @Input() gamesystem: Gamesystem, Transition> | undefined + @Input() scriptAccounts: ScriptAccount[] = []; @Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter(); + ngOnInit() { + console.log("GamesystemEditor: ", this.scriptAccounts.length) + } + isSimpleGamesystem() { return this.gamesystem instanceof SimpleGamesystem; } diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html index 4b24edd..cc28a3d 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html @@ -1,4 +1,4 @@ - +
- +
diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts index ab4fcc5..5baf0e9 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts @@ -1,6 +1,7 @@ import {Component, Input} from '@angular/core'; import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; import {MatTableDataSource} from "@angular/material/table"; +import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-simple-gamesystem-editor', @@ -10,7 +11,7 @@ import {MatTableDataSource} from "@angular/material/table"; export class SimpleGamesystemEditorComponent { @Input() simpleGamesystem: SimpleGamesystem | undefined - + @Input() scriptAccunts: ScriptAccount[] = [] } diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index 6e99ce8..e6bbea0 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -64,7 +64,6 @@ export class ProductTransitionEditorComponent implements OnInit{ } const leafStates = LeafGamesystemCalculator.calcLeafStates(state); - console.log(leafStates) return leafStates[index]; } diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html new file mode 100644 index 0000000..af7af1b --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + +
ScriptAccount + {{action.scriptAccount.componentName}} + + ScriptAccount + + {{scriptAccount.componentName}} + + + Value + {{action.changingValue}} + + Value + + + + + + + + + +
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 new file mode 100644 index 0000000..1caa532 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss @@ -0,0 +1,7 @@ +table { + width: 100%; +} + +.long-form { + width: 100%; +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts new file mode 100644 index 0000000..3c4a363 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ScriptaccountActionEditorComponent } from './scriptaccount-action-editor.component'; + +describe('ScriptaccountActionEditorComponent', () => { + let component: ScriptaccountActionEditorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ScriptaccountActionEditorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ScriptaccountActionEditorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts new file mode 100644 index 0000000..f2b8860 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -0,0 +1,53 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {Transition} from "../../../../game-model/gamesystems/transitions/Transition"; +import {MatTableDataSource} from "@angular/material/table"; +import {ScriptAccountAction} from "../../../../game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; + +@Component({ + selector: 'app-scriptaccount-action-editor', + templateUrl: './scriptaccount-action-editor.component.html', + styleUrl: './scriptaccount-action-editor.component.scss' +}) +export class ScriptaccountActionEditorComponent implements OnInit{ + @Input() transition: Transition | undefined + @Input() scriptAccounts: ScriptAccount[] = [] + + dataSource: MatTableDataSource = new MatTableDataSource(); + displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete']; + + editedAction: ScriptAccountAction | undefined + addedAction: ScriptAccountAction | undefined + + ngOnInit() { + this.dataSource.data = this.transition!.scriptAccountActions.map(action => action); + console.log("# ScriptAccounts", this.scriptAccounts.length) + } + + editAction(scriptAccountAction: ScriptAccountAction) { + this.editedAction = scriptAccountAction; + } + + createNewAction() { + this.addedAction = new ScriptAccountAction(new ScriptAccount("", ""), 0); + this.editedAction = this.addedAction; + + this.dataSource.data = this.dataSource.data.concat(this.addedAction); + } + + finishEditing() { + if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') { + this.transition?.addScriptAccountAction(this.addedAction) + console.log(this.addedAction.scriptAccount) + this.dataSource.data = this.transition!.scriptAccountActions; + console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length) + this.addedAction = undefined; + } + this.editedAction = undefined; + } + + deleteAction(action: ScriptAccountAction) { + this.transition!.removeScriptAccountAction(action.scriptAccount) + this.dataSource.data = this.transition!.scriptAccountActions + } +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 0834eb0..837048b 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -40,7 +40,7 @@
-

Expanded Detail

+
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index 5c8b3d4..efa965a 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -1,21 +1,12 @@ import {Component, Input, OnInit} from '@angular/core'; -import {GameModel} from "../../../../game-model/GameModel"; import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import { - MatCell, - MatCellDef, - MatColumnDef, - MatHeaderCell, - MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef, - MatTable, MatTableDataSource } from "@angular/material/table"; import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/SimpleTransition"; import {animate, state, style, transition, trigger} from "@angular/animations"; import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; -import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; -import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; - +import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-simple-transition-editor', templateUrl: './simple-transition-editor.component.html', @@ -31,6 +22,7 @@ import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGame export class SimpleTransitionEditorComponent implements OnInit { @Input() gamesystem: SimpleGamesystem | undefined + @Input() scriptAccounts: ScriptAccount[] = [] displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"]; dataSource = new MatTableDataSource(); columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; @@ -49,6 +41,7 @@ export class SimpleTransitionEditorComponent implements OnInit { this.dataSource.filterPredicate = (data: SimpleTransition, filter: string) => { return [data.startingState, data.endingState].some((state) => state.stateLabel.toLowerCase().includes(filter)) } + console.log("TransitionEditor: ", this.scriptAccounts.length) } addTransition() { From 4a1f4e4c52e1a29bf10cf8ee0f5b194c73d88ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 18:15:36 +0100 Subject: [PATCH 04/58] Create ScriptAccountConditions --- .../conditions/ConditionCreation.spec.ts | 55 +++++++++++++++++++ .../conditions/ScriptAccountCondition.ts | 20 +++++++ 2 files changed, 75 insertions(+) create mode 100644 e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts create mode 100644 src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts diff --git a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts new file mode 100644 index 0000000..9b1239c --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts @@ -0,0 +1,55 @@ + +import { test, expect } from '@playwright/test'; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import exp = require("node:constants"); +test.describe('Test Create Gamesystems', () => { + + test("Test creation with null/undefined parameters", async () => { + let result = ScriptAccountCondition.constructScriptAccountCondition(null, 1, 2); + expect(result).toBeUndefined() + + result = ScriptAccountCondition.constructScriptAccountCondition(undefined, 1, 2); + expect(result).toBeUndefined(); + + result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), null, 2); + expect(result).toBeUndefined(); + + result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), undefined, 2); + expect(result).toBeUndefined(); + + result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), 1, undefined); + expect(result).toBeUndefined(); + + result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""),1, null); + expect(result).toBeUndefined(); + }) + + test("Test Creation with swapped Min Max Parameter", async () => { + let result = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), 2, 1); + expect(result).toBeUndefined(); + }) + + test("Test Correct Condition Creation", async () => { + const scriptAccount = new ScriptAccount("Test", ""); + + let result = ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 1, 2); + expect(result).toBeDefined(); + expect(result!.scriptAccount).toEqual(scriptAccount) + expect(result!.minValue).toEqual(1); + expect(result!.maxValue).toEqual(2) + + result = ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, -10, 2); + expect(result).toBeDefined(); + expect(result!.scriptAccount).toEqual(scriptAccount) + expect(result!.minValue).toEqual(-10); + expect(result!.maxValue).toEqual(2) + + result = ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, -20, -10); + expect(result).toBeDefined(); + expect(result!.scriptAccount).toEqual(scriptAccount) + expect(result!.minValue).toEqual(-20); + expect(result!.maxValue).toEqual(-10) + }) + +}); diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts new file mode 100644 index 0000000..aa04cd9 --- /dev/null +++ b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts @@ -0,0 +1,20 @@ +import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; +export class ScriptAccountCondition { + scriptAccount: ScriptAccount + minValue: number + maxValue: number + + + private constructor(scriptAccount: ScriptAccount, minValue: number, maxValue: number) { + this.scriptAccount = scriptAccount; + this.minValue = minValue; + this.maxValue = maxValue; + } + + static constructScriptAccountCondition(scriptAccount: ScriptAccount, minValue: number, maxValue: number) { + if(scriptAccount == undefined || minValue == undefined || maxValue == undefined || minValue > maxValue) return undefined + return new ScriptAccountCondition(scriptAccount, minValue, maxValue) + } + + +} From 75a4122641441df1b44c44fbe8779d486f10e376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 18:37:40 +0100 Subject: [PATCH 05/58] Check if conditions are contradicting each other --- .../conditions/ConditionContradicting.spec.ts | 43 +++++++++++++++++++ .../conditions/ConditionTrainer.ts | 14 ++++++ .../conditions/ScriptAccountCondition.ts | 9 ++++ .../gamesystems/transitions/Transition.ts | 14 ++++++ 4 files changed, 80 insertions(+) create mode 100644 e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts create mode 100644 e2e/game-model/gamesystems/conditions/ConditionTrainer.ts diff --git a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts new file mode 100644 index 0000000..8a26afc --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts @@ -0,0 +1,43 @@ + +import { test, expect } from '@playwright/test'; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import exp = require("node:constants"); +import {ConditionTrainer} from "./ConditionTrainer"; +import {Conditional} from "@angular/compiler"; +test.describe('Test Contradicting Conditions', () => { + + test("Test contradicting conditions", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + + let contradictingCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.maxValue + 10, condition.maxValue+200); + expect(condition.isContradicting(contradictingCondition)).toBeTruthy(); + + contradictingCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-100, condition.minValue-50); + expect(condition.isContradicting(contradictingCondition)).toBeTruthy(); + }) + + test("Test intersecting conditions", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + let otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-1, condition.minValue+1); + expect(condition.isContradicting(otherCondition)).toBeFalsy(); + + otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.maxValue-1, condition.maxValue+1); + expect(condition.isContradicting(otherCondition)).toBeFalsy(); + + otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-1, condition.maxValue+1); + expect(condition.isContradicting(otherCondition)).toBeFalsy(); + + expect(condition.isContradicting(condition)).toBeFalsy(); + }) + + test("Test contradicting conditions with different ScriptAccount", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + const otherCondition = ScriptAccountCondition.constructScriptAccountCondition( + new ScriptAccount("Another test", ""), condition.minValue-20, condition.minValue-10); + + expect(condition.isContradicting(otherCondition)).toBeFalsy(); + }) + + +}); diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts new file mode 100644 index 0000000..d08077f --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -0,0 +1,14 @@ +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; + +export class ConditionTrainer { + static withSimpleCondition(): ScriptAccountCondition { + const scriptAccount = new ScriptAccount("Test", ""); + return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10); + } + + static withSimpleOtherCondition(): ScriptAccountCondition { + const scriptAccount = new ScriptAccount("Another Test", ""); + return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10); + } +} diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts index aa04cd9..6d741be 100644 --- a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts +++ b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts @@ -16,5 +16,14 @@ export class ScriptAccountCondition { return new ScriptAccountCondition(scriptAccount, minValue, maxValue) } + extendCondition(condition: ScriptAccountCondition) { + + } + + isContradicting(condition: ScriptAccountCondition) { + return condition.scriptAccount === this.scriptAccount && + (this.maxValue < condition.minValue || this.minValue > condition.maxValue) + } + } diff --git a/src/app/game-model/gamesystems/transitions/Transition.ts b/src/app/game-model/gamesystems/transitions/Transition.ts index ca302c5..48e9170 100644 --- a/src/app/game-model/gamesystems/transitions/Transition.ts +++ b/src/app/game-model/gamesystems/transitions/Transition.ts @@ -1,12 +1,14 @@ import {State} from "../states/State"; import {ScriptAccountAction} from "../actions/ScriptAccountAction"; import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; export abstract class Transition> { startingState: S endingState: S scriptAccountActions: ScriptAccountAction[] = []; + scriptAccountConditions: ScriptAccountCondition[] = []; constructor(startingState: S, endingState: S) { this.startingState = startingState; @@ -36,4 +38,16 @@ export abstract class Transition> { findScriptAccountActionByScriptAccount(scriptAccount: ScriptAccount) { return this.scriptAccountActions.find(sA => sA.scriptAccount.componentName === scriptAccount.componentName); } + + addScriptAccountCondition(scriptAccountCondition: ScriptAccountCondition) { + + } + + removeScriptAccountCondition(scriptAccount: ScriptAccount) { + + } + + findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount) { + + } } From d667a66b79c6ba246e3b1ff6ae750516cdb784c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 18:49:24 +0100 Subject: [PATCH 06/58] Expand Conditions --- .../conditions/ConditionExpansion.spec.ts | 44 +++++++++++++++++++ .../conditions/ConditionTrainer.ts | 5 +-- .../conditions/ScriptAccountCondition.ts | 5 ++- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts diff --git a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts new file mode 100644 index 0000000..d2b859c --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts @@ -0,0 +1,44 @@ + +import { test, expect } from '@playwright/test'; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import exp = require("node:constants"); +import {ConditionTrainer} from "./ConditionTrainer"; +test.describe('Test Expand Conditions', () => { + + test("Test expansion with contradiccting Conditions", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + const otherCondition = ConditionTrainer.withContradictingCondition(condition); + + condition.extendCondition(otherCondition) + expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue); + expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue); + }) + + test("Test lower expansion of Conditions", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-10, condition.minValue+10) + + condition.extendCondition(otherCondition); + expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue-10) + expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue); + }) + + test("Test higher expansion of conditions", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.maxValue-10, condition.maxValue+10) + + condition.extendCondition(otherCondition) + expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue) + expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue+10) + }) + + test("Test higher and lower Expansion of Conditions", async () => { + const condition = ConditionTrainer.withSimpleCondition(); + const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-10, condition.maxValue+10); + + condition.extendCondition(otherCondition); + expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue-10) + expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue+10) + }) +}); diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts index d08077f..ac7b947 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -7,8 +7,7 @@ export class ConditionTrainer { return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10); } - static withSimpleOtherCondition(): ScriptAccountCondition { - const scriptAccount = new ScriptAccount("Another Test", ""); - return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10); + static withContradictingCondition(condition: ScriptAccountCondition): ScriptAccountCondition { + return ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-20, condition.minValue-10); } } diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts index 6d741be..9284c5a 100644 --- a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts +++ b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts @@ -17,7 +17,10 @@ export class ScriptAccountCondition { } extendCondition(condition: ScriptAccountCondition) { - + if(!this.isContradicting(condition)) { + this.minValue = Math.min(this.minValue, condition.minValue); + this.maxValue = Math.max(this.maxValue, condition.maxValue); + } } isContradicting(condition: ScriptAccountCondition) { From f6b22583c816d2ca406e438aedaaf9a2524d99a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 19:06:38 +0100 Subject: [PATCH 07/58] Add Conditions --- .../AddTransitionConditions.spec.ts | 41 +++++++++++++++++++ .../conditions/ConditionTrainer.ts | 4 ++ .../conditions/TransitionConditionTrainer.ts | 24 +++++++++++ .../gamesystems/transitions/Transition.ts | 15 +++++-- 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts create mode 100644 e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts diff --git a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts new file mode 100644 index 0000000..c9fb7a9 --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts @@ -0,0 +1,41 @@ + +import { test, expect } from '@playwright/test'; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import exp = require("node:constants"); +import {ConditionTrainer} from "./ConditionTrainer"; +import {Conditional} from "@angular/compiler"; +import {TransitionConditionTrainer} from "./TransitionConditionTrainer"; +import {transition} from "@angular/animations"; +test.describe('Test Adding Conditions To Transitions', () => { + + test("Test adding not contradicting Conditions", async () => { + const transition = TransitionConditionTrainer.withTransitionWithCondition(); + const condition = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("Test", ""), -200, -100); + + transition.addScriptAccountCondition(condition); + expect(transition.scriptAccountConditions.length).toEqual(2); + expect(transition.scriptAccountConditions.includes(condition)).toBeTruthy(); + }) + + test("Test adding contradicting Conditions", async () => { + const transition = TransitionConditionTrainer.withTransitionWithCondition(); + const condition = ConditionTrainer.withContradictingCondition(transition.scriptAccountConditions[0]); + + transition.addScriptAccountCondition(condition) + expect(transition.scriptAccountConditions.length).toEqual(1); + expect(transition.scriptAccountConditions.includes(condition)).toBeFalsy(); + }) + + test("Test expanding Conditions", async () => { + const transition = TransitionConditionTrainer.withTransitionWithCondition(); + const condition = ConditionTrainer.withExpendingCondition(transition.scriptAccountConditions[0]); + + transition.addScriptAccountCondition(condition); + expect(transition.scriptAccountConditions.length).toEqual(1); + expect(transition.scriptAccountConditions.includes(condition)).toBeFalsy(); + expect(transition.scriptAccountConditions[0].minValue).toEqual(-10) + expect(transition.scriptAccountConditions[0].maxValue).toEqual(20) + }) + +}); diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts index ac7b947..ea4587c 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -10,4 +10,8 @@ export class ConditionTrainer { static withContradictingCondition(condition: ScriptAccountCondition): ScriptAccountCondition { return ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-20, condition.minValue-10); } + + static withExpendingCondition(condition: ScriptAccountCondition): ScriptAccount { + return ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-10, condition.maxValue+10); + } } diff --git a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts new file mode 100644 index 0000000..ba97347 --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts @@ -0,0 +1,24 @@ +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +export class TransitionConditionTrainer { + static withTransitionWithoutConditions() { + const startingState = new SimpleState("StartingState", ""); + const endingState = new SimpleState("EndingState", ""); + + return new SimpleTransition(startingState, endingState); + } + + static withTransitionWithCondition() { + const startingState = new SimpleState("StartingState", ""); + const endingState = new SimpleState("EndingState", ""); + + const transition = new SimpleTransition(startingState, endingState); + + const scriptAccount = new ScriptAccount("ScriptAccount", ""); + transition.scriptAccountConditions.push(ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10)!) + + return transition; + } +} diff --git a/src/app/game-model/gamesystems/transitions/Transition.ts b/src/app/game-model/gamesystems/transitions/Transition.ts index 48e9170..e4a5e39 100644 --- a/src/app/game-model/gamesystems/transitions/Transition.ts +++ b/src/app/game-model/gamesystems/transitions/Transition.ts @@ -40,14 +40,21 @@ export abstract class Transition> { } addScriptAccountCondition(scriptAccountCondition: ScriptAccountCondition) { - + const existingScriptAccountCondition = this.findScriptAccountConditionByScriptAccount(scriptAccountCondition.scriptAccount); + if(existingScriptAccountCondition != undefined) { + if(!existingScriptAccountCondition.isContradicting(scriptAccountCondition)) { + existingScriptAccountCondition.extendCondition(scriptAccountCondition) + } + } else { + this.scriptAccountConditions.push(scriptAccountCondition); + } } removeScriptAccountCondition(scriptAccount: ScriptAccount) { - + this.scriptAccountConditions = this.scriptAccountConditions.filter(condition => condition.scriptAccount !== scriptAccount); } - findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount) { - + findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount): ScriptAccountCondition | undefined { + return this.scriptAccountConditions.find(condition => condition.scriptAccount === scriptAccount); } } From 49154058fcf48bbd939f8a19798709d61096cc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 19:07:24 +0100 Subject: [PATCH 08/58] Expanding conditions only when they belong to the same scriptAccount --- .../game-model/gamesystems/conditions/ScriptAccountCondition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts index 9284c5a..5592421 100644 --- a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts +++ b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts @@ -17,7 +17,7 @@ export class ScriptAccountCondition { } extendCondition(condition: ScriptAccountCondition) { - if(!this.isContradicting(condition)) { + if(!this.isContradicting(condition) && this.scriptAccount === condition.scriptAccount) { this.minValue = Math.min(this.minValue, condition.minValue); this.maxValue = Math.max(this.maxValue, condition.maxValue); } From 80dcfb33bfb52344127d4465bcc230312f263414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 17 Feb 2024 21:50:57 +0100 Subject: [PATCH 09/58] Introduce Conditions to State and simple (not functional ConditionEditor) --- src/app/app.module.ts | 6 +- ...iptaccount-condition-editor.component.html | 56 +++++++++++++++++++ ...iptaccount-condition-editor.component.scss | 0 ...account-condition-editor.component.spec.ts | 23 ++++++++ ...criptaccount-condition-editor.component.ts | 49 ++++++++++++++++ .../simple-transition-editor.component.html | 2 + .../simple-transition-editor.component.ts | 11 ++++ .../game-model/gamesystems/states/State.ts | 23 ++++++++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html create mode 100644 src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss create mode 100644 src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts create mode 100644 src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 87fe6af..69fde6f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -65,6 +65,9 @@ import {MatCard, MatCardContent} from "@angular/material/card"; import { ScriptaccountActionEditorComponent } from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; +import { + ScriptaccountConditionEditorComponent +} from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -85,7 +88,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl ProductTransitionEditorComponent, ProductStateEditorComponent, ProductGamesystemEditorComponent, - ScriptaccountActionEditorComponent + ScriptaccountActionEditorComponent, + ScriptaccountConditionEditorComponent ], imports: [ BrowserModule, diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html new file mode 100644 index 0000000..654d45f --- /dev/null +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ScriptAccount + {{condition.scriptAccount.componentName}} + + ScriptAccount + + {{scriptAccount.componentName}} + + + Minimal Value + {{condition.minValue}} + + Minimal Value + + + Maximal Value + {{condition.minValue}} + + Maximal Value + + + + + + + + + +
diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts new file mode 100644 index 0000000..d833447 --- /dev/null +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ScriptaccountConditionEditorComponent } from './scriptaccount-condition-editor.component'; + +describe('ScriptaccountConditionEditorComponent', () => { + let component: ScriptaccountConditionEditorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ScriptaccountConditionEditorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ScriptaccountConditionEditorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts new file mode 100644 index 0000000..2277704 --- /dev/null +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts @@ -0,0 +1,49 @@ +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {ScriptAccountCondition} from "../../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {MatTableDataSource} from "@angular/material/table"; +import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount"; + +@Component({ + selector: 'app-scriptaccount-condition-editor', + templateUrl: './scriptaccount-condition-editor.component.html', + styleUrl: './scriptaccount-condition-editor.component.scss' +}) +export class ScriptaccountConditionEditorComponent implements OnInit{ + + @Input() conditions: ScriptAccountCondition[] = [] + @Input() scriptAccounts: ScriptAccount[] = [] + @Output() onCreateCondition: EventEmitter = new EventEmitter(); + @Output() onDeleteCondition: EventEmitter = new EventEmitter(); + + dataSource: MatTableDataSource = new MatTableDataSource(); + displayedColumns = ['scriptAccount', 'minValue', 'maxValue', 'edit', 'delete'] + + editedCondition: ScriptAccountCondition | undefined + addedCondition: ScriptAccountCondition | undefined + + ngOnInit() { + this.dataSource.data = this.conditions.concat(); + } + + createCondition() { + this.addedCondition = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("", ""), 0,0); + this.editedCondition = this.addedCondition; + this.dataSource.data = this.dataSource.data.concat(this.addedCondition!); + console.log(this.dataSource.data.length) + console.log(this.conditions.length) + } + + finishEditing() { + if(this.addedCondition != undefined) { + const createdCondition = ScriptAccountCondition.constructScriptAccountCondition(this.addedCondition.scriptAccount, this.addedCondition.minValue, this.addedCondition.maxValue); + if(createdCondition != undefined) { + this.onCreateCondition.emit(createdCondition); + this.conditions.push(createdCondition); + this.dataSource.data = this.conditions; + } + this.addedCondition = undefined; + } else { + this.editedCondition = undefined; + } + } +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 837048b..6a08285 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -41,6 +41,8 @@
+
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index efa965a..4c0030e 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -7,6 +7,7 @@ import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/S import {animate, state, style, transition, trigger} from "@angular/animations"; import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition"; @Component({ selector: 'app-simple-transition-editor', templateUrl: './simple-transition-editor.component.html', @@ -86,4 +87,14 @@ export class SimpleTransitionEditorComponent implements OnInit { const filterValue = (event.target as HTMLInputElement).value; this.dataSource.filter = filterValue.trim().toLowerCase(); } + + protected readonly transition = transition; + + onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) { + transition.addScriptAccountCondition(condition); + } + + deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) { + trasition.removeScriptAccountCondition(condition.scriptAccount); + } } diff --git a/src/app/game-model/gamesystems/states/State.ts b/src/app/game-model/gamesystems/states/State.ts index 234c4ce..d1848f5 100644 --- a/src/app/game-model/gamesystems/states/State.ts +++ b/src/app/game-model/gamesystems/states/State.ts @@ -1,4 +1,6 @@ import {Transition} from "../transitions/Transition"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; export abstract class State> { @@ -7,6 +9,8 @@ export abstract class State> { initial: boolean = false; + conditions: ScriptAccountCondition[] = []; + addIncomingTransition(transition: T) { this.incomingTransitions.push(transition); } @@ -23,5 +27,24 @@ export abstract class State> { } + addScriptAccountCondition(scriptAccountCondition: ScriptAccountCondition) { + const existingScriptAccountCondition = this.findScriptAccountConditionByScriptAccount(scriptAccountCondition.scriptAccount); + if(existingScriptAccountCondition != undefined) { + if(!existingScriptAccountCondition.isContradicting(scriptAccountCondition)) { + existingScriptAccountCondition.extendCondition(scriptAccountCondition) + } + } else { + this.conditions.push(scriptAccountCondition); + } + } + + removeScriptAccountCondition(scriptAccount: ScriptAccount) { + this.conditions = this.conditions.filter(condition => condition.scriptAccount !== scriptAccount); + } + + findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount): ScriptAccountCondition | undefined { + return this.conditions.find(condition => condition.scriptAccount === scriptAccount); + } + abstract equals(state: State>): boolean; } From 79eee273a0432588fce9718832094396144f267e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 18 Feb 2024 17:17:39 +0100 Subject: [PATCH 10/58] Fix duplicate condition and displaying min twice instead of min and max value --- .../scriptaccount-condition-editor.component.html | 2 +- .../scriptaccount-condition-editor.component.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html index 654d45f..3c80567 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -26,7 +26,7 @@ Maximal Value - {{condition.minValue}} + {{condition.maxValue}} Maximal Value diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts index 2277704..aa22f08 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts @@ -29,16 +29,15 @@ export class ScriptaccountConditionEditorComponent implements OnInit{ this.addedCondition = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("", ""), 0,0); this.editedCondition = this.addedCondition; this.dataSource.data = this.dataSource.data.concat(this.addedCondition!); - console.log(this.dataSource.data.length) - console.log(this.conditions.length) } finishEditing() { if(this.addedCondition != undefined) { const createdCondition = ScriptAccountCondition.constructScriptAccountCondition(this.addedCondition.scriptAccount, this.addedCondition.minValue, this.addedCondition.maxValue); if(createdCondition != undefined) { + console.log(createdCondition) this.onCreateCondition.emit(createdCondition); - this.conditions.push(createdCondition); + console.log(this.conditions) this.dataSource.data = this.conditions; } this.addedCondition = undefined; From c0bdbd5f40db941d08745e58431d63aa2c40f95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 18 Feb 2024 17:20:38 +0100 Subject: [PATCH 11/58] Edit existing Conditions --- .../scriptaccount-condition-editor.component.html | 2 +- .../scriptaccount-condition-editor.component.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html index 3c80567..6d3470a 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -37,7 +37,7 @@ - + diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts index aa22f08..62c0fa6 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts @@ -41,8 +41,11 @@ export class ScriptaccountConditionEditorComponent implements OnInit{ this.dataSource.data = this.conditions; } this.addedCondition = undefined; - } else { - this.editedCondition = undefined; } + this.editedCondition = undefined; + } + + edit(condition: ScriptAccountCondition) { + this.editedCondition = condition; } } From 18ff86840c6403c1cc5424b9ef86e7403227607e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 18 Feb 2024 17:24:10 +0100 Subject: [PATCH 12/58] Delete Conditions --- .../scriptaccount-condition-editor.component.html | 2 +- .../scriptaccount-condition-editor.component.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html index 6d3470a..530a0fa 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -47,7 +47,7 @@ - + diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts index 62c0fa6..61e81fc 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts @@ -48,4 +48,14 @@ export class ScriptaccountConditionEditorComponent implements OnInit{ edit(condition: ScriptAccountCondition) { this.editedCondition = condition; } + + deleteCondition(condition: ScriptAccountCondition) { + if(this.addedCondition === condition) { + this.addedCondition = undefined; + this.dataSource.data = this.conditions.concat(); + } else { + this.onDeleteCondition.emit(condition); + this.dataSource.data = this.conditions.concat(); + } + } } From 8f45d18e406150cadee9422c538b9899b28dfc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 18 Feb 2024 17:41:02 +0100 Subject: [PATCH 13/58] Restyle Condition and Action Editor in SimpleTransitionEditor --- .../simple-transition-editor.component.html | 14 +++++++++++--- .../simple-transition-editor.component.scss | 13 +++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 6a08285..e589f6f 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -40,9 +40,17 @@
- - +
+
+ +
+
+ +
+
+ +
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss index 3292508..b1e5805 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss @@ -61,3 +61,16 @@ tr.example-element-row:not(.example-expanded-row):active { .mat-error { color: red; } + +.condition-action-container { + display: flex; + width: 100% +} + +.condition-container { + width: 45%; +} + +.action-container { + width: 45%; +} From 5dafce8a9121afbb5c8999e1ad025504917d4c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 18 Feb 2024 17:50:08 +0100 Subject: [PATCH 14/58] Condition Editor for StateConditions --- .../scriptaccount-condition-editor.component.scss | 7 +++++++ .../simple-gamesystem-editor.component.html | 2 +- .../simple-state-editor.component.html | 5 +++++ .../simple-state-editor.component.ts | 12 ++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss index e69de29..dd63a97 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss @@ -0,0 +1,7 @@ +.mat-column-edit, .mat-column-delete { + width: 32px; +} + +table { + width: 100%; +} diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html index cc28a3d..7d7dc52 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html @@ -1,4 +1,4 @@ - +
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html index 1100328..2153f0e 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html @@ -25,6 +25,11 @@ Description + +
+ +
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 8177aa6..93dd0b1 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -6,6 +6,8 @@ import {MatSnackBar} from "@angular/material/snack-bar"; import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; +import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition"; @Component({ selector: 'app-simple-state-editor', @@ -23,6 +25,7 @@ export class SimpleStateEditorComponent implements OnInit{ @Input() states: SimpleState[] = []; @Input() gamesystem: SimpleGamesystem | undefined + @Input() scriptAccounts: ScriptAccount[] = [] dataSource = new MatTableDataSource(); displayedColumns = ["name", "initial", "edit", "delete"]; columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; @@ -93,4 +96,13 @@ export class SimpleStateEditorComponent implements OnInit{ const filterValue = (event.target as HTMLInputElement).value; this.dataSource.filter = filterValue.trim().toLowerCase(); } + + onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) { + state.addScriptAccountCondition(condition); + } + + + deleteCondition(state: SimpleState, condition: ScriptAccountCondition) { + state.removeScriptAccountCondition(condition.scriptAccount); + } } From 2e6bddc099855985658b0f1fb66cafb3a07f090d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 18 Feb 2024 18:22:38 +0100 Subject: [PATCH 15/58] Enable Disable Editing Mode in Action Editor and implement expandable rows in product-state-editor --- .../product-state-editor.component.html | 34 +++++++++++-- .../product-state-editor.component.scss | 51 ++++++++++++++++++- .../product-state-editor.component.ts | 11 ++++ .../scriptaccount-action-editor.component.ts | 6 ++- 4 files changed, 97 insertions(+), 5 deletions(-) diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html index 7ca4627..20ed928 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html @@ -4,7 +4,7 @@ Filter - +
- - + + + + + + + + + + + + + +
{{col}} @@ -15,8 +15,36 @@
  + + +
+

Expanded Row

+
+
diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.scss b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.scss index f2c3344..3761132 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.scss +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.scss @@ -2,10 +2,59 @@ table { width: 100%; } -.mat-column-Initial { +.mat-column-Initial, .mat-column-expand { width: 32px; } .long-form { width: 100%; } + + +table { + width: 100%; +} + +tr.example-detail-row { + height: 0; +} + +tr.example-element-row:not(.example-expanded-row):hover { + background: #545456; +} + +tr.example-element-row:not(.example-expanded-row):active { + background: #545456; +} + +.example-element-row td { + border-bottom-width: 0; +} + +.example-element-detail { + overflow: hidden; + display: flex; +} + +.example-element-diagram { + min-width: 80px; + border: 2px solid black; + padding: 8px; + font-weight: lighter; + margin: 8px 0; + height: 104px; +} + +.example-element-symbol { + font-weight: bold; + font-size: 40px; + line-height: normal; +} + +.example-element-description { + padding: 16px; +} + +.example-element-description-attribution { + opacity: 0.5; +} diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts index 9b15ede..a0b6afe 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts @@ -9,10 +9,18 @@ import {State} from "../../../../game-model/gamesystems/states/State"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; +import {animate, state, style, transition, trigger} from "@angular/animations"; @Component({ selector: 'app-product-state-editor', templateUrl: './product-state-editor.component.html', + animations: [ + trigger('detailExpand', [ + state('collapsed,void', style({height: '0px', minHeight: '0'})), + state('expanded', style({height: '*'})), + transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), + ]), + ], styleUrl: './product-state-editor.component.scss' }) export class ProductStateEditorComponent implements OnInit{ @@ -20,13 +28,16 @@ export class ProductStateEditorComponent implements OnInit{ @Input() gamesystem: ProductGamesystem | undefined @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter(); displayedColumns: string[] = []; + expandedColumns: string[] = [] datasource = new MatTableDataSource(); + expandedElement: ProductState | null = null; ngOnInit() { this.gamesystem!.generateFromChildsystems(); this.generateColumnNamesRecursively(this.gamesystem!, ""); this.displayedColumns.push('Initial'); + this.expandedColumns = [...this.displayedColumns, 'expand']; this.datasource.data = this.gamesystem!.states; this.datasource.filterPredicate = (data: ProductState, filter: string) => { const leaf_states = LeafGamesystemCalculator.calcLeafStates(data); diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts index f2b8860..b569ba1 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -12,6 +12,7 @@ import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount export class ScriptaccountActionEditorComponent implements OnInit{ @Input() transition: Transition | undefined @Input() scriptAccounts: ScriptAccount[] = [] + @Input() enableEditing: boolean = false; dataSource: MatTableDataSource = new MatTableDataSource(); displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete']; @@ -21,7 +22,10 @@ export class ScriptaccountActionEditorComponent implements OnInit{ ngOnInit() { this.dataSource.data = this.transition!.scriptAccountActions.map(action => action); - console.log("# ScriptAccounts", this.scriptAccounts.length) + + if(!this.enableEditing) { + this.displayedColumns = this.displayedColumns.slice(0, -2); + } } editAction(scriptAccountAction: ScriptAccountAction) { From 26ef72cac3dec5418aed1658cbac0d3c48905d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 15:58:44 +0100 Subject: [PATCH 16/58] Fix undefined GameModel and loading gamemodel when no gamesystems defined --- app/SaveProject.js | 11 ++++++++--- app/SaveProject.ts | 10 +++++++--- src/app/app.component.ts | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/SaveProject.js b/app/SaveProject.js index 0e77adc..95ef547 100644 --- a/app/SaveProject.js +++ b/app/SaveProject.js @@ -54,9 +54,14 @@ class SaveProject { } static loadGamesystems(projectDir) { const gamesystemDir = path.join(projectDir, "gamesystems"); - const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); - console.log("LoadedGamesystems: ", loadedGamesystems.length); - return loadedGamesystems; + if (fs.existsSync(gamesystemDir)) { + const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); + console.log("LoadedGamesystems: ", loadedGamesystems.length); + return loadedGamesystems; + } + else { + return []; + } } static loadGamesystemsRecursively(gamesystemDir) { let loadedGamesystems = []; diff --git a/app/SaveProject.ts b/app/SaveProject.ts index 7c010d3..a042f9e 100644 --- a/app/SaveProject.ts +++ b/app/SaveProject.ts @@ -62,9 +62,13 @@ export class SaveProject { static loadGamesystems(projectDir: string): LoadModel[] { const gamesystemDir = path.join(projectDir, "gamesystems"); - const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); - console.log("LoadedGamesystems: ", loadedGamesystems.length); - return loadedGamesystems; + if(fs.existsSync(gamesystemDir)) { + const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); + console.log("LoadedGamesystems: ", loadedGamesystems.length); + return loadedGamesystems; + } else { + return [] + } } static loadGamesystemsRecursively(gamesystemDir: string): LoadModel[] { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b416d2c..ebfb04a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -42,6 +42,9 @@ export class AppComponent implements OnInit{ private dialog: MatDialog ) { console.log('APP_CONFIG', APP_CONFIG); + if(this.gameModel == undefined) { + this.gameModel = new GameModel("Unknown GameModel") + } if (electronService.isElectron) { console.log(process.env); From 511043b76455be71032b9e8064b9db715d7ef4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 16:09:03 +0100 Subject: [PATCH 17/58] Replace primary color with blue color in editor btns --- .../scriptaccount-condition-editor.component.html | 4 ++-- .../simple-state-editor.component.html | 4 ++-- .../simple-state-editor.component.scss | 6 ------ .../scriptaccount-action-editor.component.html | 4 ++-- .../simple-transition-editor.component.html | 4 ++-- src/styles.css | 4 ++++ testModel/gamesystems/Weather.json | 13 +++++++++++++ testModel/script-accounts/Luftfeuchtigkeit.json | 2 -- testModel/script-accounts/Temperature.json | 2 -- 9 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 testModel/gamesystems/Weather.json diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html index 530a0fa..0ddb8f5 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -37,8 +37,8 @@ - - + + diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html index 2153f0e..470471a 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html @@ -51,8 +51,8 @@ - - + + diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.scss b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.scss index 0830e19..f4b8648 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.scss +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.scss @@ -17,12 +17,6 @@ tr.example-element-row:not(.example-expanded-row):active { .example-element-row td { border-bottom-width: 0; } - -.example-element-detail { - overflow: hidden; - display: flex; -} - .example-element-diagram { min-width: 80px; border: 2px solid black; diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html index af7af1b..ea3882f 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html @@ -26,8 +26,8 @@ - - + + diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index e589f6f..6d61627 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -58,8 +58,8 @@ - - + diff --git a/src/styles.css b/src/styles.css index 2fd855a..4f3f4b3 100644 --- a/src/styles.css +++ b/src/styles.css @@ -17,3 +17,7 @@ body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } background-color: #4f5459 !important; color: white; } + +.icon-btn-primary { + color: #3c95f8; +} diff --git a/testModel/gamesystems/Weather.json b/testModel/gamesystems/Weather.json new file mode 100644 index 0000000..53d81f8 --- /dev/null +++ b/testModel/gamesystems/Weather.json @@ -0,0 +1,13 @@ +{ + "componentName": "Weather", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "Sonnig", + "stateDescription": "Die Sonne scheint" + } + ], + "transitions": [] +} \ No newline at end of file diff --git a/testModel/script-accounts/Luftfeuchtigkeit.json b/testModel/script-accounts/Luftfeuchtigkeit.json index b948f4b..b4593b2 100644 --- a/testModel/script-accounts/Luftfeuchtigkeit.json +++ b/testModel/script-accounts/Luftfeuchtigkeit.json @@ -1,8 +1,6 @@ { - "unsaved": false, "componentName": "Luftfeuchtigkeit", "componentDescription": "", - "type": 0, "minValue": 0, "maxValue": 100 } \ No newline at end of file diff --git a/testModel/script-accounts/Temperature.json b/testModel/script-accounts/Temperature.json index c53736b..686f64e 100644 --- a/testModel/script-accounts/Temperature.json +++ b/testModel/script-accounts/Temperature.json @@ -1,8 +1,6 @@ { - "unsaved": false, "componentName": "Temperature", "componentDescription": "", - "type": 0, "minValue": 0, "maxValue": 100 } \ No newline at end of file From e0332433892e414070630fe751ef6263a543cb66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 16:33:39 +0100 Subject: [PATCH 18/58] Store conditions and simplify condition reference to component-name --- ...iptaccount-condition-editor.component.html | 2 +- src/app/game-model/fs/store/StoreProject.ts | 4 +++ testModel/gamesystems/Weather.json | 35 +++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html index 0ddb8f5..0cad14c 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -37,7 +37,7 @@ - + diff --git a/src/app/game-model/fs/store/StoreProject.ts b/src/app/game-model/fs/store/StoreProject.ts index 6503281..ce3e0bb 100644 --- a/src/app/game-model/fs/store/StoreProject.ts +++ b/src/app/game-model/fs/store/StoreProject.ts @@ -53,6 +53,10 @@ export class StoreProject { return value.stateLabel } + if(key === "scriptAccount") { + return value.componentName + } + if(key === 'incomingTransitions' || key === 'outgoingTransitions' || key === 'unsaved' || key === 'type') { return undefined; } else { diff --git a/testModel/gamesystems/Weather.json b/testModel/gamesystems/Weather.json index 53d81f8..cf34e7b 100644 --- a/testModel/gamesystems/Weather.json +++ b/testModel/gamesystems/Weather.json @@ -4,10 +4,41 @@ "states": [ { "initial": false, - "conditions": [], + "conditions": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "50" + } + ], "stateLabel": "Sonnig", "stateDescription": "Die Sonne scheint" + }, + { + "initial": false, + "conditions": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": "50", + "maxValue": "75" + } + ], + "stateLabel": "Wolkig", + "stateDescription": "" } ], - "transitions": [] + "transitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": "50", + "maxValue": "75" + } + ], + "startingState": "Sonnig", + "endingState": "Wolkig" + } + ] } \ No newline at end of file From 413d5eb9250a73edc4087a1795f086aacf079eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 16:43:50 +0100 Subject: [PATCH 19/58] Fix missing adding Button in action editor --- .../simple-transition-editor.component.html | 2 +- testModel/gamesystems/Weather.json | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 6d61627..5825868 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -42,7 +42,7 @@ [@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
- +
Date: Mon, 18 Mar 2024 17:05:18 +0100 Subject: [PATCH 20/58] 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 Date: Mon, 18 Mar 2024 17:15:07 +0100 Subject: [PATCH 21/58] Load Conditions & Actions for Transitions --- .../fs/parser/SimpleGamesystemParser.ts | 38 +++++++++++++++++-- testModel/gamesystems/Weather.json | 10 ++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts index 34b88ea..505d879 100644 --- a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts +++ b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts @@ -3,6 +3,7 @@ import {SimpleState} from "../../gamesystems/states/SimpleState"; import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition"; import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountAction} from "../../gamesystems/actions/ScriptAccountAction"; export class SimpleGamesystemParser { @@ -10,7 +11,7 @@ export class SimpleGamesystemParser { const gamesystemName = jsonObject.componentName; const gamesystemDescription = jsonObject.componentDescription; const simpleStates = SimpleGamesystemParser.parseSimpleStates(jsonObject, scriptAccounts) - const simpleTransitions = SimpleGamesystemParser.parseSimpleTransitions(jsonObject, simpleStates); + const simpleTransitions = SimpleGamesystemParser.parseSimpleTransitions(jsonObject, simpleStates, scriptAccounts); const gamesystem = new SimpleGamesystem(gamesystemName, gamesystemDescription); gamesystem.states = simpleStates; @@ -41,7 +42,7 @@ export class SimpleGamesystemParser { - static parseSimpleTransitions(jsonObject: any, states: SimpleState[]): SimpleTransition[] { + static parseSimpleTransitions(jsonObject: any, states: SimpleState[], scriptAccounts: ScriptAccount[]): SimpleTransition[] { const transitions: SimpleTransition[] = []; for(let i=0; i state.stateLabel === startingStateLabel); const endingState = states.find(state => state.stateLabel === endingStateLabel); + const actions: ScriptAccountAction[] = [] + for(let j=0; j scriptAccount.componentName === scriptAccountName) + + if(referencedScriptAccount != undefined) { + const scriptAccountAction = new ScriptAccountAction(referencedScriptAccount!, jsonObject.transitions[i].scriptAccountActions[j].changingValue) + actions.push(scriptAccountAction) + } + } + + const conditions: ScriptAccountCondition[] = []; + for(let j=0; j scriptAccount.componentName === scriptAccountName) + + if(referencedScriptAccount != undefined) { + const minValue = jsonObject.transitions[i].scriptAccountConditions[j].minValue + const maxValue = jsonObject.transitions[i].scriptAccountConditions[j].maxValue + + const scriptAccountCondition = + ScriptAccountCondition.constructScriptAccountCondition(referencedScriptAccount, minValue, maxValue) + + conditions.push(scriptAccountCondition!) + } + } + if(startingState != undefined && endingState != undefined) { - transitions.push(new SimpleTransition(startingState, endingState)); + const simpleTransition = new SimpleTransition(startingState, endingState); + simpleTransition.scriptAccountActions = actions; + simpleTransition.scriptAccountConditions = conditions; + + transitions.push(simpleTransition); } else { console.error("Starting or Ending State are not defined!", startingState, endingState) } diff --git a/testModel/gamesystems/Weather.json b/testModel/gamesystems/Weather.json index e6baf79..c7f2531 100644 --- a/testModel/gamesystems/Weather.json +++ b/testModel/gamesystems/Weather.json @@ -6,6 +6,7 @@ "initial": false, "conditions": [ { + "scriptAccount": "Temperature", "minValue": 0, "maxValue": "50" } @@ -17,6 +18,7 @@ "initial": false, "conditions": [ { + "scriptAccount": "Temperature", "minValue": "50", "maxValue": "75" } @@ -33,7 +35,13 @@ "scriptAccount": "Temperature" } ], - "scriptAccountConditions": [], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": "10" + } + ], "startingState": "Sonnig", "endingState": "Wolkig" } From 8c39762edeebcf86c108ca2c0e858f2a1e131647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 17:22:32 +0100 Subject: [PATCH 22/58] Store Structured Productgamesystems --- src/app/game-model/fs/store/StoreProject.ts | 2 +- .../gamesystems/Weather/Parent Weather.json | 6 +++ .../gamesystems/Weather/Weather(Child).json | 49 +++++++++++++++++++ testModel/gamesystems/Weather/Weather.json | 4 ++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 testModel/gamesystems/Weather/Parent Weather.json create mode 100644 testModel/gamesystems/Weather/Weather(Child).json create mode 100644 testModel/gamesystems/Weather/Weather.json diff --git a/src/app/game-model/fs/store/StoreProject.ts b/src/app/game-model/fs/store/StoreProject.ts index ce3e0bb..6f2cffe 100644 --- a/src/app/game-model/fs/store/StoreProject.ts +++ b/src/app/game-model/fs/store/StoreProject.ts @@ -57,7 +57,7 @@ export class StoreProject { return value.componentName } - if(key === 'incomingTransitions' || key === 'outgoingTransitions' || key === 'unsaved' || key === 'type') { + if(key === 'parentGamesystem' || key === 'incomingTransitions' || key === 'outgoingTransitions' || key === 'unsaved' || key === 'type') { return undefined; } else { return value; diff --git a/testModel/gamesystems/Weather/Parent Weather.json b/testModel/gamesystems/Weather/Parent Weather.json new file mode 100644 index 0000000..d4797d0 --- /dev/null +++ b/testModel/gamesystems/Weather/Parent Weather.json @@ -0,0 +1,6 @@ +{ + "componentName": "Parent Weather", + "componentDescription": "", + "states": [], + "transitions": [] +} \ No newline at end of file diff --git a/testModel/gamesystems/Weather/Weather(Child).json b/testModel/gamesystems/Weather/Weather(Child).json new file mode 100644 index 0000000..76b2e76 --- /dev/null +++ b/testModel/gamesystems/Weather/Weather(Child).json @@ -0,0 +1,49 @@ +{ + "componentName": "Weather(Child)", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": "50" + } + ], + "stateLabel": "Sonnig", + "stateDescription": "Die Sonne scheint" + }, + { + "initial": false, + "conditions": [ + { + "scriptAccount": "Temperature", + "minValue": "50", + "maxValue": "75" + } + ], + "stateLabel": "Wolkig", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "changingValue": 10, + "scriptAccount": "Temperature" + } + ], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": "10" + } + ], + "startingState": "Sonnig", + "endingState": "Wolkig" + } + ] +} \ No newline at end of file diff --git a/testModel/gamesystems/Weather/Weather.json b/testModel/gamesystems/Weather/Weather.json new file mode 100644 index 0000000..f989303 --- /dev/null +++ b/testModel/gamesystems/Weather/Weather.json @@ -0,0 +1,4 @@ +{ + "componentName": "Weather", + "componentDescription": "" +} \ No newline at end of file From e8687ae95e075dc0b6267a07772077b120895e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 17:33:24 +0100 Subject: [PATCH 23/58] Reset Gamesystem Selection --- src/app/app.component.html | 4 ++-- src/app/app.component.ts | 6 ++++++ .../gamescript-overview/gamescript-overview.component.ts | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 9b85948..2801b21 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@
-
+
-
From 4a7c87ecea9300bb09018f46f775e0453f225baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Tue, 19 Mar 2024 15:54:02 +0100 Subject: [PATCH 32/58] Expand Product Transitions --- .../product-transition-editor.component.html | 38 +++++++++++-- .../product-transition-editor.component.scss | 53 +++++++++++++++++++ .../product-transition-editor.component.ts | 13 ++++- 3 files changed, 99 insertions(+), 5 deletions(-) diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html index e2da5c2..2ef43f7 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html @@ -4,14 +4,31 @@ Filter - +
+ + + + + + + + + @@ -41,9 +58,22 @@ > + + + - - + + + + diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss index 432fb10..c9cf5f4 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss @@ -2,3 +2,56 @@ width: 100%; } + +.mat-column-expand { + width: 32px; + text-align: center; +} + +table { + width: 100%; +} + +tr.example-detail-row { + height: 0; +} + +tr.example-element-row:not(.example-expanded-row):hover { + background: whitesmoke; +} + +tr.example-element-row:not(.example-expanded-row):active { + background: #efefef; +} + +.example-element-row td { + border-bottom-width: 0; +} + +.example-element-detail { + overflow: hidden; + display: flex; +} + +.example-element-diagram { + min-width: 80px; + border: 2px solid black; + padding: 8px; + font-weight: lighter; + margin: 8px 0; + height: 104px; +} + +.example-element-symbol { + font-weight: bold; + font-size: 40px; + line-height: normal; +} + +.example-element-description { + padding: 16px; +} + +.example-element-description-attribution { + opacity: 0.5; +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index e6bbea0..741f8b6 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -7,6 +7,7 @@ import { import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; +import {animate, state, style, transition, trigger} from "@angular/animations"; class DisplayedColumnName { displayedName: string internalName: string @@ -20,7 +21,14 @@ class DisplayedColumnName { @Component({ selector: 'app-product-transition-editor', templateUrl: './product-transition-editor.component.html', - styleUrl: './product-transition-editor.component.scss' + styleUrl: './product-transition-editor.component.scss', + animations: [ + trigger('detailExpand', [ + state('collapsed,void', style({height: '0px', minHeight: '0'})), + state('expanded', style({height: '*'})), + transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), + ]), + ], }) export class ProductTransitionEditorComponent implements OnInit{ @@ -30,6 +38,8 @@ export class ProductTransitionEditorComponent implements OnInit{ dataSource = new MatTableDataSource(); displayedColumns: DisplayedColumnName[] = []; columns: string[] = []; + columnsToDisplayWithExpand = [...this.columns, 'expand']; + expandedElement: ProductTransition | null = null numberLeafSystems: number = -1; ngOnInit() { @@ -40,6 +50,7 @@ export class ProductTransitionEditorComponent implements OnInit{ this.numberLeafSystems = leafGamesystems.length; this.columns = this.displayedColumns.map(column => column.internalName) + this.columnsToDisplayWithExpand = [...this.columns, 'expand'] this.dataSource.data = this.gamesystem.transitions; this.dataSource.filterPredicate = (data: ProductTransition, filter: string) => { From 03bc18e679271d296e0fb98657eb0b1ebf1a29f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Tue, 19 Mar 2024 16:07:58 +0100 Subject: [PATCH 33/58] Fix condition combining --- .../product-transition-editor.component.html | 2 +- .../conditions/ScriptAccountCondition.ts | 2 +- testModel/gamesystems/ParentTestSystem/A.json | 32 +++++++++++++++++++ .../gamesystems/ParentTestSystem/Numbers.json | 32 +++++++++++++++++++ .../ParentTestSystem/ParentTestSystem.json | 4 +++ .../gamesystems/Weathersystem/Season.json | 2 +- .../gamesystems/Weathersystem/Weather.json | 2 +- 7 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 testModel/gamesystems/ParentTestSystem/A.json create mode 100644 testModel/gamesystems/ParentTestSystem/Numbers.json create mode 100644 testModel/gamesystems/ParentTestSystem/ParentTestSystem.json diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html index 2ef43f7..8861ae6 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html @@ -62,7 +62,7 @@ diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts index 566bfb0..ecc1b26 100644 --- a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts +++ b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts @@ -26,7 +26,7 @@ export class ScriptAccountCondition { combineCondition(condition: ScriptAccountCondition) { if(condition.scriptAccount === this.scriptAccount) { const scriptAccount = new ScriptAccountCondition(this.scriptAccount, this.minValue, this.maxValue); - scriptAccount.combineCondition(condition); + scriptAccount.extendCondition(condition); return scriptAccount; } return undefined; diff --git a/testModel/gamesystems/ParentTestSystem/A.json b/testModel/gamesystems/ParentTestSystem/A.json new file mode 100644 index 0000000..6db8a9c --- /dev/null +++ b/testModel/gamesystems/ParentTestSystem/A.json @@ -0,0 +1,32 @@ +{ + "componentName": "A", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "A", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "B", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": "10" + } + ], + "startingState": "A", + "endingState": "B" + } + ] +} \ No newline at end of file diff --git a/testModel/gamesystems/ParentTestSystem/Numbers.json b/testModel/gamesystems/ParentTestSystem/Numbers.json new file mode 100644 index 0000000..546a507 --- /dev/null +++ b/testModel/gamesystems/ParentTestSystem/Numbers.json @@ -0,0 +1,32 @@ +{ + "componentName": "Numbers", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "1", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "5" + } + ], + "stateLabel": "2", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "1", + "endingState": "2" + } + ] +} \ No newline at end of file diff --git a/testModel/gamesystems/ParentTestSystem/ParentTestSystem.json b/testModel/gamesystems/ParentTestSystem/ParentTestSystem.json new file mode 100644 index 0000000..0572a4c --- /dev/null +++ b/testModel/gamesystems/ParentTestSystem/ParentTestSystem.json @@ -0,0 +1,4 @@ +{ + "componentName": "ParentTestSystem", + "componentDescription": "" +} \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Season.json b/testModel/gamesystems/Weathersystem/Season.json index a815ccb..5d16d94 100644 --- a/testModel/gamesystems/Weathersystem/Season.json +++ b/testModel/gamesystems/Weathersystem/Season.json @@ -3,7 +3,7 @@ "componentDescription": "Ein simples Gamesystem zur Modellierung verschiedener Jahreszeiten und deren Übergänge", "states": [ { - "initial": true, + "initial": false, "conditions": [ { "scriptAccount": "Temperature", diff --git a/testModel/gamesystems/Weathersystem/Weather.json b/testModel/gamesystems/Weathersystem/Weather.json index b9de825..f35425f 100644 --- a/testModel/gamesystems/Weathersystem/Weather.json +++ b/testModel/gamesystems/Weathersystem/Weather.json @@ -3,7 +3,7 @@ "componentDescription": "A small Gamesystem about local weather events", "states": [ { - "initial": true, + "initial": false, "conditions": [], "stateLabel": "Sonne", "stateDescription": "" From 620e591c0b2cf382851754b4be17e5d422899ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Tue, 19 Mar 2024 16:33:17 +0100 Subject: [PATCH 34/58] Load Initial Value of Simple State --- src/app/game-model/fs/parser/SimpleGamesystemParser.ts | 2 ++ testModel/gamesystems/Weathersystem/Season.json | 2 +- testModel/gamesystems/Weathersystem/Weather.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts index 505d879..b20cd3d 100644 --- a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts +++ b/src/app/game-model/fs/parser/SimpleGamesystemParser.ts @@ -25,6 +25,8 @@ export class SimpleGamesystemParser { for(let i=0; i scriptAccount.componentName === conditions[j].scriptAccount) if(searchedScriptAccount != undefined) { diff --git a/testModel/gamesystems/Weathersystem/Season.json b/testModel/gamesystems/Weathersystem/Season.json index 5d16d94..a815ccb 100644 --- a/testModel/gamesystems/Weathersystem/Season.json +++ b/testModel/gamesystems/Weathersystem/Season.json @@ -3,7 +3,7 @@ "componentDescription": "Ein simples Gamesystem zur Modellierung verschiedener Jahreszeiten und deren Übergänge", "states": [ { - "initial": false, + "initial": true, "conditions": [ { "scriptAccount": "Temperature", diff --git a/testModel/gamesystems/Weathersystem/Weather.json b/testModel/gamesystems/Weathersystem/Weather.json index f35425f..b9de825 100644 --- a/testModel/gamesystems/Weathersystem/Weather.json +++ b/testModel/gamesystems/Weathersystem/Weather.json @@ -3,7 +3,7 @@ "componentDescription": "A small Gamesystem about local weather events", "states": [ { - "initial": false, + "initial": true, "conditions": [], "stateLabel": "Sonne", "stateDescription": "" From c4085a7cf94c88bff75d61d0aa94ee5bc1fc1c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Tue, 19 Mar 2024 17:03:07 +0100 Subject: [PATCH 35/58] Delete ScriptAccounts from Filesystem --- app/DeleteModel.js | 14 ++++++++++++++ app/DeleteModel.ts | 10 ++++++++++ app/main.ts | 18 ++++++++++++++++-- src/app/app.component.ts | 2 ++ src/app/game-model/fs/DeleteModel.ts | 12 ++++++++++++ testModel/script-accounts/Temperature.json | 6 ------ 6 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 app/DeleteModel.js create mode 100644 app/DeleteModel.ts create mode 100644 src/app/game-model/fs/DeleteModel.ts delete mode 100644 testModel/script-accounts/Temperature.json diff --git a/app/DeleteModel.js b/app/DeleteModel.js new file mode 100644 index 0000000..563c8fb --- /dev/null +++ b/app/DeleteModel.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeleteTransaction = void 0; +const path = require("node:path"); +const fs = require("fs"); +class DeleteTransaction { + static deleteScriptAccount(projectDir, componentName) { + const filename = path.join(projectDir, "script-accounts", componentName + ".json"); + fs.unlinkSync(filename); + console.log("Delete ", filename); + } +} +exports.DeleteTransaction = DeleteTransaction; +//# sourceMappingURL=DeleteModel.js.map \ No newline at end of file diff --git a/app/DeleteModel.ts b/app/DeleteModel.ts new file mode 100644 index 0000000..cd00d88 --- /dev/null +++ b/app/DeleteModel.ts @@ -0,0 +1,10 @@ +import * as path from "node:path"; +import * as fs from "fs"; + +export class DeleteTransaction { + static deleteScriptAccount(projectDir: string, componentName: string) { + const filename = path.join(projectDir, "script-accounts", componentName + ".json") + fs.unlinkSync(filename) + console.log("Delete ", filename) + } +} diff --git a/app/main.ts b/app/main.ts index 0f784e9..4aa4388 100644 --- a/app/main.ts +++ b/app/main.ts @@ -1,9 +1,11 @@ -import {app, BrowserWindow, screen, Menu, ipcMain, dialog, globalShortcut} from 'electron'; +import {app, BrowserWindow, dialog, globalShortcut, ipcMain, Menu, screen} from 'electron'; import * as path from 'path'; import * as fs from 'fs'; -import {json} from "node:stream/consumers"; import {StorageModel} from "../src/app/game-model/fs/StorageModel"; import {SaveProject} from "./SaveProject"; +import {DeleteModel} from "../src/app/game-model/fs/DeleteModel"; +import {ModelComponentType} from "../src/app/game-model/ModelComponentType"; +import {DeleteTransaction} from "./DeleteModel"; let win: BrowserWindow | null = null; const args = process.argv.slice(1), @@ -99,6 +101,11 @@ function createWindow(): BrowserWindow { SaveProject.saveProject(projectDirectory, storageModels); }) + ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => { + console.log("Delete Model: ", deletedComponent) + deleteComponent(deletedComponent); + }) + const menuTemplate = [ { label: 'File', @@ -207,3 +214,10 @@ function openProjectFromFile(openProjectDir: string) { function saveProject() { win!.webContents.send('get-project-data') } + +function deleteComponent(component: DeleteModel) { + console.log("Delete Component") + if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) { + DeleteTransaction.deleteScriptAccount(projectDirectory, component.componentName); + } +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index cdc62e8..5b3675f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -18,6 +18,7 @@ import {LoadedProject} from "../../app/LoadedProject"; import {ProcessLoadedProject} from "./game-model/fs/ProcessLoadedProject"; import {StoreProject} from "./game-model/fs/store/StoreProject"; import {Gamesystem} from "./game-model/gamesystems/Gamesystem"; +import {DeleteModel} from "./game-model/fs/DeleteModel"; @Component({ selector: 'app-root', @@ -115,6 +116,7 @@ export class AppComponent implements OnInit{ if(res != undefined && res) { if(affectedModelComponent instanceof ScriptAccount) { this.gameModel!.removeScriptAccount(affectedModelComponent); + this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT)) } else if(affectedModelComponent instanceof Gamesystem) { this.gameModel!.removeGamesystem(affectedModelComponent); this.gamesystemOverview!.refresh() diff --git a/src/app/game-model/fs/DeleteModel.ts b/src/app/game-model/fs/DeleteModel.ts new file mode 100644 index 0000000..186c583 --- /dev/null +++ b/src/app/game-model/fs/DeleteModel.ts @@ -0,0 +1,12 @@ +import {ModelComponentType} from "../ModelComponentType"; + +export class DeleteModel { + componentName: string + modeltype: ModelComponentType + + + constructor(componentName: string, modeltype: ModelComponentType) { + this.componentName = componentName; + this.modeltype = modeltype; + } +} diff --git a/testModel/script-accounts/Temperature.json b/testModel/script-accounts/Temperature.json deleted file mode 100644 index 53db39d..0000000 --- a/testModel/script-accounts/Temperature.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "componentName": "Temperature", - "componentDescription": "", - "minValue": -50, - "maxValue": 70 -} \ No newline at end of file From b62f93bfd52ae15bf1b6fee5d3a23f6b15954332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Tue, 19 Mar 2024 17:55:11 +0100 Subject: [PATCH 36/58] Delete Gamesystems from Filesystem --- app/DeleteModel.js | 36 +++++++++++++++++ app/DeleteModel.ts | 40 +++++++++++++++++++ app/main.ts | 2 + src/app/app.component.ts | 1 + testModel/gamesystems/ParentTestSystem/A.json | 32 --------------- 5 files changed, 79 insertions(+), 32 deletions(-) delete mode 100644 testModel/gamesystems/ParentTestSystem/A.json diff --git a/app/DeleteModel.js b/app/DeleteModel.js index 563c8fb..c9d7b3f 100644 --- a/app/DeleteModel.js +++ b/app/DeleteModel.js @@ -9,6 +9,42 @@ class DeleteTransaction { fs.unlinkSync(filename); console.log("Delete ", filename); } + static deleteGamesystem(projectDir, componentName) { + const gamesystemDir = path.join(projectDir, "gamesystems"); + const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName); + try { + if (gamesystemFile != undefined) { + console.log("Delete Gamesystem under File: ", gamesystemFile); + if (fs.lstatSync(gamesystemFile).isDirectory()) { + fs.rmSync(gamesystemFile, { recursive: true, force: true }); + } + else { + fs.unlinkSync(gamesystemFile); + } + } + } + catch (e) { + console.log(e); + } + } + static findGamesystemPath(gamesystemRootDir, searchedFilename) { + const directoriesToProcess = []; + directoriesToProcess.push(gamesystemRootDir); + while (directoriesToProcess.length > 0) { + const currentDirectory = directoriesToProcess.shift(); + const filesInDirectory = fs.readdirSync(currentDirectory); + for (let i = 0; i < filesInDirectory.length; i++) { + const currentFile = path.join(currentDirectory, filesInDirectory[i]); + if (fs.lstatSync(currentFile).isDirectory()) { + directoriesToProcess.push(currentFile); + } + if (path.parse(path.basename(currentFile)).name === searchedFilename) { + return currentFile; + } + } + } + return undefined; + } } exports.DeleteTransaction = DeleteTransaction; //# sourceMappingURL=DeleteModel.js.map \ No newline at end of file diff --git a/app/DeleteModel.ts b/app/DeleteModel.ts index cd00d88..3ac58f2 100644 --- a/app/DeleteModel.ts +++ b/app/DeleteModel.ts @@ -1,5 +1,6 @@ import * as path from "node:path"; import * as fs from "fs"; +import {json} from "node:stream/consumers"; export class DeleteTransaction { static deleteScriptAccount(projectDir: string, componentName: string) { @@ -7,4 +8,43 @@ export class DeleteTransaction { fs.unlinkSync(filename) console.log("Delete ", filename) } + + static deleteGamesystem(projectDir: string, componentName: string) { + const gamesystemDir = path.join(projectDir, "gamesystems") + const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName) + try { + if(gamesystemFile != undefined) { + console.log("Delete Gamesystem under File: ", gamesystemFile) + if(fs.lstatSync(gamesystemFile).isDirectory()) { + fs.rmSync(gamesystemFile, {recursive: true, force: true}) + } else { + fs.unlinkSync(gamesystemFile) + } + } + }catch (e) { + console.log(e) + } + + } + + static findGamesystemPath(gamesystemRootDir: string, searchedFilename: string) { + const directoriesToProcess: string[] = []; + directoriesToProcess.push(gamesystemRootDir); + while(directoriesToProcess.length > 0) { + const currentDirectory = directoriesToProcess.shift(); + const filesInDirectory = fs.readdirSync(currentDirectory!) + for(let i=0; i Date: Wed, 20 Mar 2024 09:26:14 +0100 Subject: [PATCH 37/58] Refactor Loading of ScriptAccounts --- app/DeleteModel.js | 50 -------- app/DeleteModel.ts | 50 -------- app/LoadModel.js | 11 -- app/LoadModel.ts | 12 -- app/LoadedProject.js | 11 -- app/LoadedProject.ts | 12 -- app/RecursiveLoadModel.js | 12 -- app/RecursiveLoadModel.ts | 12 -- app/SaveProject.js | 105 ---------------- app/SaveProject.ts | 114 ------------------ app/StorageModel.ts | 12 -- app/main.ts | 22 ++-- app/storage/FileUtils.ts | 13 ++ app/storage/ModelComponentFileDirectory.ts | 6 + app/storage/StoreComponent.ts | 13 ++ app/storage/StoredGameModel.ts | 12 ++ app/storage/loader/GameModelLoader.ts | 43 +++++++ app/storage/loader/ScriptAccountLoader.ts | 34 ++++++ src/app/app.component.html | 2 +- src/app/app.component.ts | 74 +++--------- .../delete-confirmation-dialog.component.ts | 5 +- src/app/editor/editor.component.ts | 18 +-- .../gamesystem-editor.component.ts | 13 +- .../LeafGamesystemCalculator.ts | 12 +- .../product-gamesystem-editor.component.ts | 5 +- ...criptaccount-condition-editor.component.ts | 4 +- .../simple-gamesystem-editor.component.ts | 4 +- .../product-state-editor.component.ts | 11 +- .../simple-state-editor.component.ts | 10 +- .../product-transition-editor.component.ts | 8 +- .../scriptaccount-action-editor.component.ts | 6 +- .../simple-transition-editor.component.ts | 10 +- .../model-component-editor.component.ts | 2 +- .../script-account-editor.component.ts | 4 +- src/app/{ => project}/game-model/GameModel.ts | 0 .../game-model/ModelComponent.ts | 0 .../game-model/ModelComponentType.ts | 0 .../ModelComponentTypeUtillities.ts | 0 .../{ => project}/game-model/SaveComponent.ts | 0 .../game-model/fs/DeleteModel.ts | 0 .../game-model/fs/ProcessLoadedProject.ts | 0 .../game-model/fs/StorageModel.ts | 0 .../fs/parser/ProductGamesystemParser.ts | 0 .../fs/parser/SimpleGamesystemParser.ts | 0 .../game-model/fs/store/StoreProject.ts | 0 .../game-model/game-model.module.ts | 0 .../game-model/gamesystems/Gamesystem.ts | 0 .../gamesystems/ProductGamesystem.ts | 1 - .../gamesystems/SimpleGamesystem.ts | 0 .../actions/ScriptAccountAction.ts | 0 .../conditions/ScriptAccountCondition.ts | 0 .../gamesystems/states/ProductState.ts | 0 .../gamesystems/states/SimpleState.ts | 0 .../game-model/gamesystems/states/State.ts | 0 .../transitions/ProductTransition.ts | 0 .../transitions/SimpleTransition.ts | 0 .../gamesystems/transitions/Transition.ts | 0 .../scriptAccounts/ScriptAccount.ts | 0 src/app/project/parser/ScriptAccountParser.ts | 12 ++ .../gamescript-overview.component.ts | 12 +- .../script-account-overview.component.ts | 4 +- 61 files changed, 223 insertions(+), 538 deletions(-) delete mode 100644 app/DeleteModel.js delete mode 100644 app/DeleteModel.ts delete mode 100644 app/LoadModel.js delete mode 100644 app/LoadModel.ts delete mode 100644 app/LoadedProject.js delete mode 100644 app/LoadedProject.ts delete mode 100644 app/RecursiveLoadModel.js delete mode 100644 app/RecursiveLoadModel.ts delete mode 100644 app/SaveProject.js delete mode 100644 app/SaveProject.ts delete mode 100644 app/StorageModel.ts create mode 100644 app/storage/FileUtils.ts create mode 100644 app/storage/ModelComponentFileDirectory.ts create mode 100644 app/storage/StoreComponent.ts create mode 100644 app/storage/StoredGameModel.ts create mode 100644 app/storage/loader/GameModelLoader.ts create mode 100644 app/storage/loader/ScriptAccountLoader.ts rename src/app/{ => project}/game-model/GameModel.ts (100%) rename src/app/{ => project}/game-model/ModelComponent.ts (100%) rename src/app/{ => project}/game-model/ModelComponentType.ts (100%) rename src/app/{ => project}/game-model/ModelComponentTypeUtillities.ts (100%) rename src/app/{ => project}/game-model/SaveComponent.ts (100%) rename src/app/{ => project}/game-model/fs/DeleteModel.ts (100%) rename src/app/{ => project}/game-model/fs/ProcessLoadedProject.ts (100%) rename src/app/{ => project}/game-model/fs/StorageModel.ts (100%) rename src/app/{ => project}/game-model/fs/parser/ProductGamesystemParser.ts (100%) rename src/app/{ => project}/game-model/fs/parser/SimpleGamesystemParser.ts (100%) rename src/app/{ => project}/game-model/fs/store/StoreProject.ts (100%) rename src/app/{ => project}/game-model/game-model.module.ts (100%) rename src/app/{ => project}/game-model/gamesystems/Gamesystem.ts (100%) rename src/app/{ => project}/game-model/gamesystems/ProductGamesystem.ts (99%) rename src/app/{ => project}/game-model/gamesystems/SimpleGamesystem.ts (100%) rename src/app/{ => project}/game-model/gamesystems/actions/ScriptAccountAction.ts (100%) rename src/app/{ => project}/game-model/gamesystems/conditions/ScriptAccountCondition.ts (100%) rename src/app/{ => project}/game-model/gamesystems/states/ProductState.ts (100%) rename src/app/{ => project}/game-model/gamesystems/states/SimpleState.ts (100%) rename src/app/{ => project}/game-model/gamesystems/states/State.ts (100%) rename src/app/{ => project}/game-model/gamesystems/transitions/ProductTransition.ts (100%) rename src/app/{ => project}/game-model/gamesystems/transitions/SimpleTransition.ts (100%) rename src/app/{ => project}/game-model/gamesystems/transitions/Transition.ts (100%) rename src/app/{ => project}/game-model/scriptAccounts/ScriptAccount.ts (100%) create mode 100644 src/app/project/parser/ScriptAccountParser.ts diff --git a/app/DeleteModel.js b/app/DeleteModel.js deleted file mode 100644 index c9d7b3f..0000000 --- a/app/DeleteModel.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DeleteTransaction = void 0; -const path = require("node:path"); -const fs = require("fs"); -class DeleteTransaction { - static deleteScriptAccount(projectDir, componentName) { - const filename = path.join(projectDir, "script-accounts", componentName + ".json"); - fs.unlinkSync(filename); - console.log("Delete ", filename); - } - static deleteGamesystem(projectDir, componentName) { - const gamesystemDir = path.join(projectDir, "gamesystems"); - const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName); - try { - if (gamesystemFile != undefined) { - console.log("Delete Gamesystem under File: ", gamesystemFile); - if (fs.lstatSync(gamesystemFile).isDirectory()) { - fs.rmSync(gamesystemFile, { recursive: true, force: true }); - } - else { - fs.unlinkSync(gamesystemFile); - } - } - } - catch (e) { - console.log(e); - } - } - static findGamesystemPath(gamesystemRootDir, searchedFilename) { - const directoriesToProcess = []; - directoriesToProcess.push(gamesystemRootDir); - while (directoriesToProcess.length > 0) { - const currentDirectory = directoriesToProcess.shift(); - const filesInDirectory = fs.readdirSync(currentDirectory); - for (let i = 0; i < filesInDirectory.length; i++) { - const currentFile = path.join(currentDirectory, filesInDirectory[i]); - if (fs.lstatSync(currentFile).isDirectory()) { - directoriesToProcess.push(currentFile); - } - if (path.parse(path.basename(currentFile)).name === searchedFilename) { - return currentFile; - } - } - } - return undefined; - } -} -exports.DeleteTransaction = DeleteTransaction; -//# sourceMappingURL=DeleteModel.js.map \ No newline at end of file diff --git a/app/DeleteModel.ts b/app/DeleteModel.ts deleted file mode 100644 index 3ac58f2..0000000 --- a/app/DeleteModel.ts +++ /dev/null @@ -1,50 +0,0 @@ -import * as path from "node:path"; -import * as fs from "fs"; -import {json} from "node:stream/consumers"; - -export class DeleteTransaction { - static deleteScriptAccount(projectDir: string, componentName: string) { - const filename = path.join(projectDir, "script-accounts", componentName + ".json") - fs.unlinkSync(filename) - console.log("Delete ", filename) - } - - static deleteGamesystem(projectDir: string, componentName: string) { - const gamesystemDir = path.join(projectDir, "gamesystems") - const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName) - try { - if(gamesystemFile != undefined) { - console.log("Delete Gamesystem under File: ", gamesystemFile) - if(fs.lstatSync(gamesystemFile).isDirectory()) { - fs.rmSync(gamesystemFile, {recursive: true, force: true}) - } else { - fs.unlinkSync(gamesystemFile) - } - } - }catch (e) { - console.log(e) - } - - } - - static findGamesystemPath(gamesystemRootDir: string, searchedFilename: string) { - const directoriesToProcess: string[] = []; - directoriesToProcess.push(gamesystemRootDir); - while(directoriesToProcess.length > 0) { - const currentDirectory = directoriesToProcess.shift(); - const filesInDirectory = fs.readdirSync(currentDirectory!) - for(let i=0; i { - let modelDir = path.join(projectDir, storageModel.storageRootDir); - storageModel.storagePath.forEach(pathElement => modelDir = path.join(modelDir, pathElement)); - if (!fs.existsSync(modelDir)) { - fs.mkdirSync(modelDir, { recursive: true }); - } - const filePath = path.join(modelDir, storageModel.fileName + ".json"); - fs.writeFile(filePath, storageModel.jsonString, 'utf-8', (err) => { - if (err) { - console.error('Error writing JSON to file:', err); - } - else { - console.log('JSON file saved successfully:', filePath); - } - }); - }); - } - static loadProject(projectDir) { - let loadedScriptAccounts = SaveProject.loadScriptAccounts(projectDir); - loadedScriptAccounts = loadedScriptAccounts.concat(SaveProject.loadGamesystems(projectDir)); - return new LoadedProject_1.LoadedProject(path.basename(projectDir), loadedScriptAccounts); - } - static loadScriptAccounts(projectDir) { - const scriptAccountDir = path.join(projectDir, "script-accounts"); - if (!fs.existsSync(scriptAccountDir)) { - return []; - } - const loadedScriptAccounts = []; - const scriptAccountFileNames = fs.readdirSync(scriptAccountDir); - scriptAccountFileNames.forEach(scriptAccountFileName => { - const scriptAccountFile = path.join(scriptAccountDir, scriptAccountFileName); - const scriptAccountData = fs.readFileSync(scriptAccountFile, 'utf-8'); - loadedScriptAccounts.push({ - modelType: ModelComponentType_1.ModelComponentType.SCRIPTACCOUNT, - jsonString: scriptAccountData - }); - }); - return loadedScriptAccounts; - } - static loadGamesystems(projectDir) { - const gamesystemDir = path.join(projectDir, "gamesystems"); - if (fs.existsSync(gamesystemDir)) { - const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); - console.log("LoadedGamesystems: ", loadedGamesystems.length); - return loadedGamesystems; - } - else { - return []; - } - } - static loadGamesystemsRecursively(gamesystemDir) { - let loadedGamesystems = []; - const gamesystemFileNames = fs.readdirSync(gamesystemDir); - gamesystemFileNames.forEach(fileName => { - const gamesystemPath = path.join(gamesystemDir, fileName); - if (fs.lstatSync(gamesystemPath).isDirectory()) { - const childModels = SaveProject.loadGamesystemsRecursively(gamesystemPath); - loadedGamesystems = loadedGamesystems.concat(childModels); - } - else { - const gamesystemData = fs.readFileSync(path.join(gamesystemDir, fileName), "utf-8"); - if (path.parse(fileName).name === path.basename(gamesystemDir)) { - if ((path.basename(gamesystemDir) === path.parse(fileName).name) && path.basename(path.parse(gamesystemDir).dir) === "gamesystems") { - const loadedModel = new LoadModel_1.LoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM); - loadedGamesystems.unshift(loadedModel); - } - else { - const loadedModel = new RecursiveLoadModel_1.RecursiveLoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM, path.basename(gamesystemDir)); - loadedGamesystems.unshift(loadedModel); - } - } - else { - const secondCon = path.basename(gamesystemDir) === path.parse(fileName).name; - const thirdCon = path.basename(path.parse(gamesystemDir).dir) === "gamesystems"; - if (path.basename(gamesystemDir) === "gamesystems") { - const loadedModel = new LoadModel_1.LoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM); - loadedGamesystems.push(loadedModel); - } - else { - const loadedModel = new RecursiveLoadModel_1.RecursiveLoadModel(gamesystemData, ModelComponentType_1.ModelComponentType.GAMESYTEM, path.basename(gamesystemDir)); - loadedGamesystems.push(loadedModel); - } - } - } - }); - return loadedGamesystems; - } -} -exports.SaveProject = SaveProject; -//# sourceMappingURL=SaveProject.js.map \ No newline at end of file diff --git a/app/SaveProject.ts b/app/SaveProject.ts deleted file mode 100644 index a042f9e..0000000 --- a/app/SaveProject.ts +++ /dev/null @@ -1,114 +0,0 @@ -import {StorageModel} from "../src/app/game-model/fs/StorageModel"; -import * as fs from "fs"; -import * as path from "node:path"; -import {LoadModel} from "./LoadModel"; -import {ModelComponentType} from "../src/app/game-model/ModelComponentType"; -import {LoadedProject} from "./LoadedProject"; -import {RecursiveLoadModel} from "./RecursiveLoadModel"; - - -export class SaveProject { - static saveProject(projectDir: string, storageModels: StorageModel[]) { - if(!fs.existsSync(projectDir)) { - fs.mkdirSync(projectDir, {recursive: true}); - } - - console.log(storageModels) - storageModels.forEach(storageModel => { - let modelDir = path.join(projectDir, storageModel.storageRootDir); - storageModel.storagePath.forEach(pathElement => modelDir = path.join(modelDir, pathElement)); - if(!fs.existsSync(modelDir)) { - fs.mkdirSync(modelDir, {recursive: true}); - } - - const filePath = path.join(modelDir, storageModel.fileName + ".json"); - fs.writeFile(filePath, storageModel.jsonString ,'utf-8', (err) => { - if (err) { - console.error('Error writing JSON to file:', err); - } else { - console.log('JSON file saved successfully:', filePath); - } - }) - }) - } - - static loadProject(projectDir: string) { - let loadedScriptAccounts: LoadModel[] = SaveProject.loadScriptAccounts(projectDir) - loadedScriptAccounts = loadedScriptAccounts.concat(SaveProject.loadGamesystems(projectDir)) - return new LoadedProject(path.basename(projectDir), loadedScriptAccounts); - } - - static loadScriptAccounts(projectDir: string): LoadModel[] { - const scriptAccountDir = path.join(projectDir, "script-accounts"); - if (!fs.existsSync(scriptAccountDir)) { - return []; - } - - const loadedScriptAccounts: LoadModel[] = []; - - const scriptAccountFileNames = fs.readdirSync(scriptAccountDir); - scriptAccountFileNames.forEach(scriptAccountFileName => { - const scriptAccountFile = path.join(scriptAccountDir, scriptAccountFileName) - const scriptAccountData: string = fs.readFileSync(scriptAccountFile, 'utf-8'); - - loadedScriptAccounts.push({ - modelType: ModelComponentType.SCRIPTACCOUNT, - jsonString: scriptAccountData - }); - }) - - return loadedScriptAccounts; - } - - static loadGamesystems(projectDir: string): LoadModel[] { - const gamesystemDir = path.join(projectDir, "gamesystems"); - if(fs.existsSync(gamesystemDir)) { - const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); - console.log("LoadedGamesystems: ", loadedGamesystems.length); - return loadedGamesystems; - } else { - return [] - } - } - - static loadGamesystemsRecursively(gamesystemDir: string): LoadModel[] { - let loadedGamesystems: LoadModel[] = []; - const gamesystemFileNames = fs.readdirSync(gamesystemDir); - - gamesystemFileNames.forEach(fileName => { - const gamesystemPath = path.join(gamesystemDir, fileName); - - if(fs.lstatSync(gamesystemPath).isDirectory()) { - const childModels: LoadModel[] = SaveProject.loadGamesystemsRecursively(gamesystemPath); - loadedGamesystems = loadedGamesystems.concat(childModels); - } else { - const gamesystemData = fs.readFileSync(path.join(gamesystemDir, fileName), "utf-8"); - if(path.parse(fileName).name === path.basename(gamesystemDir) ) { - if((path.basename(gamesystemDir) === path.parse(fileName).name) && path.basename(path.parse(gamesystemDir).dir) === "gamesystems") { - const loadedModel = new LoadModel(gamesystemData, ModelComponentType.GAMESYTEM); - loadedGamesystems.unshift(loadedModel) - } else { - const loadedModel = new RecursiveLoadModel(gamesystemData, ModelComponentType.GAMESYTEM, path.basename(gamesystemDir)) - loadedGamesystems.unshift(loadedModel); - } - - } else { - const secondCon = path.basename(gamesystemDir) === path.parse(fileName).name - const thirdCon = path.basename(path.parse(gamesystemDir).dir) === "gamesystems" - - if(path.basename(gamesystemDir) === "gamesystems"){ - const loadedModel = new LoadModel(gamesystemData, ModelComponentType.GAMESYTEM) - loadedGamesystems.push(loadedModel); - } else { - - const loadedModel = new RecursiveLoadModel(gamesystemData, ModelComponentType.GAMESYTEM, path.basename(gamesystemDir)) - loadedGamesystems.push(loadedModel); - } - - } - } - }) - return loadedGamesystems; - } - -} diff --git a/app/StorageModel.ts b/app/StorageModel.ts deleted file mode 100644 index 392016a..0000000 --- a/app/StorageModel.ts +++ /dev/null @@ -1,12 +0,0 @@ -class StorageModel { - jsonString: string - fileName: string - storageDir: string - - - constructor(jsonString: string, fileName: string, storageDir: string) { - this.jsonString = jsonString; - this.fileName = fileName; - this.storageDir = storageDir; - } -} diff --git a/app/main.ts b/app/main.ts index 3d4cf11..71b92c3 100644 --- a/app/main.ts +++ b/app/main.ts @@ -1,11 +1,7 @@ import {app, BrowserWindow, dialog, globalShortcut, ipcMain, Menu, screen} from 'electron'; import * as path from 'path'; import * as fs from 'fs'; -import {StorageModel} from "../src/app/game-model/fs/StorageModel"; -import {SaveProject} from "./SaveProject"; -import {DeleteModel} from "../src/app/game-model/fs/DeleteModel"; -import {ModelComponentType} from "../src/app/game-model/ModelComponentType"; -import {DeleteTransaction} from "./DeleteModel"; +import {GameModelLoader} from "./storage/loader/GameModelLoader"; let win: BrowserWindow | null = null; const args = process.argv.slice(1), @@ -96,15 +92,15 @@ function createWindow(): BrowserWindow { contextMenu.popup({ window: win!, x: params.x, y: params.y }); }) - ipcMain.on('save-model', (event, storageModels: StorageModel[]) => { + /*ipcMain.on('save-model', (event, storageModels: StorageModel[]) => { console.log("Save Model") SaveProject.saveProject(projectDirectory, storageModels); - }) + })*/ - ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => { + /*ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => { console.log("Delete Model: ", deletedComponent) deleteComponent(deletedComponent); - }) + })*/ const menuTemplate = [ { @@ -206,8 +202,8 @@ function loadDevProjectAtStart() { function openProjectFromFile(openProjectDir: string) { projectDirectory = openProjectDir - console.log("Open Project-Directory: ", openProjectDir) - const loadedProject = SaveProject.loadProject(openProjectDir) + const gameModelLoader = new GameModelLoader(openProjectDir); + const loadedProject = gameModelLoader.loadGameModel(); win!.webContents.send("open-project", loadedProject) } @@ -215,11 +211,11 @@ function saveProject() { win!.webContents.send('get-project-data') } -function deleteComponent(component: DeleteModel) { +/*function deleteComponent(component: DeleteModel) { console.log("Delete Component") if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) { DeleteTransaction.deleteScriptAccount(projectDirectory, component.componentName); } else if(component.modeltype === ModelComponentType.GAMESYTEM) { DeleteTransaction.deleteGamesystem(projectDirectory, component.componentName); } -} +}*/ diff --git a/app/storage/FileUtils.ts b/app/storage/FileUtils.ts new file mode 100644 index 0000000..3d267fb --- /dev/null +++ b/app/storage/FileUtils.ts @@ -0,0 +1,13 @@ +import * as fs from "fs"; +import * as path from "node:path"; + + +export class FileUtils { + public static listFilesInDirectory(directory: string) { + if(fs.lstatSync(directory).isDirectory()) { + return fs.readdirSync(directory).map(fileName => path.join(directory, fileName)) + } else { + return []; + } + } +} diff --git a/app/storage/ModelComponentFileDirectory.ts b/app/storage/ModelComponentFileDirectory.ts new file mode 100644 index 0000000..35514b9 --- /dev/null +++ b/app/storage/ModelComponentFileDirectory.ts @@ -0,0 +1,6 @@ +export class ModelComponentFileDirectory { + public static SCRIPTACCOUNT_DIR_NAME = "script-accounts" + public static GAMESYSTEM_DIR_NAME = "gamesystems"; + public static GAMESYSTEM_SIMPLE_DIR_NAME = "simple"; + public static GAMESYSTEM_PRODUCT_DIR_NAME = "product"; +} diff --git a/app/storage/StoreComponent.ts b/app/storage/StoreComponent.ts new file mode 100644 index 0000000..95dea82 --- /dev/null +++ b/app/storage/StoreComponent.ts @@ -0,0 +1,13 @@ +import {ModelComponentType} from "../../src/app/project/game-model/ModelComponentType"; + + +export class StoreComponent { + jsonString: string + fileName: string + componentType: ModelComponentType + constructor(jsonString: string, fileName: string, componentType: ModelComponentType) { + this.jsonString = jsonString; + this.fileName = fileName; + this.componentType = componentType + } +} diff --git a/app/storage/StoredGameModel.ts b/app/storage/StoredGameModel.ts new file mode 100644 index 0000000..8104b44 --- /dev/null +++ b/app/storage/StoredGameModel.ts @@ -0,0 +1,12 @@ +import {StoreComponent} from "./StoreComponent"; + +export class StoredGameModel { + gameModelName: string + loadedModels: StoreComponent[] + + + constructor(gameModelName: string, loadedModels: StoreComponent[]) { + this.gameModelName = gameModelName; + this.loadedModels = loadedModels; + } +} diff --git a/app/storage/loader/GameModelLoader.ts b/app/storage/loader/GameModelLoader.ts new file mode 100644 index 0000000..b077721 --- /dev/null +++ b/app/storage/loader/GameModelLoader.ts @@ -0,0 +1,43 @@ +import {StoredGameModel} from "../StoredGameModel"; +import {StoreComponent} from "../StoreComponent"; +import * as path from "node:path"; +import * as fs from "fs"; +import {ModelComponentFileDirectory} from "../ModelComponentFileDirectory"; +import {ScriptAccountLoader} from "./ScriptAccountLoader"; + +export class GameModelLoader { + gameModelDir: string + + + constructor(gameModelDir: string) { + this.gameModelDir = gameModelDir; + } + + loadGameModel(): StoredGameModel { + const gameModelName = path.basename(this.gameModelDir) + const gameModelComponents: StoreComponent[] = this.loadGameModelComponents(); + + return new StoredGameModel(gameModelName, gameModelComponents); + } + + private loadGameModelComponents(): StoreComponent[] { + let gameModelComponents: StoreComponent[] = this.loadScriptAccountComponents() + gameModelComponents = gameModelComponents.concat(this.loadGamesystems()) + return gameModelComponents + } + + private loadScriptAccountComponents() { + const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME); + const scriptAccountLoader = new ScriptAccountLoader(scriptAccountDir); + return scriptAccountLoader.loadScriptAccounts() + } + + private loadGamesystems(): StoreComponent[] { + return [] + } + + + + + +} diff --git a/app/storage/loader/ScriptAccountLoader.ts b/app/storage/loader/ScriptAccountLoader.ts new file mode 100644 index 0000000..4914584 --- /dev/null +++ b/app/storage/loader/ScriptAccountLoader.ts @@ -0,0 +1,34 @@ +import {StoreComponent} from "../StoreComponent"; +import {FileUtils} from "../FileUtils"; +import {ModelComponentType} from "../../../src/app/project/game-model/ModelComponentType"; +import * as fs from "fs"; +import {ModelComponentFileDirectory} from "../ModelComponentFileDirectory"; +import {load} from "@angular-devkit/build-angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks"; + +export class ScriptAccountLoader { + scriptAccountDir: string + + + constructor(scriptAccountDir: string) { + this.scriptAccountDir = scriptAccountDir; + } + + loadScriptAccounts(): StoreComponent[] { + const scriptAccountFiles = FileUtils.listFilesInDirectory(this.scriptAccountDir); + const loadedScriptAccounts: StoreComponent[] = [] + scriptAccountFiles.forEach(scriptAccountFile => { + const loadedScriptAccount = this.loadScriptAccount(scriptAccountFile); + if(loadedScriptAccount != undefined) { + loadedScriptAccounts.push(loadedScriptAccount) + } + }) + return loadedScriptAccounts; + } + + private loadScriptAccount(scriptAccountFile: string) { + if(scriptAccountFile.endsWith(".json")) { + const scriptAccountData = fs.readFileSync(scriptAccountFile, 'utf-8'); + return new StoreComponent(scriptAccountData, scriptAccountFile, ModelComponentType.SCRIPTACCOUNT); + } + } +} diff --git a/src/app/app.component.html b/src/app/app.component.html index 2801b21..e345414 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -22,7 +22,7 @@ - + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3c81077..c3a6b1a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,24 +1,20 @@ import {Component, NgZone, OnInit, ViewChild} from '@angular/core'; -import {ElectronService} from './core/services'; -import {APP_CONFIG} from '../environments/environment'; -import {ModelComponentType} from "./game-model/ModelComponentType"; import {MatDrawerContainer} from "@angular/material/sidenav"; -import {ModelComponentTypeUtillities} from "./game-model/ModelComponentTypeUtillities"; -import {GameModel} from "./game-model/GameModel"; import {EditorComponent} from "./editor/editor.component"; -import {ModelComponent} from "./game-model/ModelComponent"; import { ScriptAccountOverviewComponent } from "./side-overviews/script-account-overview/script-account-overview.component"; import {MatDialog} from "@angular/material/dialog"; import {DeleteConfirmationDialogComponent} from "./delete-confirmation-dialog/delete-confirmation-dialog.component"; -import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount"; import {GamescriptOverviewComponent} from "./side-overviews/gamescript-overview/gamescript-overview.component"; -import {LoadedProject} from "../../app/LoadedProject"; -import {ProcessLoadedProject} from "./game-model/fs/ProcessLoadedProject"; -import {StoreProject} from "./game-model/fs/store/StoreProject"; -import {Gamesystem} from "./game-model/gamesystems/Gamesystem"; -import {DeleteModel} from "./game-model/fs/DeleteModel"; + +import {ProjectService} from "./project/project.service"; +import {ModelComponentType} from "./project/game-model/ModelComponentType"; +import {ModelComponentTypeUtillities} from "./project/game-model/ModelComponentTypeUtillities"; +import {ScriptAccount} from "./project/game-model/scriptAccounts/ScriptAccount"; +import {Gamesystem} from "./project/game-model/gamesystems/Gamesystem"; +import {ModelComponent} from "./project/game-model/ModelComponent"; +import {GameModel} from "./project/game-model/GameModel"; @Component({ selector: 'app-root', @@ -35,44 +31,11 @@ export class AppComponent implements OnInit{ gameModel: GameModel | undefined - constructor(private electronService: ElectronService, - private zone: NgZone, - private dialog: MatDialog + constructor(private zone: NgZone, + private dialog: MatDialog, + private projectService: ProjectService ) { - console.log('APP_CONFIG', APP_CONFIG); - if(this.gameModel == undefined) { - this.gameModel = new GameModel("Unknown GameModel") - } - if (electronService.isElectron) { - console.log(process.env); - console.log('Run in electron'); - console.log('Electron ipcRenderer', this.electronService.ipcRenderer); - console.log('NodeJS childProcess', this.electronService.childProcess); - - electronService.ipcRenderer.on('context-menu', (event: any, message: string) => { - this.zone.run(() => { - this.onContextMenuMessageRecieved(message); - }); - }) - - electronService.ipcRenderer.on('get-project-data', (event: any, message: string) => { - this.zone.run(() => { - this.saveGameModel(); - }) - }) - - electronService.ipcRenderer.on('open-project', (event: any, loadedProject: LoadedProject) => { - this.gameModel = ProcessLoadedProject.processLoadedProject(loadedProject) - }) - } else { - console.log('Run in browser'); - } - } - - saveGameModel() { - const storageModels = StoreProject.storeProject(this.gameModel!); - this.electronService.ipcRenderer.send('save-model', storageModels) } onContextMenuMessageRecieved(message: string) { @@ -100,7 +63,7 @@ export class AppComponent implements OnInit{ } break; case ModelComponentType.GAMESYTEM: { if(this.gamesystemOverview!.selectedGamesystem != undefined) { - const gamesystem = this.gameModel!.findGamesystem(this.gamesystemOverview!.selectedGamesystemName!); + const gamesystem = this.projectService!.gameModel!.findGamesystem(this.gamesystemOverview!.selectedGamesystemName!); this.editor!.openGameModelComponent(gamesystem!); } } break @@ -115,11 +78,11 @@ export class AppComponent implements OnInit{ dialogRef.afterClosed().subscribe(res => { if(res != undefined && res) { if(affectedModelComponent instanceof ScriptAccount) { - this.gameModel!.removeScriptAccount(affectedModelComponent); - this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT)) + this.projectService!.gameModel!.removeScriptAccount(affectedModelComponent); + //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT)) } else if(affectedModelComponent instanceof Gamesystem) { - this.gameModel!.removeGamesystem(affectedModelComponent); - this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM)) + //this.gameModel!.removeGamesystem(affectedModelComponent); + //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM)) this.gamesystemOverview!.refresh() } } @@ -134,7 +97,7 @@ export class AppComponent implements OnInit{ } private onCreateNewScriptAccount() { - const createdScriptAccount = this.gameModel!.createScriptAccount("New ScriptAccount"); + const createdScriptAccount = this.projectService!.gameModel!.createScriptAccount("New ScriptAccount"); if(createdScriptAccount != undefined) { this.editor?.openGameModelComponent(createdScriptAccount); } else { @@ -151,7 +114,7 @@ export class AppComponent implements OnInit{ } - const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName); + const createdGamesystem = this.projectService!.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName); if(createdGamesystem != undefined) { this.gamesystemOverview!.refresh(); this.editor?.openGameModelComponent(createdGamesystem); @@ -176,6 +139,7 @@ export class AppComponent implements OnInit{ } ngOnInit() { + this.gameModel = this.projectService.gameModel /*this.gameModel = new GameModel("No More"); this.gameModel.createScriptAccount("Temperature"); this.gameModel.createScriptAccount("Luftfeuchtigkeit"); diff --git a/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts b/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts index 8eacb90..00c63d2 100644 --- a/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts +++ b/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts @@ -1,7 +1,7 @@ import {Component, Inject} from '@angular/core'; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; -import {ModelComponentTypeUtillities} from "../game-model/ModelComponentTypeUtillities"; -import {ModelComponent} from "../game-model/ModelComponent"; +import {ModelComponent} from "../project/game-model/ModelComponent"; + @Component({ selector: 'app-delete-confirmation-dialog', @@ -13,7 +13,6 @@ export class DeleteConfirmationDialogComponent { constructor(private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) { } - protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities; cancel() { this.dialogRef.close(false); diff --git a/src/app/editor/editor.component.ts b/src/app/editor/editor.component.ts index a1e377f..887f4d8 100644 --- a/src/app/editor/editor.component.ts +++ b/src/app/editor/editor.component.ts @@ -1,11 +1,12 @@ import {Component, EventEmitter, Input, Output} from '@angular/core'; -import {GameModel} from "../game-model/GameModel"; -import {ModelComponent} from "../game-model/ModelComponent"; -import {ModelComponentType} from "../game-model/ModelComponentType"; -import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount"; -import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; -import {State} from "../game-model/gamesystems/states/State"; -import {Transition} from "../game-model/gamesystems/transitions/Transition"; +import {ModelComponent} from "../project/game-model/ModelComponent"; +import {GameModel} from "../project/game-model/GameModel"; +import {ScriptAccount} from "../project/game-model/scriptAccounts/ScriptAccount"; +import {Gamesystem} from "../project/game-model/gamesystems/Gamesystem"; +import {State} from "../project/game-model/gamesystems/states/State"; +import {Transition} from "../project/game-model/gamesystems/transitions/Transition"; +import {ModelComponentType} from "../project/game-model/ModelComponentType"; + @Component({ selector: 'app-editor', @@ -43,9 +44,10 @@ export class EditorComponent { } } - protected readonly ModelComponentType = ModelComponentType; onModelNameUpdate() { this.onModelNameUpdateEmitter.emit(true); } + + protected readonly ModelComponentType = ModelComponentType; } diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index a35cc1b..f14dda3 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -1,11 +1,10 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {GameModel} from "../../game-model/GameModel"; -import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; -import {State} from "../../game-model/gamesystems/states/State"; -import {Transition} from "../../game-model/gamesystems/transitions/Transition"; -import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; -import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; -import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {State} from "../../project/game-model/gamesystems/states/State"; +import {Gamesystem} from "../../project/game-model/gamesystems/Gamesystem"; +import { Transition } from '../../project/game-model/gamesystems/transitions/Transition'; +import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; +import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; @Component({ selector: 'app-gamesystem-editor', diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts b/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts index d1951be..2d0c7d0 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/LeafGamesystemCalculator.ts @@ -1,9 +1,9 @@ -import {Gamesystem} from "../../../game-model/gamesystems/Gamesystem"; -import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; -import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem"; -import {State} from "../../../game-model/gamesystems/states/State"; -import {ProductState} from "../../../game-model/gamesystems/states/ProductState"; -import {SimpleState} from "../../../game-model/gamesystems/states/SimpleState"; +import {Gamesystem} from "../../../project/game-model/gamesystems/Gamesystem"; +import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../project/game-model/gamesystems/ProductGamesystem"; +import {State} from "../../../project/game-model/gamesystems/states/State"; +import {SimpleState} from "../../../project/game-model/gamesystems/states/SimpleState"; +import {ProductState} from "../../../project/game-model/gamesystems/states/ProductState"; export class LeafGamesystemCalculator { diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts index eebcefd..d1f7f23 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts @@ -1,10 +1,9 @@ import {Component, EventEmitter, Input, Output} from '@angular/core'; -import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem"; -import {ProductStateEditorComponent} from "../state-editor/product-state-editor/product-state-editor.component"; -import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; import { ProductTransitionEditorComponent } from "../transition-editor/product-transition-editor/product-transition-editor.component"; +import {ProductGamesystem} from "../../../project/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem"; diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts index d93d81a..4eaeff9 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts @@ -1,7 +1,7 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {ScriptAccountCondition} from "../../../game-model/gamesystems/conditions/ScriptAccountCondition"; import {MatTableDataSource} from "@angular/material/table"; -import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-scriptaccount-condition-editor', diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts index 5baf0e9..36af424 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts @@ -1,7 +1,7 @@ import {Component, Input} from '@angular/core'; -import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; import {MatTableDataSource} from "@angular/material/table"; -import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount"; +import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem"; +import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-simple-gamesystem-editor', diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts index a0b6afe..328928e 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts @@ -1,15 +1,13 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import { MatTableDataSource } from "@angular/material/table"; -import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; -import {State} from "../../../../game-model/gamesystems/states/State"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; -import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; -import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; import {animate, state, style, transition, trigger} from "@angular/animations"; +import {ProductGamesystem} from "../../../../project/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../project/game-model/gamesystems/states/ProductState"; +import {State} from "../../../../project/game-model/gamesystems/states/State"; @Component({ selector: 'app-product-state-editor', @@ -55,7 +53,6 @@ export class ProductStateEditorComponent implements OnInit{ }) } - protected readonly SimpleState = SimpleState; getLeafState(state: State, i: number) { return LeafGamesystemCalculator.calcLeafStates(state)[i]; diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 93dd0b1..049814c 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -1,13 +1,11 @@ import {Component, Input, OnInit} from '@angular/core'; -import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; import {MatTableDataSource} from "@angular/material/table"; import {animate, state, style, transition, trigger} from "@angular/animations"; import {MatSnackBar} from "@angular/material/snack-bar"; -import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; -import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; -import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState"; +import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; +import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; @Component({ selector: 'app-simple-state-editor', diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index 741f8b6..2f164d6 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -1,13 +1,13 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import { MatTableDataSource } from "@angular/material/table"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; -import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; -import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; import {animate, state, style, transition, trigger} from "@angular/animations"; +import {ProductGamesystem} from "../../../../project/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; +import {ProductTransition} from "../../../../project/game-model/gamesystems/transitions/ProductTransition"; +import {ProductState} from "../../../../project/game-model/gamesystems/states/ProductState"; class DisplayedColumnName { displayedName: string internalName: string diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts index b569ba1..e8392ee 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -1,8 +1,8 @@ import {Component, Input, OnInit} from '@angular/core'; -import {Transition} from "../../../../game-model/gamesystems/transitions/Transition"; import {MatTableDataSource} from "@angular/material/table"; -import {ScriptAccountAction} from "../../../../game-model/gamesystems/actions/ScriptAccountAction"; -import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount"; +import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition"; +import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction"; @Component({ selector: 'app-scriptaccount-action-editor', diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index 4c0030e..d26acd6 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -1,13 +1,13 @@ import {Component, Input, OnInit} from '@angular/core'; -import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import { MatTableDataSource } from "@angular/material/table"; -import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/SimpleTransition"; import {animate, state, style, transition, trigger} from "@angular/animations"; -import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; -import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; +import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount"; +import {SimpleTransition} from "../../../../project/game-model/gamesystems/transitions/SimpleTransition"; +import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState"; +import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; @Component({ selector: 'app-simple-transition-editor', templateUrl: './simple-transition-editor.component.html', diff --git a/src/app/editor/model-component-editor/model-component-editor.component.ts b/src/app/editor/model-component-editor/model-component-editor.component.ts index c527bb5..a94547c 100644 --- a/src/app/editor/model-component-editor/model-component-editor.component.ts +++ b/src/app/editor/model-component-editor/model-component-editor.component.ts @@ -1,6 +1,6 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {ModelComponent} from "../../game-model/ModelComponent"; import {FormControl, Validators} from "@angular/forms"; +import {ModelComponent} from "../../project/game-model/ModelComponent"; @Component({ selector: 'app-model-component-editor', diff --git a/src/app/editor/script-account-editor/script-account-editor.component.ts b/src/app/editor/script-account-editor/script-account-editor.component.ts index 4ee4a56..75670de 100644 --- a/src/app/editor/script-account-editor/script-account-editor.component.ts +++ b/src/app/editor/script-account-editor/script-account-editor.component.ts @@ -1,12 +1,12 @@ import {Component, Input, OnInit} from '@angular/core'; -import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; -import {ModelComponent} from "../../game-model/ModelComponent"; + import {MatFormField} from "@angular/material/form-field"; import {MatInput} from "@angular/material/input"; import {FormControl, FormGroupDirective, FormsModule, NgForm, Validators} from "@angular/forms"; import {NgIf} from "@angular/common"; import {ErrorStateMatcher} from "@angular/material/core"; import {ElectronService} from "../../core/services"; +import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; export class MyErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { diff --git a/src/app/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts similarity index 100% rename from src/app/game-model/GameModel.ts rename to src/app/project/game-model/GameModel.ts diff --git a/src/app/game-model/ModelComponent.ts b/src/app/project/game-model/ModelComponent.ts similarity index 100% rename from src/app/game-model/ModelComponent.ts rename to src/app/project/game-model/ModelComponent.ts diff --git a/src/app/game-model/ModelComponentType.ts b/src/app/project/game-model/ModelComponentType.ts similarity index 100% rename from src/app/game-model/ModelComponentType.ts rename to src/app/project/game-model/ModelComponentType.ts diff --git a/src/app/game-model/ModelComponentTypeUtillities.ts b/src/app/project/game-model/ModelComponentTypeUtillities.ts similarity index 100% rename from src/app/game-model/ModelComponentTypeUtillities.ts rename to src/app/project/game-model/ModelComponentTypeUtillities.ts diff --git a/src/app/game-model/SaveComponent.ts b/src/app/project/game-model/SaveComponent.ts similarity index 100% rename from src/app/game-model/SaveComponent.ts rename to src/app/project/game-model/SaveComponent.ts diff --git a/src/app/game-model/fs/DeleteModel.ts b/src/app/project/game-model/fs/DeleteModel.ts similarity index 100% rename from src/app/game-model/fs/DeleteModel.ts rename to src/app/project/game-model/fs/DeleteModel.ts diff --git a/src/app/game-model/fs/ProcessLoadedProject.ts b/src/app/project/game-model/fs/ProcessLoadedProject.ts similarity index 100% rename from src/app/game-model/fs/ProcessLoadedProject.ts rename to src/app/project/game-model/fs/ProcessLoadedProject.ts diff --git a/src/app/game-model/fs/StorageModel.ts b/src/app/project/game-model/fs/StorageModel.ts similarity index 100% rename from src/app/game-model/fs/StorageModel.ts rename to src/app/project/game-model/fs/StorageModel.ts diff --git a/src/app/game-model/fs/parser/ProductGamesystemParser.ts b/src/app/project/game-model/fs/parser/ProductGamesystemParser.ts similarity index 100% rename from src/app/game-model/fs/parser/ProductGamesystemParser.ts rename to src/app/project/game-model/fs/parser/ProductGamesystemParser.ts diff --git a/src/app/game-model/fs/parser/SimpleGamesystemParser.ts b/src/app/project/game-model/fs/parser/SimpleGamesystemParser.ts similarity index 100% rename from src/app/game-model/fs/parser/SimpleGamesystemParser.ts rename to src/app/project/game-model/fs/parser/SimpleGamesystemParser.ts diff --git a/src/app/game-model/fs/store/StoreProject.ts b/src/app/project/game-model/fs/store/StoreProject.ts similarity index 100% rename from src/app/game-model/fs/store/StoreProject.ts rename to src/app/project/game-model/fs/store/StoreProject.ts diff --git a/src/app/game-model/game-model.module.ts b/src/app/project/game-model/game-model.module.ts similarity index 100% rename from src/app/game-model/game-model.module.ts rename to src/app/project/game-model/game-model.module.ts diff --git a/src/app/game-model/gamesystems/Gamesystem.ts b/src/app/project/game-model/gamesystems/Gamesystem.ts similarity index 100% rename from src/app/game-model/gamesystems/Gamesystem.ts rename to src/app/project/game-model/gamesystems/Gamesystem.ts diff --git a/src/app/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts similarity index 99% rename from src/app/game-model/gamesystems/ProductGamesystem.ts rename to src/app/project/game-model/gamesystems/ProductGamesystem.ts index 087e019..630b2c3 100644 --- a/src/app/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -6,7 +6,6 @@ import {Transition} from "./transitions/Transition"; import {SimpleState} from "./states/SimpleState"; import {SimpleGamesystem} from "./SimpleGamesystem"; import {GameModel} from "../GameModel"; -import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer"; import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition"; import {ScriptAccountAction} from "./actions/ScriptAccountAction"; diff --git a/src/app/game-model/gamesystems/SimpleGamesystem.ts b/src/app/project/game-model/gamesystems/SimpleGamesystem.ts similarity index 100% rename from src/app/game-model/gamesystems/SimpleGamesystem.ts rename to src/app/project/game-model/gamesystems/SimpleGamesystem.ts diff --git a/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts b/src/app/project/game-model/gamesystems/actions/ScriptAccountAction.ts similarity index 100% rename from src/app/game-model/gamesystems/actions/ScriptAccountAction.ts rename to src/app/project/game-model/gamesystems/actions/ScriptAccountAction.ts diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition.ts similarity index 100% rename from src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts rename to src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition.ts diff --git a/src/app/game-model/gamesystems/states/ProductState.ts b/src/app/project/game-model/gamesystems/states/ProductState.ts similarity index 100% rename from src/app/game-model/gamesystems/states/ProductState.ts rename to src/app/project/game-model/gamesystems/states/ProductState.ts diff --git a/src/app/game-model/gamesystems/states/SimpleState.ts b/src/app/project/game-model/gamesystems/states/SimpleState.ts similarity index 100% rename from src/app/game-model/gamesystems/states/SimpleState.ts rename to src/app/project/game-model/gamesystems/states/SimpleState.ts diff --git a/src/app/game-model/gamesystems/states/State.ts b/src/app/project/game-model/gamesystems/states/State.ts similarity index 100% rename from src/app/game-model/gamesystems/states/State.ts rename to src/app/project/game-model/gamesystems/states/State.ts diff --git a/src/app/game-model/gamesystems/transitions/ProductTransition.ts b/src/app/project/game-model/gamesystems/transitions/ProductTransition.ts similarity index 100% rename from src/app/game-model/gamesystems/transitions/ProductTransition.ts rename to src/app/project/game-model/gamesystems/transitions/ProductTransition.ts diff --git a/src/app/game-model/gamesystems/transitions/SimpleTransition.ts b/src/app/project/game-model/gamesystems/transitions/SimpleTransition.ts similarity index 100% rename from src/app/game-model/gamesystems/transitions/SimpleTransition.ts rename to src/app/project/game-model/gamesystems/transitions/SimpleTransition.ts diff --git a/src/app/game-model/gamesystems/transitions/Transition.ts b/src/app/project/game-model/gamesystems/transitions/Transition.ts similarity index 100% rename from src/app/game-model/gamesystems/transitions/Transition.ts rename to src/app/project/game-model/gamesystems/transitions/Transition.ts diff --git a/src/app/game-model/scriptAccounts/ScriptAccount.ts b/src/app/project/game-model/scriptAccounts/ScriptAccount.ts similarity index 100% rename from src/app/game-model/scriptAccounts/ScriptAccount.ts rename to src/app/project/game-model/scriptAccounts/ScriptAccount.ts diff --git a/src/app/project/parser/ScriptAccountParser.ts b/src/app/project/parser/ScriptAccountParser.ts new file mode 100644 index 0000000..56a99b7 --- /dev/null +++ b/src/app/project/parser/ScriptAccountParser.ts @@ -0,0 +1,12 @@ +import {StoreComponent} from "../../../../app/storage/StoreComponent"; +import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount"; + +export class ScriptAccountParser { + + public static parseScriptAccount(storedComponent: StoreComponent): ScriptAccount { + console.log("Parse ScriptAccount: ", storedComponent.fileName) + const parsedScriptAccount = new ScriptAccount("", ""); + Object.assign(parsedScriptAccount, JSON.parse(storedComponent.jsonString)); + return parsedScriptAccount; + } +} diff --git a/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts b/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts index a3341ac..3194a5f 100644 --- a/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts +++ b/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts @@ -1,13 +1,13 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; -import {State} from "../../game-model/gamesystems/states/State"; -import {Transition} from "../../game-model/gamesystems/transitions/Transition"; -import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; import {FlatTreeControl} from "@angular/cdk/tree"; import {MatTreeFlatDataSource, MatTreeFlattener} from "@angular/material/tree"; -import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; -import {GameModel} from "../../game-model/GameModel"; import {ElectronService} from "../../core/services"; +import {GameModel} from "../../project/game-model/GameModel"; +import {Gamesystem} from "../../project/game-model/gamesystems/Gamesystem"; +import {State} from "../../project/game-model/gamesystems/states/State"; +import {Transition} from "../../project/game-model/gamesystems/transitions/Transition"; +import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; interface FlatNode { diff --git a/src/app/side-overviews/script-account-overview/script-account-overview.component.ts b/src/app/side-overviews/script-account-overview/script-account-overview.component.ts index f0d15da..3643289 100644 --- a/src/app/side-overviews/script-account-overview/script-account-overview.component.ts +++ b/src/app/side-overviews/script-account-overview/script-account-overview.component.ts @@ -1,7 +1,7 @@ import {Component, EventEmitter, Input, NgZone, Output} from '@angular/core'; -import {GameModel} from "../../game-model/GameModel"; -import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ElectronService} from "../../core/services"; +import {GameModel} from "../../project/game-model/GameModel"; +import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-script-account-overview', From b31f72475a1c95b45aeb8f10e39aceac10e151cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 09:26:52 +0100 Subject: [PATCH 38/58] Introduce Project Service as interface to persistance of gamemodel --- app/storage/FileUtils.js | 17 ++++++++ app/storage/ModelComponentFileDirectory.js | 11 ++++++ app/storage/StoreComponent.js | 12 ++++++ app/storage/StoredGameModel.js | 11 ++++++ app/storage/loader/GameModelLoader.js | 32 +++++++++++++++ app/storage/loader/ScriptAccountLoader.js | 31 +++++++++++++++ src/app/project/project.service.spec.ts | 16 ++++++++ src/app/project/project.service.ts | 45 ++++++++++++++++++++++ 8 files changed, 175 insertions(+) create mode 100644 app/storage/FileUtils.js create mode 100644 app/storage/ModelComponentFileDirectory.js create mode 100644 app/storage/StoreComponent.js create mode 100644 app/storage/StoredGameModel.js create mode 100644 app/storage/loader/GameModelLoader.js create mode 100644 app/storage/loader/ScriptAccountLoader.js create mode 100644 src/app/project/project.service.spec.ts create mode 100644 src/app/project/project.service.ts diff --git a/app/storage/FileUtils.js b/app/storage/FileUtils.js new file mode 100644 index 0000000..6a966ba --- /dev/null +++ b/app/storage/FileUtils.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FileUtils = void 0; +const fs = require("fs"); +const path = require("node:path"); +class FileUtils { + static listFilesInDirectory(directory) { + if (fs.lstatSync(directory).isDirectory()) { + return fs.readdirSync(directory).map(fileName => path.join(directory, fileName)); + } + else { + return []; + } + } +} +exports.FileUtils = FileUtils; +//# sourceMappingURL=FileUtils.js.map \ No newline at end of file diff --git a/app/storage/ModelComponentFileDirectory.js b/app/storage/ModelComponentFileDirectory.js new file mode 100644 index 0000000..9e2de51 --- /dev/null +++ b/app/storage/ModelComponentFileDirectory.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ModelComponentFileDirectory = void 0; +class ModelComponentFileDirectory { +} +exports.ModelComponentFileDirectory = ModelComponentFileDirectory; +ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME = "script-accounts"; +ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME = "gamesystems"; +ModelComponentFileDirectory.GAMESYSTEM_SIMPLE_DIR_NAME = "simple"; +ModelComponentFileDirectory.GAMESYSTEM_PRODUCT_DIR_NAME = "product"; +//# sourceMappingURL=ModelComponentFileDirectory.js.map \ No newline at end of file diff --git a/app/storage/StoreComponent.js b/app/storage/StoreComponent.js new file mode 100644 index 0000000..a4ca044 --- /dev/null +++ b/app/storage/StoreComponent.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StoreComponent = void 0; +class StoreComponent { + constructor(jsonString, fileName, componentType) { + this.jsonString = jsonString; + this.fileName = fileName; + this.componentType = componentType; + } +} +exports.StoreComponent = StoreComponent; +//# sourceMappingURL=StoreComponent.js.map \ No newline at end of file diff --git a/app/storage/StoredGameModel.js b/app/storage/StoredGameModel.js new file mode 100644 index 0000000..076e1a0 --- /dev/null +++ b/app/storage/StoredGameModel.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StoredGameModel = void 0; +class StoredGameModel { + constructor(gameModelName, loadedModels) { + this.gameModelName = gameModelName; + this.loadedModels = loadedModels; + } +} +exports.StoredGameModel = StoredGameModel; +//# sourceMappingURL=StoredGameModel.js.map \ No newline at end of file diff --git a/app/storage/loader/GameModelLoader.js b/app/storage/loader/GameModelLoader.js new file mode 100644 index 0000000..33c28fb --- /dev/null +++ b/app/storage/loader/GameModelLoader.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GameModelLoader = void 0; +const StoredGameModel_1 = require("../StoredGameModel"); +const path = require("node:path"); +const ModelComponentFileDirectory_1 = require("../ModelComponentFileDirectory"); +const ScriptAccountLoader_1 = require("./ScriptAccountLoader"); +class GameModelLoader { + constructor(gameModelDir) { + this.gameModelDir = gameModelDir; + } + loadGameModel() { + const gameModelName = path.basename(this.gameModelDir); + const gameModelComponents = this.loadGameModelComponents(); + return new StoredGameModel_1.StoredGameModel(gameModelName, gameModelComponents); + } + loadGameModelComponents() { + let gameModelComponents = this.loadScriptAccountComponents(); + gameModelComponents = gameModelComponents.concat(this.loadGamesystems()); + return gameModelComponents; + } + loadScriptAccountComponents() { + const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME); + const scriptAccountLoader = new ScriptAccountLoader_1.ScriptAccountLoader(scriptAccountDir); + return scriptAccountLoader.loadScriptAccounts(); + } + loadGamesystems() { + return []; + } +} +exports.GameModelLoader = GameModelLoader; +//# sourceMappingURL=GameModelLoader.js.map \ No newline at end of file diff --git a/app/storage/loader/ScriptAccountLoader.js b/app/storage/loader/ScriptAccountLoader.js new file mode 100644 index 0000000..5b5c1a2 --- /dev/null +++ b/app/storage/loader/ScriptAccountLoader.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ScriptAccountLoader = void 0; +const StoreComponent_1 = require("../StoreComponent"); +const FileUtils_1 = require("../FileUtils"); +const ModelComponentType_1 = require("../../../src/app/project/game-model/ModelComponentType"); +const fs = require("fs"); +class ScriptAccountLoader { + constructor(scriptAccountDir) { + this.scriptAccountDir = scriptAccountDir; + } + loadScriptAccounts() { + const scriptAccountFiles = FileUtils_1.FileUtils.listFilesInDirectory(this.scriptAccountDir); + const loadedScriptAccounts = []; + scriptAccountFiles.forEach(scriptAccountFile => { + const loadedScriptAccount = this.loadScriptAccount(scriptAccountFile); + if (loadedScriptAccount != undefined) { + loadedScriptAccounts.push(loadedScriptAccount); + } + }); + return loadedScriptAccounts; + } + loadScriptAccount(scriptAccountFile) { + if (scriptAccountFile.endsWith(".json")) { + const scriptAccountData = fs.readFileSync(scriptAccountFile, 'utf-8'); + return new StoreComponent_1.StoreComponent(scriptAccountData, scriptAccountFile, ModelComponentType_1.ModelComponentType.SCRIPTACCOUNT); + } + } +} +exports.ScriptAccountLoader = ScriptAccountLoader; +//# sourceMappingURL=ScriptAccountLoader.js.map \ No newline at end of file diff --git a/src/app/project/project.service.spec.ts b/src/app/project/project.service.spec.ts new file mode 100644 index 0000000..c70ac34 --- /dev/null +++ b/src/app/project/project.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ProjectService } from './project.service'; + +describe('ProjectService', () => { + let service: ProjectService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ProjectService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/project/project.service.ts b/src/app/project/project.service.ts new file mode 100644 index 0000000..b06fb8f --- /dev/null +++ b/src/app/project/project.service.ts @@ -0,0 +1,45 @@ +import { Injectable } from '@angular/core'; +import {ElectronService} from "../core/services"; +import {GameModel} from "./game-model/GameModel"; +import {StoredGameModel} from "../../../app/storage/StoredGameModel"; +import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "./game-model/ModelComponentType"; +import {ScriptAccountParser} from "./parser/ScriptAccountParser"; + +@Injectable({ + providedIn: 'root' +}) +export class ProjectService { + + gameModel: GameModel = new GameModel("New GameModel") + constructor(private electronService: ElectronService) { + if(electronService.isElectron) { + electronService.ipcRenderer.on('get-project-data', (event: any, message: string) => { + this.saveProject(); + }) + + electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => { + this.loadProject(loadedProject); + }) + } + } + + saveProject() { + + } + + loadProject(storedGameModel: StoredGameModel) { + const gameModel = new GameModel(storedGameModel.gameModelName) + storedGameModel.loadedModels.forEach(storedComponent => { + switch (storedComponent.componentType) { + case ModelComponentType.SCRIPTACCOUNT: { + const scriptAccount = ScriptAccountParser.parseScriptAccount(storedComponent); + gameModel.addScriptAccount(scriptAccount); + } + } + }) + this.gameModel = gameModel; + } + + +} From ed2f28760e6c922d179d5cfd8a52b7b3a71c7f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 11:19:32 +0100 Subject: [PATCH 39/58] Refactor Gamesystem parsing --- app/storage/loader/GameModelLoader.js | 5 +- app/storage/loader/GameModelLoader.ts | 5 +- app/storage/loader/GamesystemLoader.ts | 44 ++++++++++++++ .../gamesystemParser/GamesystemParser.ts | 60 +++++++++++++++++++ .../ParsedParentGamesystems.ts | 12 ++++ src/app/project/project.service.ts | 12 ++++ .../gamesystems/ParentTestSystem/Numbers.json | 32 ---------- .../ParentTestSystem/ParentTestSystem.json | 4 -- .../Weathersystem/Weathersystem.json | 10 +++- 9 files changed, 145 insertions(+), 39 deletions(-) create mode 100644 app/storage/loader/GamesystemLoader.ts create mode 100644 src/app/project/parser/gamesystemParser/GamesystemParser.ts create mode 100644 src/app/project/parser/gamesystemParser/ParsedParentGamesystems.ts delete mode 100644 testModel/gamesystems/ParentTestSystem/Numbers.json delete mode 100644 testModel/gamesystems/ParentTestSystem/ParentTestSystem.json diff --git a/app/storage/loader/GameModelLoader.js b/app/storage/loader/GameModelLoader.js index 33c28fb..a705ac9 100644 --- a/app/storage/loader/GameModelLoader.js +++ b/app/storage/loader/GameModelLoader.js @@ -5,6 +5,7 @@ const StoredGameModel_1 = require("../StoredGameModel"); const path = require("node:path"); const ModelComponentFileDirectory_1 = require("../ModelComponentFileDirectory"); const ScriptAccountLoader_1 = require("./ScriptAccountLoader"); +const GamesystemLoader_1 = require("./GamesystemLoader"); class GameModelLoader { constructor(gameModelDir) { this.gameModelDir = gameModelDir; @@ -25,7 +26,9 @@ class GameModelLoader { return scriptAccountLoader.loadScriptAccounts(); } loadGamesystems() { - return []; + const gamesystemDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME); + const gamesystemLoader = new GamesystemLoader_1.GamesystemLoader(gamesystemDir); + return gamesystemLoader.loadGamesystems(); } } exports.GameModelLoader = GameModelLoader; diff --git a/app/storage/loader/GameModelLoader.ts b/app/storage/loader/GameModelLoader.ts index b077721..d9edfb3 100644 --- a/app/storage/loader/GameModelLoader.ts +++ b/app/storage/loader/GameModelLoader.ts @@ -4,6 +4,7 @@ import * as path from "node:path"; import * as fs from "fs"; import {ModelComponentFileDirectory} from "../ModelComponentFileDirectory"; import {ScriptAccountLoader} from "./ScriptAccountLoader"; +import {GamesystemLoader} from "./GamesystemLoader"; export class GameModelLoader { gameModelDir: string @@ -33,7 +34,9 @@ export class GameModelLoader { } private loadGamesystems(): StoreComponent[] { - return [] + const gamesystemDir = path.join(this.gameModelDir, ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME); + const gamesystemLoader = new GamesystemLoader(gamesystemDir); + return gamesystemLoader.loadGamesystems(); } diff --git a/app/storage/loader/GamesystemLoader.ts b/app/storage/loader/GamesystemLoader.ts new file mode 100644 index 0000000..8ade2ca --- /dev/null +++ b/app/storage/loader/GamesystemLoader.ts @@ -0,0 +1,44 @@ +import {StoreComponent} from "../StoreComponent"; +import {FileUtils} from "../FileUtils"; +import * as fs from "fs"; +import * as path from "node:path"; +import {ModelComponentType} from "../../../src/app/project/game-model/ModelComponentType"; + +export class GamesystemLoader { + + gamesystemDir: string + + + constructor(gamesystemDir: string) { + this.gamesystemDir = gamesystemDir; + } + + loadGamesystems() { + return this.loadGamesystemsRecursivly(this.gamesystemDir) + } + + private loadGamesystemsRecursivly(currentGamesystemDir: string) { + let loadedGamesystems: StoreComponent[] = [] + const gamesystemFiles = FileUtils.listFilesInDirectory(currentGamesystemDir); + gamesystemFiles.forEach(gamesystemFile => { + if(fs.lstatSync(gamesystemFile).isDirectory()) { + const childGamesystems = this.loadGamesystemsRecursivly(gamesystemFile); + loadedGamesystems = loadedGamesystems.concat(childGamesystems); + } else if(path.basename(gamesystemFile).endsWith(".json")) { + const loadedGamesystem = this.loadGamesystem(gamesystemFile); + if(loadedGamesystem != undefined) { + loadedGamesystems.push(loadedGamesystem); + } + } + }) + + return loadedGamesystems; + } + + private loadGamesystem(gamesystemFile: string) { + if(gamesystemFile.endsWith(".json")) { + const gamesystemData = fs.readFileSync(gamesystemFile, 'utf-8'); + return new StoreComponent(gamesystemData, gamesystemFile, ModelComponentType.GAMESYTEM); + } + } +} diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts new file mode 100644 index 0000000..af65bc3 --- /dev/null +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -0,0 +1,60 @@ +import {StoreComponent} from "../../../../../app/storage/StoreComponent"; +import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; +import {ParsedParentGamesystems} from "./ParsedParentGamesystems"; +import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; + +export class GamesystemParser { + + parsedParentGamesystems: ParsedParentGamesystems[] = [] + parsedGamesystems: Gamesystem[] = [] + public parseGamesystem(storedGamesystem: StoreComponent) { + const parsedGamesystemData = JSON.parse(storedGamesystem.jsonString) + let parsedSystem: Gamesystem + if(parsedGamesystemData.childsystems != undefined) { + parsedSystem = this.parseProductGamesystem(parsedGamesystemData) + } else { + parsedSystem = this.parseSimpleGamesystem(parsedGamesystemData) + } + this.parsedGamesystems.push(parsedSystem); + } + + parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem { + const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) + + return simpleGamesystem + } + + parseProductGamesystem(gamesystemData: any) { + const productGamesystem = new ProductGamesystem(gamesystemData.componentName, gamesystemData.componentDescription); + const childsystemNames: string[] = [] + for(let i=0; i[] { + const topGamesystems: Gamesystem[] = [] + this.parsedGamesystems.forEach(parsedGamesystem => { + const searchedParentsystem = this.findParentsystem(parsedGamesystem.componentName) + if(searchedParentsystem != undefined) { + searchedParentsystem.addChildGamesystem(parsedGamesystem) + } else { + topGamesystems.push(parsedGamesystem) + } + }) + return topGamesystems + } + + findParentsystem(childsystemName: string) { + for(let i=0; i { switch (storedComponent.componentType) { case ModelComponentType.SCRIPTACCOUNT: { const scriptAccount = ScriptAccountParser.parseScriptAccount(storedComponent); gameModel.addScriptAccount(scriptAccount); + } break + case ModelComponentType.GAMESYTEM: { + gamesystemParser.parseGamesystem(storedComponent); } } }) + + gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => { + gameModel.addGamesystem(topGamesystem) + }) + + console.log(gameModel) this.gameModel = gameModel; } diff --git a/testModel/gamesystems/ParentTestSystem/Numbers.json b/testModel/gamesystems/ParentTestSystem/Numbers.json deleted file mode 100644 index 546a507..0000000 --- a/testModel/gamesystems/ParentTestSystem/Numbers.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "componentName": "Numbers", - "componentDescription": "", - "states": [ - { - "initial": false, - "conditions": [], - "stateLabel": "1", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Luftfeuchtigkeit", - "minValue": 0, - "maxValue": "5" - } - ], - "stateLabel": "2", - "stateDescription": "" - } - ], - "transitions": [ - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "1", - "endingState": "2" - } - ] -} \ No newline at end of file diff --git a/testModel/gamesystems/ParentTestSystem/ParentTestSystem.json b/testModel/gamesystems/ParentTestSystem/ParentTestSystem.json deleted file mode 100644 index 0572a4c..0000000 --- a/testModel/gamesystems/ParentTestSystem/ParentTestSystem.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "componentName": "ParentTestSystem", - "componentDescription": "" -} \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Weathersystem.json b/testModel/gamesystems/Weathersystem/Weathersystem.json index 4a0733a..47d644a 100644 --- a/testModel/gamesystems/Weathersystem/Weathersystem.json +++ b/testModel/gamesystems/Weathersystem/Weathersystem.json @@ -1,4 +1,12 @@ { "componentName": "Weathersystem", - "componentDescription": "Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt." + "componentDescription": "Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt.", + "childsystems": [ + { + "componentName": "Season" + }, + { + "componentName": "Weather" + } + ] } \ No newline at end of file From ad36913ff9051a2f6c34a6800fa27bef1bbafeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 12:50:47 +0100 Subject: [PATCH 40/58] Project Service had to be deleted as the gamemodel binding would suffer flexibility --- app/storage/loader/GamesystemLoader.js | 41 ++++++++++++++ src/app/app.component.ts | 72 ++++++++++++++----------- src/app/project/project.service.spec.ts | 16 ------ src/app/project/project.service.ts | 57 -------------------- 4 files changed, 83 insertions(+), 103 deletions(-) create mode 100644 app/storage/loader/GamesystemLoader.js delete mode 100644 src/app/project/project.service.spec.ts delete mode 100644 src/app/project/project.service.ts diff --git a/app/storage/loader/GamesystemLoader.js b/app/storage/loader/GamesystemLoader.js new file mode 100644 index 0000000..551404b --- /dev/null +++ b/app/storage/loader/GamesystemLoader.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GamesystemLoader = void 0; +const StoreComponent_1 = require("../StoreComponent"); +const FileUtils_1 = require("../FileUtils"); +const fs = require("fs"); +const path = require("node:path"); +const ModelComponentType_1 = require("../../../src/app/project/game-model/ModelComponentType"); +class GamesystemLoader { + constructor(gamesystemDir) { + this.gamesystemDir = gamesystemDir; + } + loadGamesystems() { + return this.loadGamesystemsRecursivly(this.gamesystemDir); + } + loadGamesystemsRecursivly(currentGamesystemDir) { + let loadedGamesystems = []; + const gamesystemFiles = FileUtils_1.FileUtils.listFilesInDirectory(currentGamesystemDir); + gamesystemFiles.forEach(gamesystemFile => { + if (fs.lstatSync(gamesystemFile).isDirectory()) { + const childGamesystems = this.loadGamesystemsRecursivly(gamesystemFile); + loadedGamesystems = loadedGamesystems.concat(childGamesystems); + } + else if (path.basename(gamesystemFile).endsWith(".json")) { + const loadedGamesystem = this.loadGamesystem(gamesystemFile); + if (loadedGamesystem != undefined) { + loadedGamesystems.push(loadedGamesystem); + } + } + }); + return loadedGamesystems; + } + loadGamesystem(gamesystemFile) { + if (gamesystemFile.endsWith(".json")) { + const gamesystemData = fs.readFileSync(gamesystemFile, 'utf-8'); + return new StoreComponent_1.StoreComponent(gamesystemData, gamesystemFile, ModelComponentType_1.ModelComponentType.GAMESYTEM); + } + } +} +exports.GamesystemLoader = GamesystemLoader; +//# sourceMappingURL=GamesystemLoader.js.map \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c3a6b1a..6df23df 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import {Component, NgZone, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import {MatDrawerContainer} from "@angular/material/sidenav"; import {EditorComponent} from "./editor/editor.component"; import { @@ -7,14 +7,16 @@ import { import {MatDialog} from "@angular/material/dialog"; import {DeleteConfirmationDialogComponent} from "./delete-confirmation-dialog/delete-confirmation-dialog.component"; import {GamescriptOverviewComponent} from "./side-overviews/gamescript-overview/gamescript-overview.component"; - -import {ProjectService} from "./project/project.service"; import {ModelComponentType} from "./project/game-model/ModelComponentType"; import {ModelComponentTypeUtillities} from "./project/game-model/ModelComponentTypeUtillities"; import {ScriptAccount} from "./project/game-model/scriptAccounts/ScriptAccount"; import {Gamesystem} from "./project/game-model/gamesystems/Gamesystem"; import {ModelComponent} from "./project/game-model/ModelComponent"; import {GameModel} from "./project/game-model/GameModel"; +import {StoredGameModel} from "../../app/storage/StoredGameModel"; +import {GamesystemParser} from "./project/parser/gamesystemParser/GamesystemParser"; +import {ScriptAccountParser} from "./project/parser/ScriptAccountParser"; +import {ElectronService} from "./core/services"; @Component({ selector: 'app-root', @@ -31,9 +33,8 @@ export class AppComponent implements OnInit{ gameModel: GameModel | undefined - constructor(private zone: NgZone, - private dialog: MatDialog, - private projectService: ProjectService + constructor(private electronService: ElectronService, + private dialog: MatDialog ) { } @@ -63,7 +64,7 @@ export class AppComponent implements OnInit{ } break; case ModelComponentType.GAMESYTEM: { if(this.gamesystemOverview!.selectedGamesystem != undefined) { - const gamesystem = this.projectService!.gameModel!.findGamesystem(this.gamesystemOverview!.selectedGamesystemName!); + const gamesystem = this.gameModel!.findGamesystem(this.gamesystemOverview!.selectedGamesystemName!); this.editor!.openGameModelComponent(gamesystem!); } } break @@ -78,7 +79,7 @@ export class AppComponent implements OnInit{ dialogRef.afterClosed().subscribe(res => { if(res != undefined && res) { if(affectedModelComponent instanceof ScriptAccount) { - this.projectService!.gameModel!.removeScriptAccount(affectedModelComponent); + this.gameModel!.removeScriptAccount(affectedModelComponent); //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT)) } else if(affectedModelComponent instanceof Gamesystem) { //this.gameModel!.removeGamesystem(affectedModelComponent); @@ -97,7 +98,7 @@ export class AppComponent implements OnInit{ } private onCreateNewScriptAccount() { - const createdScriptAccount = this.projectService!.gameModel!.createScriptAccount("New ScriptAccount"); + const createdScriptAccount = this.gameModel!.createScriptAccount("New ScriptAccount"); if(createdScriptAccount != undefined) { this.editor?.openGameModelComponent(createdScriptAccount); } else { @@ -114,7 +115,7 @@ export class AppComponent implements OnInit{ } - const createdGamesystem = this.projectService!.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName); + const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName); if(createdGamesystem != undefined) { this.gamesystemOverview!.refresh(); this.editor?.openGameModelComponent(createdGamesystem); @@ -124,13 +125,13 @@ export class AppComponent implements OnInit{ private getSelectedModelComponent(): ModelComponent | undefined { if(this.openContent == ModelComponentType.SCRIPTACCOUNT) { if(this.scriptAccountOverview != undefined) { - return this.scriptAccountOverview!.selectedScriptAccount; + return this.scriptAccountOverview.selectedScriptAccount; } else { console.log("[WARN] [App.component] ScriptAccountOverview is undefined") } } else if(this.openContent == ModelComponentType.GAMESYTEM){ if(this.gamesystemOverview != undefined) { - return this.gamesystemOverview!.getSelectedGamesystem() + return this.gamesystemOverview.getSelectedGamesystem() } else { console.log("[WARN] [App.component] GamesystemOverview is undefined") } @@ -139,30 +140,41 @@ export class AppComponent implements OnInit{ } ngOnInit() { - this.gameModel = this.projectService.gameModel - /*this.gameModel = new GameModel("No More"); - this.gameModel.createScriptAccount("Temperature"); - this.gameModel.createScriptAccount("Luftfeuchtigkeit"); + if(this.electronService.isElectron) { + this.electronService.ipcRenderer.on('get-project-data', () => { + this.onSaveProject(); + }) - const weather = new SimpleGamesystem("Weather"); - const season = new SimpleGamesystem("Season"); + this.electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => { + this.onLoadProject(loadedProject); + }) + } + } - const springState = season.createState("Spring", "Spring, also known as springtime, is one of the four temperate seasons, succeeding winter and preceding summer."); - const summerState = season.createState("Summer", "Summer is the hottest and brightest of the four temperate seasons, occurring after spring and before autumn. "); + onLoadProject(storedGameModel: StoredGameModel) { + const gameModel = new GameModel(storedGameModel.gameModelName) + const gamesystemParser = new GamesystemParser(); + storedGameModel.loadedModels.forEach(storedComponent => { + switch (storedComponent.componentType) { + case ModelComponentType.SCRIPTACCOUNT: { + const scriptAccount = ScriptAccountParser.parseScriptAccount(storedComponent); + gameModel.addScriptAccount(scriptAccount); + } break + case ModelComponentType.GAMESYTEM: { + gamesystemParser.parseGamesystem(storedComponent); + } + } + }) - const sunnyState = weather.createState("Sunny", "The sun is shining. No clouds, no rain, no storm."); - const rainingState = weather.createState("Raining", "It rains") + gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => { + gameModel.addGamesystem(topGamesystem) + }) - season.createTransition(springState!, summerState!); - weather.createTransition(sunnyState!, rainingState!); + this.gameModel = gameModel; + } - const weather_season = new ProductGamesystem("Weather-Season"); - weather_season.addChildGamesystem(weather); - weather_season.addChildGamesystem(season); + onSaveProject() { - weather_season.createState([springState!, sunnyState!]); - - this.gameModel.addGamesystem(weather_season);*/ } openScriptAccountsOverview() { diff --git a/src/app/project/project.service.spec.ts b/src/app/project/project.service.spec.ts deleted file mode 100644 index c70ac34..0000000 --- a/src/app/project/project.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { ProjectService } from './project.service'; - -describe('ProjectService', () => { - let service: ProjectService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(ProjectService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/src/app/project/project.service.ts b/src/app/project/project.service.ts deleted file mode 100644 index ccc25cf..0000000 --- a/src/app/project/project.service.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Injectable } from '@angular/core'; -import {ElectronService} from "../core/services"; -import {GameModel} from "./game-model/GameModel"; -import {StoredGameModel} from "../../../app/storage/StoredGameModel"; -import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "./game-model/ModelComponentType"; -import {ScriptAccountParser} from "./parser/ScriptAccountParser"; -import {GamesystemParser} from "./parser/gamesystemParser/GamesystemParser"; -import {Gamesystem} from "./game-model/gamesystems/Gamesystem"; - -@Injectable({ - providedIn: 'root' -}) -export class ProjectService { - - gameModel: GameModel = new GameModel("New GameModel") - constructor(private electronService: ElectronService) { - if(electronService.isElectron) { - electronService.ipcRenderer.on('get-project-data', (event: any, message: string) => { - this.saveProject(); - }) - - electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => { - this.loadProject(loadedProject); - }) - } - } - - saveProject() { - - } - - loadProject(storedGameModel: StoredGameModel) { - const gameModel = new GameModel(storedGameModel.gameModelName) - const gamesystemParser = new GamesystemParser(); - storedGameModel.loadedModels.forEach(storedComponent => { - switch (storedComponent.componentType) { - case ModelComponentType.SCRIPTACCOUNT: { - const scriptAccount = ScriptAccountParser.parseScriptAccount(storedComponent); - gameModel.addScriptAccount(scriptAccount); - } break - case ModelComponentType.GAMESYTEM: { - gamesystemParser.parseGamesystem(storedComponent); - } - } - }) - - gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => { - gameModel.addGamesystem(topGamesystem) - }) - - console.log(gameModel) - this.gameModel = gameModel; - } - - -} From d62a5109393c1e213d6631e3e91c17a533c4e183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 13:07:31 +0100 Subject: [PATCH 41/58] Disable linter and Parse States (without conditions) --- .eslintrc.json | 3 +- src/app/app.component.ts | 10 +++--- .../gamesystemParser/GamesystemParser.ts | 13 ++++++- .../parser/gamesystemParser/StateParser.ts | 34 +++++++++++++++++++ 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 src/app/project/parser/gamesystemParser/StateParser.ts diff --git a/.eslintrc.json b/.eslintrc.json index 011e046..84baaef 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,8 @@ "ignorePatterns": [ "app/**/*", // ignore nodeJs files "dist/**/*", - "release/**/*" + "release/**/*", + "src/**/*" ], "overrides": [ { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6df23df..71c5078 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -153,7 +153,9 @@ export class AppComponent implements OnInit{ onLoadProject(storedGameModel: StoredGameModel) { const gameModel = new GameModel(storedGameModel.gameModelName) - const gamesystemParser = new GamesystemParser(); + + + //const gamesystemParser = new GamesystemParser(); storedGameModel.loadedModels.forEach(storedComponent => { switch (storedComponent.componentType) { case ModelComponentType.SCRIPTACCOUNT: { @@ -161,14 +163,14 @@ export class AppComponent implements OnInit{ gameModel.addScriptAccount(scriptAccount); } break case ModelComponentType.GAMESYTEM: { - gamesystemParser.parseGamesystem(storedComponent); + //gamesystemParser.parseGamesystem(storedComponent); } } }) - gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => { + /*gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => { gameModel.addGamesystem(topGamesystem) - }) + })*/ this.gameModel = gameModel; } diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index af65bc3..50771d6 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -3,11 +3,21 @@ import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; import {ParsedParentGamesystems} from "./ParsedParentGamesystems"; import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; +import {StateParser} from "./StateParser"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; export class GamesystemParser { parsedParentGamesystems: ParsedParentGamesystems[] = [] parsedGamesystems: Gamesystem[] = [] + + private stateParser: StateParser + + + constructor(scriptAccounts: ScriptAccount[]) { + this.stateParser = new StateParser(scriptAccounts) + } + public parseGamesystem(storedGamesystem: StoreComponent) { const parsedGamesystemData = JSON.parse(storedGamesystem.jsonString) let parsedSystem: Gamesystem @@ -21,7 +31,8 @@ export class GamesystemParser { parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem { const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) - + const states = this.stateParser.parseStates(gamesystemData) + simpleGamesystem.states = states return simpleGamesystem } diff --git a/src/app/project/parser/gamesystemParser/StateParser.ts b/src/app/project/parser/gamesystemParser/StateParser.ts new file mode 100644 index 0000000..e91aac0 --- /dev/null +++ b/src/app/project/parser/gamesystemParser/StateParser.ts @@ -0,0 +1,34 @@ +import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition"; + +export class StateParser { + + private scriptAccounts: ScriptAccount[] + + + constructor(scriptAccounts: ScriptAccount[]) { + this.scriptAccounts = scriptAccounts; + } + + public parseStates(gamesystemData: any): SimpleState[] { + const parsedStates: SimpleState[] = [] + for(let i=0; i Date: Wed, 20 Mar 2024 15:15:08 +0100 Subject: [PATCH 42/58] Parse ScriptAccountConditions --- app/storage/StoredGameModel.js | 5 ++- app/storage/StoredGameModel.ts | 9 +++-- app/storage/loader/GameModelLoader.js | 10 ++--- app/storage/loader/GameModelLoader.ts | 10 ++--- src/app/app.component.ts | 20 +++------- src/app/project/game-model/GameModel.ts | 20 +++------- src/app/project/parser/ScriptAccountParser.ts | 10 ++++- .../gamesystemParser/GamesystemParser.ts | 14 ++++++- .../ScriptAccountConditionParser.ts | 39 +++++++++++++++++++ .../parser/gamesystemParser/StateParser.ts | 9 ++++- testModel/script-accounts/Temperature.json | 6 +++ 11 files changed, 98 insertions(+), 54 deletions(-) create mode 100644 src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts create mode 100644 testModel/script-accounts/Temperature.json diff --git a/app/storage/StoredGameModel.js b/app/storage/StoredGameModel.js index 076e1a0..126a61b 100644 --- a/app/storage/StoredGameModel.js +++ b/app/storage/StoredGameModel.js @@ -2,9 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.StoredGameModel = void 0; class StoredGameModel { - constructor(gameModelName, loadedModels) { + constructor(gameModelName, storedScriptAccounts, storedGamesystems) { this.gameModelName = gameModelName; - this.loadedModels = loadedModels; + this.storedGamesystems = storedGamesystems; + this.storedScriptAccounts = storedScriptAccounts; } } exports.StoredGameModel = StoredGameModel; diff --git a/app/storage/StoredGameModel.ts b/app/storage/StoredGameModel.ts index 8104b44..8edfee0 100644 --- a/app/storage/StoredGameModel.ts +++ b/app/storage/StoredGameModel.ts @@ -2,11 +2,14 @@ import {StoreComponent} from "./StoreComponent"; export class StoredGameModel { gameModelName: string - loadedModels: StoreComponent[] + + storedGamesystems: StoreComponent[] + storedScriptAccounts: StoreComponent[] - constructor(gameModelName: string, loadedModels: StoreComponent[]) { + constructor(gameModelName: string, storedScriptAccounts: StoreComponent[], storedGamesystems: StoreComponent[]) { this.gameModelName = gameModelName; - this.loadedModels = loadedModels; + this.storedGamesystems = storedGamesystems; + this.storedScriptAccounts = storedScriptAccounts; } } diff --git a/app/storage/loader/GameModelLoader.js b/app/storage/loader/GameModelLoader.js index a705ac9..7139cc9 100644 --- a/app/storage/loader/GameModelLoader.js +++ b/app/storage/loader/GameModelLoader.js @@ -12,13 +12,9 @@ class GameModelLoader { } loadGameModel() { const gameModelName = path.basename(this.gameModelDir); - const gameModelComponents = this.loadGameModelComponents(); - return new StoredGameModel_1.StoredGameModel(gameModelName, gameModelComponents); - } - loadGameModelComponents() { - let gameModelComponents = this.loadScriptAccountComponents(); - gameModelComponents = gameModelComponents.concat(this.loadGamesystems()); - return gameModelComponents; + const storedScriptAccounts = this.loadScriptAccountComponents(); + const storedGamesystems = this.loadGamesystems(); + return new StoredGameModel_1.StoredGameModel(gameModelName, storedScriptAccounts, storedGamesystems); } loadScriptAccountComponents() { const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME); diff --git a/app/storage/loader/GameModelLoader.ts b/app/storage/loader/GameModelLoader.ts index d9edfb3..bcbfa63 100644 --- a/app/storage/loader/GameModelLoader.ts +++ b/app/storage/loader/GameModelLoader.ts @@ -16,15 +16,11 @@ export class GameModelLoader { loadGameModel(): StoredGameModel { const gameModelName = path.basename(this.gameModelDir) - const gameModelComponents: StoreComponent[] = this.loadGameModelComponents(); - return new StoredGameModel(gameModelName, gameModelComponents); - } + const storedScriptAccounts = this.loadScriptAccountComponents(); + const storedGamesystems = this.loadGamesystems(); - private loadGameModelComponents(): StoreComponent[] { - let gameModelComponents: StoreComponent[] = this.loadScriptAccountComponents() - gameModelComponents = gameModelComponents.concat(this.loadGamesystems()) - return gameModelComponents + return new StoredGameModel(gameModelName, storedScriptAccounts, storedGamesystems); } private loadScriptAccountComponents() { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 71c5078..9a41423 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -154,23 +154,13 @@ export class AppComponent implements OnInit{ onLoadProject(storedGameModel: StoredGameModel) { const gameModel = new GameModel(storedGameModel.gameModelName) + const scriptAccounts = ScriptAccountParser.parseScriptAccounts(storedGameModel.storedScriptAccounts); - //const gamesystemParser = new GamesystemParser(); - storedGameModel.loadedModels.forEach(storedComponent => { - switch (storedComponent.componentType) { - case ModelComponentType.SCRIPTACCOUNT: { - const scriptAccount = ScriptAccountParser.parseScriptAccount(storedComponent); - gameModel.addScriptAccount(scriptAccount); - } break - case ModelComponentType.GAMESYTEM: { - //gamesystemParser.parseGamesystem(storedComponent); - } - } - }) + const gamesystemParser = new GamesystemParser(scriptAccounts); + const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems); - /*gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => { - gameModel.addGamesystem(topGamesystem) - })*/ + gameModel.scriptAccounts = scriptAccounts + gameModel.gamesystems = gamesystems this.gameModel = gameModel; } diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index ec53871..6a7b5d5 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -9,35 +9,25 @@ import {StorageModel} from "./fs/StorageModel"; export class GameModel { private readonly _gameModelName: string - private _gamesystems: Gamesystem[] = []; - private _scriptAccounts: ScriptAccount[] = []; + gamesystems: Gamesystem[] = []; + scriptAccounts: ScriptAccount[] = []; constructor(gameModelName: string) { this._gameModelName = gameModelName; } - get gameModelName(): string { - return this._gameModelName; - } - get gamesystems(): Gamesystem[] { - return this._gamesystems; - } - get scriptAccounts(): ScriptAccount[] { - return this._scriptAccounts; - } addGamesystem(gamesystem: Gamesystem) { if(this.findGamesystem(gamesystem.componentName) == undefined) { - this._gamesystems.push(gamesystem); + this.gamesystems.push(gamesystem); } } removeGamesystem(gamesystem : Gamesystem) { if(gamesystem.parentGamesystem == undefined) { - this._gamesystems = this._gamesystems.filter(g => g !== gamesystem); + this.gamesystems = this.gamesystems.filter(g => g !== gamesystem); } else { (gamesystem.parentGamesystem as ProductGamesystem).removeChildGamesystem(gamesystem); - console.log(gamesystem.parentGamesystem) } } @@ -77,7 +67,7 @@ export class GameModel { removeScriptAccount(scriptAccount: ScriptAccount) { if(scriptAccount != undefined) { - this._scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount); + this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount); } } diff --git a/src/app/project/parser/ScriptAccountParser.ts b/src/app/project/parser/ScriptAccountParser.ts index 56a99b7..72538c9 100644 --- a/src/app/project/parser/ScriptAccountParser.ts +++ b/src/app/project/parser/ScriptAccountParser.ts @@ -3,7 +3,15 @@ import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount"; export class ScriptAccountParser { - public static parseScriptAccount(storedComponent: StoreComponent): ScriptAccount { + public static parseScriptAccounts(storedScriptAccounts: StoreComponent[]): ScriptAccount[] { + const scriptAccounts: ScriptAccount[] = [] + storedScriptAccounts.forEach(scriptAccount => { + scriptAccounts.push(this.parseScriptAccount(scriptAccount)) + }) + return scriptAccounts; + } + + private static parseScriptAccount(storedComponent: StoreComponent): ScriptAccount { console.log("Parse ScriptAccount: ", storedComponent.fileName) const parsedScriptAccount = new ScriptAccount("", ""); Object.assign(parsedScriptAccount, JSON.parse(storedComponent.jsonString)); diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index 50771d6..4feab98 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -18,7 +18,16 @@ export class GamesystemParser { this.stateParser = new StateParser(scriptAccounts) } - public parseGamesystem(storedGamesystem: StoreComponent) { + + public parseStoredGamesystems(storedGamesystems: StoreComponent[]): Gamesystem[] { + storedGamesystems.forEach(storedGamesystem => { + this.parseGamesystem(storedGamesystem) + }) + + return this.computeGamesystemStructure(); + } + + private parseGamesystem(storedGamesystem: StoreComponent) { const parsedGamesystemData = JSON.parse(storedGamesystem.jsonString) let parsedSystem: Gamesystem if(parsedGamesystemData.childsystems != undefined) { @@ -47,7 +56,7 @@ export class GamesystemParser { return productGamesystem; } - computeGamesystemStructure(): Gamesystem[] { + private computeGamesystemStructure(): Gamesystem[] { const topGamesystems: Gamesystem[] = [] this.parsedGamesystems.forEach(parsedGamesystem => { const searchedParentsystem = this.findParentsystem(parsedGamesystem.componentName) @@ -68,4 +77,5 @@ export class GamesystemParser { } return undefined } + } diff --git a/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts b/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts new file mode 100644 index 0000000..6a04131 --- /dev/null +++ b/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts @@ -0,0 +1,39 @@ +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {max, min} from "rxjs"; + +export class ScriptAccountConditionParser { + + scriptAccounts: ScriptAccount[] + + + constructor(scriptAccounts: ScriptAccount[]) { + this.scriptAccounts = scriptAccounts; + } + + parseStoredConditions(conditionData: any): ScriptAccountCondition[] { + const conditions: ScriptAccountCondition[] = [] + for(let i=0; i scriptAccount.componentName === scriptAccountName); + } +} diff --git a/src/app/project/parser/gamesystemParser/StateParser.ts b/src/app/project/parser/gamesystemParser/StateParser.ts index e91aac0..aadb6c3 100644 --- a/src/app/project/parser/gamesystemParser/StateParser.ts +++ b/src/app/project/parser/gamesystemParser/StateParser.ts @@ -1,14 +1,15 @@ import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountConditionParser} from "./ScriptAccountConditionParser"; export class StateParser { - private scriptAccounts: ScriptAccount[] + private conditionParser constructor(scriptAccounts: ScriptAccount[]) { - this.scriptAccounts = scriptAccounts; + this.conditionParser = new ScriptAccountConditionParser(scriptAccounts) } public parseStates(gamesystemData: any): SimpleState[] { @@ -25,8 +26,12 @@ export class StateParser { const stateLabel = stateData.stateLabel const stateDescription = stateData.stateDescription + const conditions = this.conditionParser.parseStoredConditions(stateData.conditions) + const simpleState = new SimpleState(stateLabel, stateDescription); simpleState.initial = initial; + simpleState.conditions = conditions; + return simpleState; } diff --git a/testModel/script-accounts/Temperature.json b/testModel/script-accounts/Temperature.json new file mode 100644 index 0000000..db4d1c8 --- /dev/null +++ b/testModel/script-accounts/Temperature.json @@ -0,0 +1,6 @@ +{ + "componentName": "Temperature", + "componentDescription": "", + "minValue": -50, + "maxValue": 50 +} \ No newline at end of file From 4f4122fd6dd66464840333d992c8106bcf70bf60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 15:33:34 +0100 Subject: [PATCH 43/58] Parse Transitions (& TransitionConditions) --- .../gamesystemParser/GamesystemParser.ts | 17 ++++--- .../ScriptAccountConditionParser.ts | 6 +-- .../parser/gamesystemParser/StateParser.ts | 6 +-- .../gamesystemParser/TransitionParser.ts | 46 +++++++++++++++++++ 4 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 src/app/project/parser/gamesystemParser/TransitionParser.ts diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index 4feab98..afb076f 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -5,17 +5,18 @@ import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem" import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; import {StateParser} from "./StateParser"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {TransitionParser} from "./TransitionParser"; export class GamesystemParser { - parsedParentGamesystems: ParsedParentGamesystems[] = [] - parsedGamesystems: Gamesystem[] = [] + private parsedParentGamesystems: ParsedParentGamesystems[] = [] + private parsedGamesystems: Gamesystem[] = [] - private stateParser: StateParser + private scriptAccounts: ScriptAccount[] constructor(scriptAccounts: ScriptAccount[]) { - this.stateParser = new StateParser(scriptAccounts) + this.scriptAccounts = scriptAccounts; } @@ -40,8 +41,12 @@ export class GamesystemParser { parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem { const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) - const states = this.stateParser.parseStates(gamesystemData) - simpleGamesystem.states = states + + const stateParser = new StateParser(this.scriptAccounts); + simpleGamesystem.states = stateParser.parseStates(gamesystemData.states) + + const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) + simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions) return simpleGamesystem } diff --git a/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts b/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts index 6a04131..7d7198c 100644 --- a/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts +++ b/src/app/project/parser/gamesystemParser/ScriptAccountConditionParser.ts @@ -4,7 +4,7 @@ import {max, min} from "rxjs"; export class ScriptAccountConditionParser { - scriptAccounts: ScriptAccount[] + private scriptAccounts: ScriptAccount[] constructor(scriptAccounts: ScriptAccount[]) { @@ -22,7 +22,7 @@ export class ScriptAccountConditionParser { return conditions } - parseSingleCondition(conditionData: any): ScriptAccountCondition | undefined{ + private parseSingleCondition(conditionData: any): ScriptAccountCondition | undefined{ const referencedScriptAccount = this.findScriptAccountByName(conditionData.scriptAccount); if(referencedScriptAccount != undefined) { const minValue = conditionData.minValue; @@ -33,7 +33,7 @@ export class ScriptAccountConditionParser { } } - findScriptAccountByName(scriptAccountName: string) { + private findScriptAccountByName(scriptAccountName: string) { return this.scriptAccounts.find(scriptAccount => scriptAccount.componentName === scriptAccountName); } } diff --git a/src/app/project/parser/gamesystemParser/StateParser.ts b/src/app/project/parser/gamesystemParser/StateParser.ts index aadb6c3..8da602a 100644 --- a/src/app/project/parser/gamesystemParser/StateParser.ts +++ b/src/app/project/parser/gamesystemParser/StateParser.ts @@ -12,10 +12,10 @@ export class StateParser { this.conditionParser = new ScriptAccountConditionParser(scriptAccounts) } - public parseStates(gamesystemData: any): SimpleState[] { + public parseStates(stateData: any): SimpleState[] { const parsedStates: SimpleState[] = [] - for(let i=0; i state.stateLabel === stateLabel); + } +} From 751d9986252fe3cc4e05e0a75c038c8d79cc4221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 16:23:37 +0100 Subject: [PATCH 44/58] Save ScriptAccount --- app/main.ts | 16 ++++++--- app/storage/storing/ScriptAccountStoring.js | 33 +++++++++++++++++ app/storage/storing/ScriptAccountStoring.ts | 36 +++++++++++++++++++ src/app/app.component.html | 2 +- src/app/app.component.ts | 10 ++++++ src/app/project/game-model/GameModel.ts | 4 +-- .../serializer/ScriptAccountSerializer.ts | 25 +++++++++++++ .../project/serializer/SerializeConstants.ts | 3 ++ testModel/script-accounts/Temperature.json | 2 +- 9 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 app/storage/storing/ScriptAccountStoring.js create mode 100644 app/storage/storing/ScriptAccountStoring.ts create mode 100644 src/app/project/serializer/ScriptAccountSerializer.ts create mode 100644 src/app/project/serializer/SerializeConstants.ts diff --git a/app/main.ts b/app/main.ts index 71b92c3..1264ef5 100644 --- a/app/main.ts +++ b/app/main.ts @@ -2,6 +2,9 @@ import {app, BrowserWindow, dialog, globalShortcut, ipcMain, Menu, screen} from import * as path from 'path'; import * as fs from 'fs'; import {GameModelLoader} from "./storage/loader/GameModelLoader"; +import {StoredGameModel} from "./storage/StoredGameModel"; +import {ScriptAccountStorage} from "./storage/storing/ScriptAccountStoring"; +import {ModelComponentFileDirectory} from "./storage/ModelComponentFileDirectory"; let win: BrowserWindow | null = null; const args = process.argv.slice(1), @@ -92,10 +95,9 @@ function createWindow(): BrowserWindow { contextMenu.popup({ window: win!, x: params.x, y: params.y }); }) - /*ipcMain.on('save-model', (event, storageModels: StorageModel[]) => { - console.log("Save Model") - SaveProject.saveProject(projectDirectory, storageModels); - })*/ + ipcMain.on('save-model', (event, storedGameModel: StoredGameModel) => { + recieveGameModelToStore(storedGameModel) + }) /*ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => { console.log("Delete Model: ", deletedComponent) @@ -129,7 +131,6 @@ function createWindow(): BrowserWindow { ] const menu = Menu.buildFromTemplate(menuTemplate); Menu.setApplicationMenu(menu) - loadDevProjectAtStart() win.webContents.on('did-finish-load', () => { loadDevProjectAtStart() @@ -211,6 +212,11 @@ function saveProject() { win!.webContents.send('get-project-data') } +function recieveGameModelToStore(gameModel: StoredGameModel) { + const scriptAccountStorage = new ScriptAccountStorage(path.join(projectDirectory, ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME)) + scriptAccountStorage.storeScriptAccounts(gameModel.storedScriptAccounts) +} + /*function deleteComponent(component: DeleteModel) { console.log("Delete Component") if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) { diff --git a/app/storage/storing/ScriptAccountStoring.js b/app/storage/storing/ScriptAccountStoring.js new file mode 100644 index 0000000..49b0eab --- /dev/null +++ b/app/storage/storing/ScriptAccountStoring.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ScriptAccountStorage = void 0; +const FileUtils_1 = require("../FileUtils"); +const path = require("node:path"); +const fs = require("fs"); +class ScriptAccountStorage { + constructor(scriptAccountDir) { + this.scriptAccountDir = scriptAccountDir; + } + storeScriptAccounts(scriptAccounts) { + this.persistDeletedScriptAccounts(scriptAccounts); + scriptAccounts.forEach(scriptAccount => { + this.storeScriptAccount(scriptAccount); + }); + } + persistDeletedScriptAccounts(existingScriptAccount) { + const scriptAccountFiles = FileUtils_1.FileUtils.listFilesInDirectory(this.scriptAccountDir); + scriptAccountFiles.forEach(scriptAccountFile => { + const scriptAccountFileName = path.parse(path.basename(scriptAccountFile)).name; + if (existingScriptAccount.find(scriptAccount => scriptAccount.fileName === scriptAccountFileName) == undefined) { + //No scriptAccountFile was found with that nae of the file. So the scriptAccount was deleted. Remove file + fs.unlinkSync(scriptAccountFile); + } + }); + } + storeScriptAccount(scriptAccount) { + const completeScriptAccountFile = path.join(this.scriptAccountDir, scriptAccount.fileName + ".json"); + fs.writeFileSync(completeScriptAccountFile, scriptAccount.jsonString, 'utf-8'); + } +} +exports.ScriptAccountStorage = ScriptAccountStorage; +//# sourceMappingURL=ScriptAccountStoring.js.map \ No newline at end of file diff --git a/app/storage/storing/ScriptAccountStoring.ts b/app/storage/storing/ScriptAccountStoring.ts new file mode 100644 index 0000000..6e73b17 --- /dev/null +++ b/app/storage/storing/ScriptAccountStoring.ts @@ -0,0 +1,36 @@ +import {StoreComponent} from "../StoreComponent"; +import {FileUtils} from "../FileUtils"; +import * as path from "node:path"; +import * as fs from "fs"; + +export class ScriptAccountStorage { + + private scriptAccountDir: string + + constructor(scriptAccountDir: string) { + this.scriptAccountDir = scriptAccountDir; + } + + storeScriptAccounts(scriptAccounts: StoreComponent[]) { + this.persistDeletedScriptAccounts(scriptAccounts) + scriptAccounts.forEach(scriptAccount => { + this.storeScriptAccount(scriptAccount) + }) + } + + private persistDeletedScriptAccounts(existingScriptAccount: StoreComponent[]) { + const scriptAccountFiles = FileUtils.listFilesInDirectory(this.scriptAccountDir); + scriptAccountFiles.forEach(scriptAccountFile => { + const scriptAccountFileName = path.parse(path.basename(scriptAccountFile)).name + if(existingScriptAccount.find(scriptAccount => scriptAccount.fileName === scriptAccountFileName) == undefined) { + //No scriptAccountFile was found with that nae of the file. So the scriptAccount was deleted. Remove file + fs.unlinkSync(scriptAccountFile) + } + }) + } + + private storeScriptAccount(scriptAccount: StoreComponent) { + const completeScriptAccountFile = path.join(this.scriptAccountDir, scriptAccount.fileName + ".json") + fs.writeFileSync(completeScriptAccountFile, scriptAccount.jsonString, 'utf-8') + } +} diff --git a/src/app/app.component.html b/src/app/app.component.html index e345414..2801b21 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -22,7 +22,7 @@ - + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9a41423..5a07598 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -17,6 +17,8 @@ import {StoredGameModel} from "../../app/storage/StoredGameModel"; import {GamesystemParser} from "./project/parser/gamesystemParser/GamesystemParser"; import {ScriptAccountParser} from "./project/parser/ScriptAccountParser"; import {ElectronService} from "./core/services"; +import {ScriptAccountSerializer} from "./project/serializer/ScriptAccountSerializer"; +import {StoreComponent} from "../../app/storage/StoreComponent"; @Component({ selector: 'app-root', @@ -162,11 +164,19 @@ export class AppComponent implements OnInit{ gameModel.scriptAccounts = scriptAccounts gameModel.gamesystems = gamesystems + console.log(gameModel.scriptAccounts) + this.gameModel = gameModel; } onSaveProject() { + const storedScriptAccounts = ScriptAccountSerializer.serializeScriptAccounts(this.gameModel!.scriptAccounts) + const storedGamesystems: StoreComponent[] = []; + const storeModel = new StoredGameModel(this.gameModel!.gameModelName, storedScriptAccounts, storedGamesystems) + if(this.electronService.isElectron) { + this.electronService.ipcRenderer.send('save-model', storeModel) + } } openScriptAccountsOverview() { diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 6a7b5d5..e1005d9 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -7,13 +7,13 @@ import {SimpleGamesystem} from "./gamesystems/SimpleGamesystem"; import {StorageModel} from "./fs/StorageModel"; export class GameModel { - private readonly _gameModelName: string + gameModelName: string gamesystems: Gamesystem[] = []; scriptAccounts: ScriptAccount[] = []; constructor(gameModelName: string) { - this._gameModelName = gameModelName; + this.gameModelName = gameModelName; } addGamesystem(gamesystem: Gamesystem) { diff --git a/src/app/project/serializer/ScriptAccountSerializer.ts b/src/app/project/serializer/ScriptAccountSerializer.ts new file mode 100644 index 0000000..bdbe960 --- /dev/null +++ b/src/app/project/serializer/ScriptAccountSerializer.ts @@ -0,0 +1,25 @@ +import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount"; +import {StoreComponent} from "../../../../app/storage/StoreComponent"; +import {SerializeConstants} from "./SerializeConstants"; +import {ModelComponentType} from "../game-model/ModelComponentType"; + +export class ScriptAccountSerializer { + + public static serializeScriptAccounts(scriptAccounts: ScriptAccount[]): StoreComponent[] { + const storeComponents: StoreComponent[] = [] + scriptAccounts.forEach(scriptAccount => storeComponents.push(this.serializeSingleScriptAccount(scriptAccount))) + return storeComponents; + } + + private static serializeSingleScriptAccount(scriptAccount: ScriptAccount): StoreComponent { + const fileName = scriptAccount.componentName + const jsonString = JSON.stringify(scriptAccount, (key, value) => { + if(key === 'unsaved' || key === 'type') { + return undefined + } else { + return value; + } + }, SerializeConstants.JSON_INDENT) + return new StoreComponent(jsonString, fileName, ModelComponentType.SCRIPTACCOUNT); + } +} diff --git a/src/app/project/serializer/SerializeConstants.ts b/src/app/project/serializer/SerializeConstants.ts new file mode 100644 index 0000000..cc7e432 --- /dev/null +++ b/src/app/project/serializer/SerializeConstants.ts @@ -0,0 +1,3 @@ +export class SerializeConstants { + public static JSON_INDENT = 4 +} diff --git a/testModel/script-accounts/Temperature.json b/testModel/script-accounts/Temperature.json index db4d1c8..91a3a6c 100644 --- a/testModel/script-accounts/Temperature.json +++ b/testModel/script-accounts/Temperature.json @@ -1,6 +1,6 @@ { "componentName": "Temperature", "componentDescription": "", - "minValue": -50, + "minValue": -30, "maxValue": 50 } \ No newline at end of file From 2a02ec9338c23634ddd41c7eb8f6b725cda9bedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 16:31:17 +0100 Subject: [PATCH 45/58] (Re)Enable context menu interactions --- src/app/app.component.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5a07598..ccbdb4c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -150,6 +150,12 @@ export class AppComponent implements OnInit{ this.electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => { this.onLoadProject(loadedProject); }) + + this.electronService.ipcRenderer.on('context-menu', (event: any, message: string) => { + console.log("Context Menu triggered") + this.onContextMenuMessageRecieved(message); + }) + } } From 09abfcaa893ae2af9e615151d9e77a1934cfbaa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 17:00:44 +0100 Subject: [PATCH 46/58] Fix rendering issues with dialog by using zone to process main process requests --- src/app/app.component.ts | 39 +++++++++++-------- .../delete-confirmation-dialog.component.ts | 12 +++++- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ccbdb4c..27f2b40 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; +import {Component, NgZone, OnInit, ViewChild} from '@angular/core'; import {MatDrawerContainer} from "@angular/material/sidenav"; import {EditorComponent} from "./editor/editor.component"; import { @@ -36,9 +36,30 @@ export class AppComponent implements OnInit{ gameModel: GameModel | undefined constructor(private electronService: ElectronService, - private dialog: MatDialog + private dialog: MatDialog, + private zone: NgZone ) { + if(electronService.isElectron) { + electronService.ipcRenderer.on('context-menu', (event: any, message: string) => { + this.zone.run(() => { + this.onContextMenuMessageRecieved(message); + }); + }) + electronService.ipcRenderer.on('get-project-data', (event: any, message: string) => { + this.zone.run(() => { + this.onSaveProject(); + }) + }) + + electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => { + this.zone.run(() => { + this.onLoadProject(loadedProject) + }) + }) + + + } } onContextMenuMessageRecieved(message: string) { @@ -142,21 +163,7 @@ export class AppComponent implements OnInit{ } ngOnInit() { - if(this.electronService.isElectron) { - this.electronService.ipcRenderer.on('get-project-data', () => { - this.onSaveProject(); - }) - this.electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => { - this.onLoadProject(loadedProject); - }) - - this.electronService.ipcRenderer.on('context-menu', (event: any, message: string) => { - console.log("Context Menu triggered") - this.onContextMenuMessageRecieved(message); - }) - - } } onLoadProject(storedGameModel: StoredGameModel) { diff --git a/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts b/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts index 00c63d2..2f646ea 100644 --- a/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts +++ b/src/app/delete-confirmation-dialog/delete-confirmation-dialog.component.ts @@ -1,6 +1,7 @@ -import {Component, Inject} from '@angular/core'; +import {Component, Inject, OnInit} from '@angular/core'; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {ModelComponent} from "../project/game-model/ModelComponent"; +import {ModelComponentTypeUtillities} from "../project/game-model/ModelComponentTypeUtillities"; @Component({ @@ -8,12 +9,17 @@ import {ModelComponent} from "../project/game-model/ModelComponent"; templateUrl: './delete-confirmation-dialog.component.html', styleUrl: './delete-confirmation-dialog.component.scss' }) -export class DeleteConfirmationDialogComponent { +export class DeleteConfirmationDialogComponent implements OnInit{ constructor(private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) { } + ngOnInit(): void { + console.log("delete Confirmation dialog here") + } + + cancel() { this.dialogRef.close(false); } @@ -21,4 +27,6 @@ export class DeleteConfirmationDialogComponent { confirmDelete() { this.dialogRef.close(true); } + + protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities; } From e6073d4f2f7a2060ddf121ef481e01e55293cf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Wed, 20 Mar 2024 19:35:24 +0100 Subject: [PATCH 47/58] Save Gamesystems --- app/storage/FileUtils.js | 7 ++ app/storage/FileUtils.ts | 9 ++ app/storage/storing/GamesystemStorage.js | 45 ++++++++ app/storage/storing/GamesystemStorage.ts | 47 ++++++++ src/app/app.component.ts | 15 ++- .../gamesystemParser/GamesystemParser.ts | 1 + .../serializer/GamesystemSerializer.ts | 107 ++++++++++++++++++ .../script-accounts/New ScriptAccount.json | 6 + 8 files changed, 231 insertions(+), 6 deletions(-) create mode 100644 app/storage/storing/GamesystemStorage.js create mode 100644 app/storage/storing/GamesystemStorage.ts create mode 100644 src/app/project/serializer/GamesystemSerializer.ts create mode 100644 testModel/script-accounts/New ScriptAccount.json diff --git a/app/storage/FileUtils.js b/app/storage/FileUtils.js index 6a966ba..a13984e 100644 --- a/app/storage/FileUtils.js +++ b/app/storage/FileUtils.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.FileUtils = void 0; const fs = require("fs"); const path = require("node:path"); +const fs_1 = require("fs"); class FileUtils { static listFilesInDirectory(directory) { if (fs.lstatSync(directory).isDirectory()) { @@ -12,6 +13,12 @@ class FileUtils { return []; } } + static prepareFileForWriting(file) { + const parentDirectory = path.dirname(file); + if (!fs.existsSync(parentDirectory)) { + (0, fs_1.mkdirSync)(parentDirectory, { recursive: true }); + } + } } exports.FileUtils = FileUtils; //# sourceMappingURL=FileUtils.js.map \ No newline at end of file diff --git a/app/storage/FileUtils.ts b/app/storage/FileUtils.ts index 3d267fb..decb4fc 100644 --- a/app/storage/FileUtils.ts +++ b/app/storage/FileUtils.ts @@ -1,5 +1,6 @@ import * as fs from "fs"; import * as path from "node:path"; +import {mkdirSync} from "fs"; export class FileUtils { @@ -10,4 +11,12 @@ export class FileUtils { return []; } } + + public static prepareFileForWriting(file: string) { + const parentDirectory = path.dirname(file) + + if(!fs.existsSync(parentDirectory)) { + mkdirSync(parentDirectory, {recursive: true}) + } + } } diff --git a/app/storage/storing/GamesystemStorage.js b/app/storage/storing/GamesystemStorage.js new file mode 100644 index 0000000..a75c04c --- /dev/null +++ b/app/storage/storing/GamesystemStorage.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GamesystemStorage = void 0; +const FileUtils_1 = require("../FileUtils"); +const path = require("node:path"); +const fs = require("fs"); +class GamesystemStorage { + constructor(gamesystemRootDir) { + this.gamesystemRootDir = gamesystemRootDir; + } + storeGamesystems(gamesystems) { + this.detectUnusedGamesystemFiles(this.gamesystemRootDir, gamesystems); + gamesystems.forEach(gamesystem => this.storeGamesystem(gamesystem)); + } + detectUnusedGamesystemFiles(gamesystemDir, gamesystems) { + const gamesystemFiles = FileUtils_1.FileUtils.listFilesInDirectory(gamesystemDir); + gamesystemFiles.forEach(gamesystemFile => { + if (fs.lstatSync(gamesystemFile).isDirectory()) { + this.detectUnusedGamesystemFiles(gamesystemFile, gamesystems); + } + else { + const currentFileName = path.parse(path.basename(gamesystemFile)).name; + const searchedGamesystem = gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === currentFileName); + if (searchedGamesystem != undefined) { + if (path.dirname(searchedGamesystem.fileName) === currentFileName) { + //Aus Simple wurde Product => Delete .json + fs.unlinkSync(gamesystemFile); + } + } + else { + fs.unlinkSync(gamesystemFile); + } + } + }); + } + storeGamesystem(gamesystem) { + const gamesystemFile = path.join(...gamesystem.fileName.split("/")); + console.log(gamesystem.jsonString); + const completeGamesystemFile = path.join(this.gamesystemRootDir, gamesystemFile); + FileUtils_1.FileUtils.prepareFileForWriting(completeGamesystemFile); + fs.writeFileSync(completeGamesystemFile + ".json", gamesystem.jsonString, 'utf-8'); + } +} +exports.GamesystemStorage = GamesystemStorage; +//# sourceMappingURL=GamesystemStorage.js.map \ No newline at end of file diff --git a/app/storage/storing/GamesystemStorage.ts b/app/storage/storing/GamesystemStorage.ts new file mode 100644 index 0000000..a25848d --- /dev/null +++ b/app/storage/storing/GamesystemStorage.ts @@ -0,0 +1,47 @@ +import {StoreComponent} from "../StoreComponent"; +import {FileUtils} from "../FileUtils"; +import * as path from "node:path"; +import * as fs from "fs"; + +export class GamesystemStorage { + + private gamesystemRootDir: string + + + constructor(gamesystemRootDir: string) { + this.gamesystemRootDir = gamesystemRootDir; + } + + public storeGamesystems(gamesystems: StoreComponent[]) { + this.detectUnusedGamesystemFiles(this.gamesystemRootDir, gamesystems) + gamesystems.forEach(gamesystem => this.storeGamesystem(gamesystem)) + } + + private detectUnusedGamesystemFiles(gamesystemDir: string, gamesystems: StoreComponent[]) { + const gamesystemFiles = FileUtils.listFilesInDirectory(gamesystemDir); + gamesystemFiles.forEach(gamesystemFile => { + if(fs.lstatSync(gamesystemFile).isDirectory()) { + this.detectUnusedGamesystemFiles(gamesystemFile, gamesystems) + } else { + const currentFileName = path.parse(path.basename(gamesystemFile)).name + const searchedGamesystem = gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === currentFileName); + if(searchedGamesystem != undefined) { + if(path.dirname(searchedGamesystem.fileName) === currentFileName) { + //Aus Simple wurde Product => Delete .json + fs.unlinkSync(gamesystemFile) + } + } else { + fs.unlinkSync(gamesystemFile) + } + } + }) + } + + private storeGamesystem(gamesystem: StoreComponent) { + const gamesystemFile = path.join(... gamesystem.fileName.split("/")) + console.log(gamesystem.jsonString) + const completeGamesystemFile = path.join(this.gamesystemRootDir, gamesystemFile) + FileUtils.prepareFileForWriting(completeGamesystemFile) + fs.writeFileSync(completeGamesystemFile + ".json", gamesystem.jsonString, 'utf-8') + } +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 27f2b40..36d1fd0 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -19,6 +19,7 @@ import {ScriptAccountParser} from "./project/parser/ScriptAccountParser"; import {ElectronService} from "./core/services"; import {ScriptAccountSerializer} from "./project/serializer/ScriptAccountSerializer"; import {StoreComponent} from "../../app/storage/StoreComponent"; +import {GamesystemSerializer} from "./project/serializer/GamesystemSerializer"; @Component({ selector: 'app-root', @@ -183,13 +184,15 @@ export class AppComponent implements OnInit{ } onSaveProject() { - const storedScriptAccounts = ScriptAccountSerializer.serializeScriptAccounts(this.gameModel!.scriptAccounts) - const storedGamesystems: StoreComponent[] = []; - const storeModel = new StoredGameModel(this.gameModel!.gameModelName, storedScriptAccounts, storedGamesystems) + if(this.gameModel != undefined) { + const storedScriptAccounts = ScriptAccountSerializer.serializeScriptAccounts(this.gameModel.scriptAccounts) + const storedGamesystems: StoreComponent[] = GamesystemSerializer.serializeGamesystems(this.gameModel.gamesystems) + const storeModel = new StoredGameModel(this.gameModel.gameModelName, storedScriptAccounts, storedGamesystems) - if(this.electronService.isElectron) { - this.electronService.ipcRenderer.send('save-model', storeModel) - } + if(this.electronService.isElectron) { + this.electronService.ipcRenderer.send('save-model', storeModel) + } + } } openScriptAccountsOverview() { diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index afb076f..e085bba 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -67,6 +67,7 @@ export class GamesystemParser { const searchedParentsystem = this.findParentsystem(parsedGamesystem.componentName) if(searchedParentsystem != undefined) { searchedParentsystem.addChildGamesystem(parsedGamesystem) + parsedGamesystem.parentGamesystem = searchedParentsystem } else { topGamesystems.push(parsedGamesystem) } diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts new file mode 100644 index 0000000..3088fe6 --- /dev/null +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -0,0 +1,107 @@ +import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; +import {StoreComponent} from "../../../../app/storage/StoreComponent"; +import {SimpleGamesystem} from "../game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../game-model/gamesystems/ProductGamesystem"; +import {SerializeConstants} from "./SerializeConstants"; +import {ModelComponentType} from "../game-model/ModelComponentType"; + +export class GamesystemSerializer { + + private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type"] + + public static serializeGamesystems(gamesystems: Gamesystem[]): StoreComponent[] { + let storedGamesystems: StoreComponent[] = [] + gamesystems.forEach(gamesystem => storedGamesystems = storedGamesystems.concat(this.serializeSingleGamesystem(gamesystem))) + return storedGamesystems + } + + private static serializeSingleGamesystem(gamesystem: Gamesystem): StoreComponent[] { + if(gamesystem instanceof SimpleGamesystem) { + console.log("Simple Gamesystem") + return [this.serializeSimpleGamesystem(gamesystem as SimpleGamesystem)] + } else { + return this.serializeProductGamesystem(gamesystem as ProductGamesystem) + } + } + + private static serializeSimpleGamesystem(simpleGamesystem: SimpleGamesystem): StoreComponent { + const fileName = this.computeSimpleGamesystemPath(simpleGamesystem); + const jsonString = JSON.stringify(simpleGamesystem, (key, value) => { + + if(this.IGNORED_SIMPLE_ATTRIBUTES.includes(key)) { + return undefined + } else if(key === 'startingState' || key === 'endingState') { + return value.stateLabel + } else if(key === 'scriptAccount') { + return value.componentName + } else { + return value; + } + }, SerializeConstants.JSON_INDENT) + + console.log(jsonString) + return new StoreComponent(jsonString, fileName, ModelComponentType.GAMESYTEM) + } + + private static serializeProductGamesystem(productGamesystem: ProductGamesystem): StoreComponent[] { + const storedGamesystems: StoreComponent[] = [] + + const fileName = this.computeProductGamesystemPath(productGamesystem) + const innerGamesystemJsonArray: {'componentName': string}[] = [] + productGamesystem.innerGamesystems.forEach(innerGamesystem => { + innerGamesystemJsonArray.push({ + 'componentName': innerGamesystem.componentName + }) + + const storedChildsystems = this.serializeSingleGamesystem(innerGamesystem); + storedChildsystems.forEach(storedChildsystem => storedGamesystems.push(storedChildsystem)) + }) + + const jsonString = { + 'componentName': productGamesystem.componentName, + 'componentDescription': productGamesystem.componentDescription, + 'childsystems': innerGamesystemJsonArray + } + + const storedProductsystem = new StoreComponent(JSON.stringify(jsonString), fileName, ModelComponentType.GAMESYTEM) + storedGamesystems.push(storedProductsystem) + + return storedGamesystems; + } + + private static computeSimpleGamesystemPath(simpleGamesystem: SimpleGamesystem): string { + if(simpleGamesystem.parentGamesystem == undefined) { + return simpleGamesystem.componentName + } else { + const pathElements: string[] = [simpleGamesystem.componentName] + let currentGamesystem: ProductGamesystem | undefined = simpleGamesystem.parentGamesystem + while(currentGamesystem != undefined) { + pathElements.unshift(currentGamesystem.componentName) + currentGamesystem = currentGamesystem.parentGamesystem + } + let output = "" + for(let i=0; i Date: Thu, 21 Mar 2024 08:43:28 +0100 Subject: [PATCH 48/58] Delete Unreferenced Gamesystems --- app/main.ts | 4 ++ app/storage/FileUtils.js | 10 ++++ app/storage/FileUtils.ts | 11 +++++ app/storage/storing/GamesystemStorage.js | 47 +++++++++++------- app/storage/storing/GamesystemStorage.ts | 49 +++++++++++++------ src/app/app.component.ts | 2 +- .../serializer/GamesystemSerializer.ts | 1 - 7 files changed, 89 insertions(+), 35 deletions(-) diff --git a/app/main.ts b/app/main.ts index 1264ef5..f651a10 100644 --- a/app/main.ts +++ b/app/main.ts @@ -5,6 +5,7 @@ import {GameModelLoader} from "./storage/loader/GameModelLoader"; import {StoredGameModel} from "./storage/StoredGameModel"; import {ScriptAccountStorage} from "./storage/storing/ScriptAccountStoring"; import {ModelComponentFileDirectory} from "./storage/ModelComponentFileDirectory"; +import {GamesystemStorage} from "./storage/storing/GamesystemStorage"; let win: BrowserWindow | null = null; const args = process.argv.slice(1), @@ -215,6 +216,9 @@ function saveProject() { function recieveGameModelToStore(gameModel: StoredGameModel) { const scriptAccountStorage = new ScriptAccountStorage(path.join(projectDirectory, ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME)) scriptAccountStorage.storeScriptAccounts(gameModel.storedScriptAccounts) + + const gamesystemStorage = new GamesystemStorage(path.join(projectDirectory, ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME)) + gamesystemStorage.storeGamesystems(gameModel.storedGamesystems) } /*function deleteComponent(component: DeleteModel) { diff --git a/app/storage/FileUtils.js b/app/storage/FileUtils.js index a13984e..55d504f 100644 --- a/app/storage/FileUtils.js +++ b/app/storage/FileUtils.js @@ -19,6 +19,16 @@ class FileUtils { (0, fs_1.mkdirSync)(parentDirectory, { recursive: true }); } } + static removeFiles(files) { + files.forEach(file => { + if (fs.lstatSync(file).isDirectory()) { + fs.rmdirSync(file); + } + else { + fs.unlinkSync(file); + } + }); + } } exports.FileUtils = FileUtils; //# sourceMappingURL=FileUtils.js.map \ No newline at end of file diff --git a/app/storage/FileUtils.ts b/app/storage/FileUtils.ts index decb4fc..cfab96a 100644 --- a/app/storage/FileUtils.ts +++ b/app/storage/FileUtils.ts @@ -1,6 +1,7 @@ import * as fs from "fs"; import * as path from "node:path"; import {mkdirSync} from "fs"; +import {lstatSync} from "node:fs"; export class FileUtils { @@ -19,4 +20,14 @@ export class FileUtils { mkdirSync(parentDirectory, {recursive: true}) } } + + public static removeFiles(files: string[]) { + files.forEach(file => { + if(fs.lstatSync(file).isDirectory()) { + fs.rmdirSync(file) + } else { + fs.unlinkSync(file); + } + }) + } } diff --git a/app/storage/storing/GamesystemStorage.js b/app/storage/storing/GamesystemStorage.js index a75c04c..fb9ca66 100644 --- a/app/storage/storing/GamesystemStorage.js +++ b/app/storage/storing/GamesystemStorage.js @@ -9,33 +9,46 @@ class GamesystemStorage { this.gamesystemRootDir = gamesystemRootDir; } storeGamesystems(gamesystems) { - this.detectUnusedGamesystemFiles(this.gamesystemRootDir, gamesystems); + const unreferencedFiles = this.detectUnusedGamesystemFiles(gamesystems); + FileUtils_1.FileUtils.removeFiles(unreferencedFiles); gamesystems.forEach(gamesystem => this.storeGamesystem(gamesystem)); } - detectUnusedGamesystemFiles(gamesystemDir, gamesystems) { - const gamesystemFiles = FileUtils_1.FileUtils.listFilesInDirectory(gamesystemDir); - gamesystemFiles.forEach(gamesystemFile => { - if (fs.lstatSync(gamesystemFile).isDirectory()) { - this.detectUnusedGamesystemFiles(gamesystemFile, gamesystems); + detectUnusedGamesystemFiles(gamesystems) { + const unreferencedFiles = []; + const gamesystemFiles = FileUtils_1.FileUtils.listFilesInDirectory(this.gamesystemRootDir); + while (gamesystemFiles.length > 0) { + const currentGamesystemFile = gamesystemFiles.shift(); + const referencedGamesystemName = path.parse(path.basename(currentGamesystemFile)).name; + const referencedGamesystem = this.findReferencedGamesystem(referencedGamesystemName, gamesystems); + if (referencedGamesystem == undefined) { + unreferencedFiles.push(currentGamesystemFile); } else { - const currentFileName = path.parse(path.basename(gamesystemFile)).name; - const searchedGamesystem = gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === currentFileName); - if (searchedGamesystem != undefined) { - if (path.dirname(searchedGamesystem.fileName) === currentFileName) { - //Aus Simple wurde Product => Delete .json - fs.unlinkSync(gamesystemFile); + const decodedJSONData = JSON.parse(referencedGamesystem.jsonString); + if (decodedJSONData.childsystems != undefined) { + //Check if current file is a directory. When it is a directory, everything is fine + if (fs.lstatSync(currentGamesystemFile).isDirectory()) { + } + else { + const parentDirName = path.basename(path.dirname(currentGamesystemFile)); + if (parentDirName !== referencedGamesystemName) { + unreferencedFiles.push(currentGamesystemFile); + } } } - else { - fs.unlinkSync(gamesystemFile); - } } - }); + if (fs.lstatSync(currentGamesystemFile).isDirectory()) { + gamesystemFiles.push(...FileUtils_1.FileUtils.listFilesInDirectory(currentGamesystemFile)); + } + } + return unreferencedFiles; + } + findReferencedGamesystem(referencedName, gamesystems) { + const searchedGamesystem = gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === referencedName); + return searchedGamesystem; } storeGamesystem(gamesystem) { const gamesystemFile = path.join(...gamesystem.fileName.split("/")); - console.log(gamesystem.jsonString); const completeGamesystemFile = path.join(this.gamesystemRootDir, gamesystemFile); FileUtils_1.FileUtils.prepareFileForWriting(completeGamesystemFile); fs.writeFileSync(completeGamesystemFile + ".json", gamesystem.jsonString, 'utf-8'); diff --git a/app/storage/storing/GamesystemStorage.ts b/app/storage/storing/GamesystemStorage.ts index a25848d..c414f65 100644 --- a/app/storage/storing/GamesystemStorage.ts +++ b/app/storage/storing/GamesystemStorage.ts @@ -13,33 +13,50 @@ export class GamesystemStorage { } public storeGamesystems(gamesystems: StoreComponent[]) { - this.detectUnusedGamesystemFiles(this.gamesystemRootDir, gamesystems) + const unreferencedFiles = this.detectUnusedGamesystemFiles(gamesystems) + FileUtils.removeFiles(unreferencedFiles) gamesystems.forEach(gamesystem => this.storeGamesystem(gamesystem)) } - private detectUnusedGamesystemFiles(gamesystemDir: string, gamesystems: StoreComponent[]) { - const gamesystemFiles = FileUtils.listFilesInDirectory(gamesystemDir); - gamesystemFiles.forEach(gamesystemFile => { - if(fs.lstatSync(gamesystemFile).isDirectory()) { - this.detectUnusedGamesystemFiles(gamesystemFile, gamesystems) + private detectUnusedGamesystemFiles(gamesystems: StoreComponent[]) { + const unreferencedFiles: string[] = [] + const gamesystemFiles = FileUtils.listFilesInDirectory(this.gamesystemRootDir); + while(gamesystemFiles.length > 0) { + const currentGamesystemFile = gamesystemFiles.shift() + const referencedGamesystemName = path.parse(path.basename(currentGamesystemFile!)).name + const referencedGamesystem = this.findReferencedGamesystem(referencedGamesystemName, gamesystems) + if(referencedGamesystem == undefined) { + unreferencedFiles.push(currentGamesystemFile!) } else { - const currentFileName = path.parse(path.basename(gamesystemFile)).name - const searchedGamesystem = gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === currentFileName); - if(searchedGamesystem != undefined) { - if(path.dirname(searchedGamesystem.fileName) === currentFileName) { - //Aus Simple wurde Product => Delete .json - fs.unlinkSync(gamesystemFile) + const decodedJSONData = JSON.parse(referencedGamesystem!.jsonString) + if(decodedJSONData.childsystems != undefined) { + //Check if current file is a directory. When it is a directory, everything is fine + if(fs.lstatSync(currentGamesystemFile!).isDirectory()) { + + } else { + const parentDirName = path.basename(path.dirname(currentGamesystemFile!)) + if(parentDirName !== referencedGamesystemName) { + unreferencedFiles.push(currentGamesystemFile!) + } } - } else { - fs.unlinkSync(gamesystemFile) } } - }) + + if(fs.lstatSync(currentGamesystemFile!).isDirectory()) { + gamesystemFiles.push(... FileUtils.listFilesInDirectory(currentGamesystemFile!)) + } + } + + return unreferencedFiles; + } + + private findReferencedGamesystem(referencedName: string, gamesystems: StoreComponent[]): StoreComponent | undefined { + return gamesystems.find(gamesystem => + path.basename(gamesystem.fileName) === referencedName) } private storeGamesystem(gamesystem: StoreComponent) { const gamesystemFile = path.join(... gamesystem.fileName.split("/")) - console.log(gamesystem.jsonString) const completeGamesystemFile = path.join(this.gamesystemRootDir, gamesystemFile) FileUtils.prepareFileForWriting(completeGamesystemFile) fs.writeFileSync(completeGamesystemFile + ".json", gamesystem.jsonString, 'utf-8') diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 36d1fd0..c1f5ec7 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -106,7 +106,7 @@ export class AppComponent implements OnInit{ this.gameModel!.removeScriptAccount(affectedModelComponent); //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT)) } else if(affectedModelComponent instanceof Gamesystem) { - //this.gameModel!.removeGamesystem(affectedModelComponent); + this.gameModel!.removeGamesystem(affectedModelComponent); //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM)) this.gamesystemOverview!.refresh() } diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index 3088fe6..eadb92e 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -39,7 +39,6 @@ export class GamesystemSerializer { } }, SerializeConstants.JSON_INDENT) - console.log(jsonString) return new StoreComponent(jsonString, fileName, ModelComponentType.GAMESYTEM) } From 50963387f046a7679ced7812453606a5d5db2a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 07:43:52 +0100 Subject: [PATCH 49/58] Fix wrong files for newly created ProductGamesystems --- app/storage/storing/GamesystemStorage.js | 3 +-- src/app/project/game-model/GameModel.ts | 1 + src/app/project/game-model/gamesystems/ProductGamesystem.ts | 2 ++ src/app/project/serializer/GamesystemSerializer.ts | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/storage/storing/GamesystemStorage.js b/app/storage/storing/GamesystemStorage.js index fb9ca66..003890e 100644 --- a/app/storage/storing/GamesystemStorage.js +++ b/app/storage/storing/GamesystemStorage.js @@ -44,8 +44,7 @@ class GamesystemStorage { return unreferencedFiles; } findReferencedGamesystem(referencedName, gamesystems) { - const searchedGamesystem = gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === referencedName); - return searchedGamesystem; + return gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === referencedName); } storeGamesystem(gamesystem) { const gamesystemFile = path.join(...gamesystem.fileName.split("/")); diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index e1005d9..7c98dcf 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -52,6 +52,7 @@ export class GameModel { const parentProductGamesystem = ProductGamesystem.constructFromSimpleGamesystem(parentGamesystem, this); parentProductGamesystem.addChildGamesystem(simpleGamesystem); simpleGamesystem.parentGamesystem = parentProductGamesystem; + console.log("The parent of my parent is ", parentProductGamesystem.parentGamesystem!.componentName) } else { const productParentGamesystem = parentGamesystem as ProductGamesystem; productParentGamesystem.addChildGamesystem(simpleGamesystem); diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index 630b2c3..83d73ec 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -20,12 +20,14 @@ export class ProductGamesystem extends Gamesystem 0) { simpleGamesystem.componentName += "(Child)"; productGamesystem.addChildGamesystem(simpleGamesystem); + simpleGamesystem.parentGamesystem = productGamesystem } if(parentGamesystem != undefined) { parentGamesystem.removeChildGamesystem(simpleGamesystem); parentGamesystem.addChildGamesystem(productGamesystem); + productGamesystem.parentGamesystem = parentGamesystem } else { gameModel.removeGamesystem(simpleGamesystem); gameModel.addGamesystem(productGamesystem); diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index eadb92e..d071a0b 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -26,6 +26,9 @@ export class GamesystemSerializer { private static serializeSimpleGamesystem(simpleGamesystem: SimpleGamesystem): StoreComponent { const fileName = this.computeSimpleGamesystemPath(simpleGamesystem); + if(simpleGamesystem.componentName === "Weather(Child)") { + console.log(fileName) + } const jsonString = JSON.stringify(simpleGamesystem, (key, value) => { if(this.IGNORED_SIMPLE_ATTRIBUTES.includes(key)) { From 32656267ace07150fdfb9da842584b26df026d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 07:45:59 +0100 Subject: [PATCH 50/58] Generate Content of Productgamesystems --- src/app/app.component.ts | 1 + src/app/project/game-model/GameModel.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c1f5ec7..2467861 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -177,6 +177,7 @@ export class AppComponent implements OnInit{ gameModel.scriptAccounts = scriptAccounts gameModel.gamesystems = gamesystems + gameModel.generateProductSystemContents() console.log(gameModel.scriptAccounts) diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 7c98dcf..625d3d2 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -90,4 +90,12 @@ export class GameModel { addScriptAccount(scriptAccount: ScriptAccount) { this.scriptAccounts.push(scriptAccount); } + + generateProductSystemContents() { + this.gamesystems.forEach(gamesystem => { + if(gamesystem instanceof ProductGamesystem) { + gamesystem.generateFromChildsystems(); + } + }) + } } From 6a8c34df521b425ac3ffcb70eaeae8c2b3ce34cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 07:53:02 +0100 Subject: [PATCH 51/58] Fix import of GameModel in Testcases --- e2e/game-model/AddingGamesystems.spec.ts | 4 ++-- e2e/game-model/RemovingGamesystems.spec.ts | 4 ++-- .../gamesystems/CreateGamesystem.spec.ts | 10 +--------- e2e/game-model/gamesystems/FindGamesystem.spec.ts | 10 +++++----- e2e/game-model/gamesystems/GamesystemTrainer.ts | 6 +++--- .../gamesystems/SimpleGamesystem.spec.ts | 10 +++++----- .../gamesystems/actions/AddActions.spec.ts | 4 ++-- .../gamesystems/actions/RemoveActions.spec.ts | 6 +++--- .../gamesystems/actions/SimpleActionTrainer.ts | 8 ++++---- .../conditions/AddTransitionConditions.spec.ts | 4 ++-- .../conditions/ConditionContradicting.spec.ts | 4 ++-- .../conditions/ConditionCreation.spec.ts | 4 ++-- .../conditions/ConditionExpansion.spec.ts | 4 +--- .../gamesystems/conditions/ConditionTrainer.ts | 4 ++-- .../conditions/TransitionConditionTrainer.ts | 8 ++++---- .../productGamesystems/CreateProductStates.spec.ts | 14 ++------------ .../CreateProductTransitions.spec.ts | 4 ++-- .../productGamesystems/EqualInnerStates.spec.ts | 12 ------------ .../ProductStateGeneration.spec.ts | 13 ------------- .../productGamesystems/ProductStateTrainer.ts | 8 ++++---- .../ProductSystemGenerationTrainer.ts | 4 ++-- .../scriptAccounts/ScriptAccountTest.spec.ts | 8 ++++---- 22 files changed, 54 insertions(+), 99 deletions(-) diff --git a/e2e/game-model/AddingGamesystems.spec.ts b/e2e/game-model/AddingGamesystems.spec.ts index 4d65fd0..db9f74a 100644 --- a/e2e/game-model/AddingGamesystems.spec.ts +++ b/e2e/game-model/AddingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/project/game-modelGameModel"; +import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; test.describe('Adding Gamesystems', () => { diff --git a/e2e/game-model/RemovingGamesystems.spec.ts b/e2e/game-model/RemovingGamesystems.spec.ts index e5777fe..1e9596e 100644 --- a/e2e/game-model/RemovingGamesystems.spec.ts +++ b/e2e/game-model/RemovingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/project/game-model/GameModel"; +import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; test.describe('Removing Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts index 84e01c5..07a6d7a 100644 --- a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts @@ -1,15 +1,7 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {ProductGamesystem} from "../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; test.describe('Test Create Gamesystems', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/FindGamesystem.spec.ts b/e2e/game-model/gamesystems/FindGamesystem.spec.ts index 879717b..67d32c4 100644 --- a/e2e/game-model/gamesystems/FindGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/FindGamesystem.spec.ts @@ -1,11 +1,11 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; +import {Gamesystem} from "../../src/app/project/gamemodel/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/project/gamemodel/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; import exp = require("node:constants"); import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; diff --git a/e2e/game-model/gamesystems/GamesystemTrainer.ts b/e2e/game-model/gamesystems/GamesystemTrainer.ts index 515882e..8c2581b 100644 --- a/e2e/game-model/gamesystems/GamesystemTrainer.ts +++ b/e2e/game-model/gamesystems/GamesystemTrainer.ts @@ -1,6 +1,6 @@ -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; +import {SimpleGamesystem} from "../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; export class GamesystemTrainer { diff --git a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts index 4c61efd..479baae 100644 --- a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts @@ -1,11 +1,11 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; +import {Gamesystem} from "../../src/app/project/gamemodel/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/project/gamemodel/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; import exp = require("node:constants"); import {end} from "electron-debug"; diff --git a/e2e/game-model/gamesystems/actions/AddActions.spec.ts b/e2e/game-model/gamesystems/actions/AddActions.spec.ts index 3e1fd12..d7057a0 100644 --- a/e2e/game-model/gamesystems/actions/AddActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/AddActions.spec.ts @@ -2,8 +2,8 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/gamemodel/gamesystems/actions/ScriptAccountAction"; test.describe('Test Create SimpleActions', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts index 931f7c9..39e0087 100644 --- a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts @@ -2,9 +2,9 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; -import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/gamemodel/gamesystems/actions/ScriptAccountAction"; +import {SimpleTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/SimpleTransition"; test.describe('Test Remove SimpleActions', () => { test("Test Removing invalid Actions", async () => { diff --git a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts index 219ae4d..ad05361 100644 --- a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts +++ b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts @@ -1,8 +1,8 @@ -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {SimpleState} from "../../../../src/app/project/gamemodel/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/SimpleTransition"; import {Script} from "node:vm"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/gamemodel/gamesystems/actions/ScriptAccountAction"; export class SimpleActionTrainer { static withEmptyActions() { diff --git a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts index c9fb7a9..6c4280a 100644 --- a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts +++ b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts index 8a26afc..880b539 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts index 9b1239c..267a10c 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); test.describe('Test Create Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts index d2b859c..ac9f593 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import exp = require("node:constants"); +import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; import {ConditionTrainer} from "./ConditionTrainer"; test.describe('Test Expand Conditions', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts index ea4587c..12bbbff 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -1,5 +1,5 @@ -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; export class ConditionTrainer { static withSimpleCondition(): ScriptAccountCondition { diff --git a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts index ba97347..20db5cb 100644 --- a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts @@ -1,7 +1,7 @@ -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {SimpleState} from "../../../../src/app/project/gamemodel/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; export class TransitionConditionTrainer { static withTransitionWithoutConditions() { const startingState = new SimpleState("StartingState", ""); diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts index 165f9c6..3224c3c 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts @@ -1,17 +1,7 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; -import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; + import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; +import {SimpleState} from "../../../../src/app/project/gamemodel/gamesystems/states/SimpleState"; test.describe('Test Create ProductStates', () => { test("Adding already existent ProductState", async () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts index dd687f3..6d6fd31 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; -import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/project/gamemodel/gamesystems/states/ProductState"; +import {SimpleGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; test.describe('Test Create ProductTransitions', () => { test("Test ProductTransition Creation with invalid inputs", async ()=> { const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates(); diff --git a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts index 5479bf2..070f5dc 100644 --- a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts @@ -1,17 +1,5 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; -import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; test.describe('Test Check Equal of Innerstates', () => { test("Test invalid input for equal checking", async()=> { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts index 9e71230..d1ae17a 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts @@ -1,17 +1,4 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; -import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; -import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; import {ProductSystemGenerationTrainer} from "./ProductSystemGenerationTrainer"; test.describe('Test Create ProductStates', () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts index 797ad83..cc585f8 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts @@ -1,7 +1,7 @@ -import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; -import {ProductTransition} from "../../../../src/app/game-model/gamesystems/transitions/ProductTransition"; +import {ProductGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/project/gamemodel/gamesystems/states/ProductState"; +import {ProductTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/ProductTransition"; export class ProductStateTrainer { static INNERSTATE_LETTER_1 = "A"; diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts index aa34557..f5e66c9 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts @@ -1,5 +1,5 @@ -import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; export class ProductSystemGenerationTrainer { diff --git a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts index 00688ac..3fd9b2a 100644 --- a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts +++ b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts @@ -1,10 +1,10 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; +import {Gamesystem} from "../../src/app/project/gamemodel/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/project/gamemodel/ModelComponentType"; test.describe('Test ScriptAccounts', () => { From f1373caa9f9673275842a3a77ff30879ae8c74e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:00:24 +0100 Subject: [PATCH 52/58] Revert "Fix import of GameModel in Testcases" This reverts commit 6a8c34df521b425ac3ffcb70eaeae8c2b3ce34cc. --- e2e/game-model/AddingGamesystems.spec.ts | 4 ++-- e2e/game-model/RemovingGamesystems.spec.ts | 4 ++-- .../gamesystems/CreateGamesystem.spec.ts | 10 +++++++++- e2e/game-model/gamesystems/FindGamesystem.spec.ts | 10 +++++----- e2e/game-model/gamesystems/GamesystemTrainer.ts | 6 +++--- .../gamesystems/SimpleGamesystem.spec.ts | 10 +++++----- .../gamesystems/actions/AddActions.spec.ts | 4 ++-- .../gamesystems/actions/RemoveActions.spec.ts | 6 +++--- .../gamesystems/actions/SimpleActionTrainer.ts | 8 ++++---- .../conditions/AddTransitionConditions.spec.ts | 4 ++-- .../conditions/ConditionContradicting.spec.ts | 4 ++-- .../conditions/ConditionCreation.spec.ts | 4 ++-- .../conditions/ConditionExpansion.spec.ts | 4 +++- .../gamesystems/conditions/ConditionTrainer.ts | 4 ++-- .../conditions/TransitionConditionTrainer.ts | 8 ++++---- .../productGamesystems/CreateProductStates.spec.ts | 14 ++++++++++++-- .../CreateProductTransitions.spec.ts | 4 ++-- .../productGamesystems/EqualInnerStates.spec.ts | 12 ++++++++++++ .../ProductStateGeneration.spec.ts | 13 +++++++++++++ .../productGamesystems/ProductStateTrainer.ts | 8 ++++---- .../ProductSystemGenerationTrainer.ts | 4 ++-- .../scriptAccounts/ScriptAccountTest.spec.ts | 8 ++++---- 22 files changed, 99 insertions(+), 54 deletions(-) diff --git a/e2e/game-model/AddingGamesystems.spec.ts b/e2e/game-model/AddingGamesystems.spec.ts index db9f74a..4d65fd0 100644 --- a/e2e/game-model/AddingGamesystems.spec.ts +++ b/e2e/game-model/AddingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/project/game-modelGameModel"; -import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; test.describe('Adding Gamesystems', () => { diff --git a/e2e/game-model/RemovingGamesystems.spec.ts b/e2e/game-model/RemovingGamesystems.spec.ts index 1e9596e..e5777fe 100644 --- a/e2e/game-model/RemovingGamesystems.spec.ts +++ b/e2e/game-model/RemovingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/project/game-model/GameModel"; -import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; test.describe('Removing Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts index 07a6d7a..84e01c5 100644 --- a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts @@ -1,7 +1,15 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; +import * as PATH from 'path'; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import exp = require("node:constants"); +import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; +import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; test.describe('Test Create Gamesystems', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/FindGamesystem.spec.ts b/e2e/game-model/gamesystems/FindGamesystem.spec.ts index 67d32c4..879717b 100644 --- a/e2e/game-model/gamesystems/FindGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/FindGamesystem.spec.ts @@ -1,11 +1,11 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; -import {Gamesystem} from "../../src/app/project/gamemodel/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/project/gamemodel/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; import exp = require("node:constants"); import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; diff --git a/e2e/game-model/gamesystems/GamesystemTrainer.ts b/e2e/game-model/gamesystems/GamesystemTrainer.ts index 8c2581b..515882e 100644 --- a/e2e/game-model/gamesystems/GamesystemTrainer.ts +++ b/e2e/game-model/gamesystems/GamesystemTrainer.ts @@ -1,6 +1,6 @@ -import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; -import {SimpleGamesystem} from "../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; -import {ProductGamesystem} from "../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; export class GamesystemTrainer { diff --git a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts index 479baae..4c61efd 100644 --- a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts @@ -1,11 +1,11 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; -import {Gamesystem} from "../../src/app/project/gamemodel/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/project/gamemodel/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; import exp = require("node:constants"); import {end} from "electron-debug"; diff --git a/e2e/game-model/gamesystems/actions/AddActions.spec.ts b/e2e/game-model/gamesystems/actions/AddActions.spec.ts index d7057a0..3e1fd12 100644 --- a/e2e/game-model/gamesystems/actions/AddActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/AddActions.spec.ts @@ -2,8 +2,8 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/project/gamemodel/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; test.describe('Test Create SimpleActions', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts index 39e0087..931f7c9 100644 --- a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts @@ -2,9 +2,9 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/project/gamemodel/gamesystems/actions/ScriptAccountAction"; -import {SimpleTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; test.describe('Test Remove SimpleActions', () => { test("Test Removing invalid Actions", async () => { diff --git a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts index ad05361..219ae4d 100644 --- a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts +++ b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts @@ -1,8 +1,8 @@ -import {SimpleState} from "../../../../src/app/project/gamemodel/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/SimpleTransition"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; import {Script} from "node:vm"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/project/gamemodel/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; export class SimpleActionTrainer { static withEmptyActions() { diff --git a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts index 6c4280a..c9fb7a9 100644 --- a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts +++ b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts index 880b539..8a26afc 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts index 267a10c..9b1239c 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); test.describe('Test Create Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts index ac9f593..d2b859c 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts @@ -1,6 +1,8 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; test.describe('Test Expand Conditions', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts index 12bbbff..ea4587c 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -1,5 +1,5 @@ -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; export class ConditionTrainer { static withSimpleCondition(): ScriptAccountCondition { diff --git a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts index 20db5cb..ba97347 100644 --- a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts @@ -1,7 +1,7 @@ -import {SimpleState} from "../../../../src/app/project/gamemodel/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/SimpleTransition"; -import {ScriptAccount} from "../../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/project/gamemodel/gamesystems/conditions/ScriptAccountCondition"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; export class TransitionConditionTrainer { static withTransitionWithoutConditions() { const startingState = new SimpleState("StartingState", ""); diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts index 3224c3c..165f9c6 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts @@ -1,7 +1,17 @@ +import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; - +import * as PATH from 'path'; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import exp = require("node:constants"); +import {end} from "electron-debug"; +import {GamesystemTrainer} from "./GamesystemTrainer"; +import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/project/gamemodel/gamesystems/states/SimpleState"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; test.describe('Test Create ProductStates', () => { test("Adding already existent ProductState", async () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts index 6d6fd31..dd687f3 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {ProductState} from "../../../../src/app/project/gamemodel/gamesystems/states/ProductState"; -import {SimpleGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; +import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; test.describe('Test Create ProductTransitions', () => { test("Test ProductTransition Creation with invalid inputs", async ()=> { const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates(); diff --git a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts index 070f5dc..5479bf2 100644 --- a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts @@ -1,5 +1,17 @@ +import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; +import * as PATH from 'path'; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import exp = require("node:constants"); +import {end} from "electron-debug"; +import {GamesystemTrainer} from "./GamesystemTrainer"; +import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; test.describe('Test Check Equal of Innerstates', () => { test("Test invalid input for equal checking", async()=> { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts index d1ae17a..9e71230 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts @@ -1,4 +1,17 @@ +import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; +import * as PATH from 'path'; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import exp = require("node:constants"); +import {end} from "electron-debug"; +import {GamesystemTrainer} from "./GamesystemTrainer"; +import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {ProductStateTrainer} from "./ProductStateTrainer"; +import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; import {ProductSystemGenerationTrainer} from "./ProductSystemGenerationTrainer"; test.describe('Test Create ProductStates', () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts index cc585f8..797ad83 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts @@ -1,7 +1,7 @@ -import {ProductGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../src/app/project/gamemodel/gamesystems/states/ProductState"; -import {ProductTransition} from "../../../../src/app/project/gamemodel/gamesystems/transitions/ProductTransition"; +import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; +import {ProductTransition} from "../../../../src/app/game-model/gamesystems/transitions/ProductTransition"; export class ProductStateTrainer { static INNERSTATE_LETTER_1 = "A"; diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts index f5e66c9..aa34557 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts @@ -1,5 +1,5 @@ -import {ProductGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/project/gamemodel/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; export class ProductSystemGenerationTrainer { diff --git a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts index 3fd9b2a..00688ac 100644 --- a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts +++ b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts @@ -1,10 +1,10 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/project/gamemodel/GameModel"; -import {Gamesystem} from "../../src/app/project/gamemodel/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/project/gamemodel/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/project/gamemodel/ModelComponentType"; +import {GameModel} from "../../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; test.describe('Test ScriptAccounts', () => { From e336bf19f9173df02986d92eab3fdbbc3912f9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:05:07 +0100 Subject: [PATCH 53/58] Fix import of GameModel in Testcases properly this time --- e2e/game-model/AddingGamesystems.spec.ts | 4 ++-- e2e/game-model/RemovingGamesystems.spec.ts | 4 ++-- e2e/game-model/gamesystems/CreateGamesystem.spec.ts | 11 +---------- e2e/game-model/gamesystems/FindGamesystem.spec.ts | 11 ++--------- e2e/game-model/gamesystems/GamesystemTrainer.ts | 6 +++--- e2e/game-model/gamesystems/SimpleGamesystem.spec.ts | 8 -------- .../gamesystems/actions/AddActions.spec.ts | 4 ++-- .../gamesystems/actions/RemoveActions.spec.ts | 6 +++--- .../gamesystems/actions/SimpleActionTrainer.ts | 8 ++++---- .../conditions/AddTransitionConditions.spec.ts | 4 ++-- .../conditions/ConditionContradicting.spec.ts | 4 ++-- .../conditions/ConditionCreation.spec.ts | 4 ++-- .../conditions/ConditionExpansion.spec.ts | 4 ++-- .../gamesystems/conditions/ConditionTrainer.ts | 4 ++-- .../conditions/TransitionConditionTrainer.ts | 8 ++++---- .../productGamesystems/CreateProductStates.spec.ts | 13 +------------ .../CreateProductTransitions.spec.ts | 4 ++-- .../productGamesystems/EqualInnerStates.spec.ts | 12 ------------ .../ProductStateGeneration.spec.ts | 13 ------------- .../productGamesystems/ProductStateTrainer.ts | 8 ++++---- .../ProductSystemGenerationTrainer.ts | 4 ++-- .../scriptAccounts/ScriptAccountTest.spec.ts | 8 ++++---- 22 files changed, 46 insertions(+), 106 deletions(-) diff --git a/e2e/game-model/AddingGamesystems.spec.ts b/e2e/game-model/AddingGamesystems.spec.ts index 4d65fd0..6a73c7c 100644 --- a/e2e/game-model/AddingGamesystems.spec.ts +++ b/e2e/game-model/AddingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/projects/game-model/GameModel"; +import {Gamesystem} from "../../src/app/projects/game-model/gamesystems/Gamesystem"; test.describe('Adding Gamesystems', () => { diff --git a/e2e/game-model/RemovingGamesystems.spec.ts b/e2e/game-model/RemovingGamesystems.spec.ts index e5777fe..643214a 100644 --- a/e2e/game-model/RemovingGamesystems.spec.ts +++ b/e2e/game-model/RemovingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/projects/game-model/GameModel"; +import {Gamesystem} from "../../src/app/projects/game-model/gamesystems/Gamesystem"; test.describe('Removing Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts index 84e01c5..0a2710b 100644 --- a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts @@ -1,15 +1,6 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {ProductGamesystem} from "../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; test.describe('Test Create Gamesystems', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/FindGamesystem.spec.ts b/e2e/game-model/gamesystems/FindGamesystem.spec.ts index 879717b..859edf3 100644 --- a/e2e/game-model/gamesystems/FindGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/FindGamesystem.spec.ts @@ -1,13 +1,6 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; +import {GameModel} from "../../../src/app/projects/game-model/GameModel"; +import {SimpleGamesystem} from "../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; import {GamesystemTrainer} from "./GamesystemTrainer"; test.describe('Test Find Gamesystems', () => { const GAMEMODELNAME: string = "GameModel"; diff --git a/e2e/game-model/gamesystems/GamesystemTrainer.ts b/e2e/game-model/gamesystems/GamesystemTrainer.ts index 515882e..55b2e74 100644 --- a/e2e/game-model/gamesystems/GamesystemTrainer.ts +++ b/e2e/game-model/gamesystems/GamesystemTrainer.ts @@ -1,6 +1,6 @@ -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; +import {GameModel} from "../../../src/app/projects/game-model/GameModel"; +import {SimpleGamesystem} from "../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; export class GamesystemTrainer { diff --git a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts index 4c61efd..12e0d7d 100644 --- a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts @@ -1,13 +1,5 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; test.describe('Test SimpleGamesystem', () => { diff --git a/e2e/game-model/gamesystems/actions/AddActions.spec.ts b/e2e/game-model/gamesystems/actions/AddActions.spec.ts index 3e1fd12..fb3ad35 100644 --- a/e2e/game-model/gamesystems/actions/AddActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/AddActions.spec.ts @@ -2,8 +2,8 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/projects/game-model/gamesystems/actions/ScriptAccountAction"; test.describe('Test Create SimpleActions', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts index 931f7c9..69f29e1 100644 --- a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts @@ -2,9 +2,9 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; -import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/projects/game-model/gamesystems/actions/ScriptAccountAction"; +import {SimpleTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/SimpleTransition"; test.describe('Test Remove SimpleActions', () => { test("Test Removing invalid Actions", async () => { diff --git a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts index 219ae4d..4b68c63 100644 --- a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts +++ b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts @@ -1,8 +1,8 @@ -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; +import {SimpleState} from "../../../../src/app/projects/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/SimpleTransition"; import {Script} from "node:vm"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/projects/game-model/gamesystems/actions/ScriptAccountAction"; export class SimpleActionTrainer { static withEmptyActions() { diff --git a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts index c9fb7a9..32203c5 100644 --- a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts +++ b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts index 8a26afc..e21bcf7 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts index 9b1239c..c724edd 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); test.describe('Test Create Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts index d2b859c..560f282 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; test.describe('Test Expand Conditions', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts index ea4587c..6d4dc44 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -1,5 +1,5 @@ -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; export class ConditionTrainer { static withSimpleCondition(): ScriptAccountCondition { diff --git a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts index ba97347..b219670 100644 --- a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts @@ -1,7 +1,7 @@ -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/game-model/gamesystems/transitions/SimpleTransition"; -import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {SimpleState} from "../../../../src/app/projects/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; export class TransitionConditionTrainer { static withTransitionWithoutConditions() { const startingState = new SimpleState("StartingState", ""); diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts index 165f9c6..990a1f7 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts @@ -1,17 +1,6 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; -import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; +import {SimpleState} from "../../../../src/app/projects/game-model/gamesystems/states/SimpleState"; test.describe('Test Create ProductStates', () => { test("Adding already existent ProductState", async () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts index dd687f3..ccf4186 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; -import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/projects/game-model/gamesystems/states/ProductState"; +import {SimpleGamesystem} from "../../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; test.describe('Test Create ProductTransitions', () => { test("Test ProductTransition Creation with invalid inputs", async ()=> { const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates(); diff --git a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts index 5479bf2..070f5dc 100644 --- a/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts @@ -1,17 +1,5 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; -import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; test.describe('Test Check Equal of Innerstates', () => { test("Test invalid input for equal checking", async()=> { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts index 9e71230..d1ae17a 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts @@ -1,17 +1,4 @@ -import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; -import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import exp = require("node:constants"); -import {end} from "electron-debug"; -import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/game-model/gamesystems/ProductGamesystem"; -import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/game-model/gamesystems/states/SimpleState"; import {ProductSystemGenerationTrainer} from "./ProductSystemGenerationTrainer"; test.describe('Test Create ProductStates', () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts index 797ad83..5f57cb8 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts @@ -1,7 +1,7 @@ -import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../src/app/game-model/gamesystems/states/ProductState"; -import {ProductTransition} from "../../../../src/app/game-model/gamesystems/transitions/ProductTransition"; +import {ProductGamesystem} from "../../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/projects/game-model/gamesystems/states/ProductState"; +import {ProductTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/ProductTransition"; export class ProductStateTrainer { static INNERSTATE_LETTER_1 = "A"; diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts index aa34557..b3f585f 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts @@ -1,5 +1,5 @@ -import {ProductGamesystem} from "../../../../src/app/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; export class ProductSystemGenerationTrainer { diff --git a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts index 00688ac..88c6ba7 100644 --- a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts +++ b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts @@ -1,10 +1,10 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/game-model/GameModel"; -import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/game-model/ModelComponentType"; +import {GameModel} from "../../../src/app/projects/game-model/GameModel"; +import {Gamesystem} from "../../src/app/projects/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/projects/game-model/ModelComponentType"; test.describe('Test ScriptAccounts', () => { From 75815578dca0b11933e3bce2a532b68255612a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:10:22 +0100 Subject: [PATCH 54/58] Fix typo in gamemodel import path in test --- e2e/game-model/AddingGamesystems.spec.ts | 4 ++-- e2e/game-model/RemovingGamesystems.spec.ts | 5 +++-- e2e/game-model/gamesystems/CreateGamesystem.spec.ts | 2 +- e2e/game-model/gamesystems/FindGamesystem.spec.ts | 4 ++-- e2e/game-model/gamesystems/GamesystemTrainer.ts | 6 +++--- e2e/game-model/gamesystems/actions/AddActions.spec.ts | 4 ++-- e2e/game-model/gamesystems/actions/RemoveActions.spec.ts | 6 +++--- e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts | 8 ++++---- .../conditions/AddTransitionConditions.spec.ts | 4 ++-- .../gamesystems/conditions/ConditionContradicting.spec.ts | 4 ++-- .../gamesystems/conditions/ConditionCreation.spec.ts | 4 ++-- .../gamesystems/conditions/ConditionExpansion.spec.ts | 4 ++-- e2e/game-model/gamesystems/conditions/ConditionTrainer.ts | 4 ++-- .../gamesystems/conditions/TransitionConditionTrainer.ts | 8 ++++---- .../productGamesystems/CreateProductStates.spec.ts | 2 +- .../productGamesystems/CreateProductTransitions.spec.ts | 4 ++-- .../gamesystems/productGamesystems/ProductStateTrainer.ts | 8 ++++---- .../productGamesystems/ProductSystemGenerationTrainer.ts | 4 ++-- e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts | 8 ++++---- 19 files changed, 47 insertions(+), 46 deletions(-) diff --git a/e2e/game-model/AddingGamesystems.spec.ts b/e2e/game-model/AddingGamesystems.spec.ts index 6a73c7c..9d6d13a 100644 --- a/e2e/game-model/AddingGamesystems.spec.ts +++ b/e2e/game-model/AddingGamesystems.spec.ts @@ -1,8 +1,8 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/projects/game-model/GameModel"; -import {Gamesystem} from "../../src/app/projects/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/project/game-model/GameModel"; +import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; test.describe('Adding Gamesystems', () => { diff --git a/e2e/game-model/RemovingGamesystems.spec.ts b/e2e/game-model/RemovingGamesystems.spec.ts index 643214a..0caa1e1 100644 --- a/e2e/game-model/RemovingGamesystems.spec.ts +++ b/e2e/game-model/RemovingGamesystems.spec.ts @@ -1,8 +1,9 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../src/app/projects/game-model/GameModel"; -import {Gamesystem} from "../../src/app/projects/game-model/gamesystems/Gamesystem"; + +import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; +import {GameModel} from "../../src/app/project/game-model/GameModel"; test.describe('Removing Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts index 0a2710b..fffea92 100644 --- a/e2e/game-model/gamesystems/CreateGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/CreateGamesystem.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "./GamesystemTrainer"; -import {ProductGamesystem} from "../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; +import {ProductGamesystem} from "../../../src/app/project/game-model/gamesystems/ProductGamesystem"; test.describe('Test Create Gamesystems', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/FindGamesystem.spec.ts b/e2e/game-model/gamesystems/FindGamesystem.spec.ts index 859edf3..095432d 100644 --- a/e2e/game-model/gamesystems/FindGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/FindGamesystem.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; -import {GameModel} from "../../../src/app/projects/game-model/GameModel"; -import {SimpleGamesystem} from "../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; +import {GameModel} from "../../../src/app/project/game-model/GameModel"; +import {SimpleGamesystem} from "../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; import {GamesystemTrainer} from "./GamesystemTrainer"; test.describe('Test Find Gamesystems', () => { const GAMEMODELNAME: string = "GameModel"; diff --git a/e2e/game-model/gamesystems/GamesystemTrainer.ts b/e2e/game-model/gamesystems/GamesystemTrainer.ts index 55b2e74..f70ce51 100644 --- a/e2e/game-model/gamesystems/GamesystemTrainer.ts +++ b/e2e/game-model/gamesystems/GamesystemTrainer.ts @@ -1,6 +1,6 @@ -import {GameModel} from "../../../src/app/projects/game-model/GameModel"; -import {SimpleGamesystem} from "../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; -import {ProductGamesystem} from "../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; +import {GameModel} from "../../../src/app/project/game-model/GameModel"; +import {SimpleGamesystem} from "../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../src/app/project/game-model/gamesystems/ProductGamesystem"; export class GamesystemTrainer { diff --git a/e2e/game-model/gamesystems/actions/AddActions.spec.ts b/e2e/game-model/gamesystems/actions/AddActions.spec.ts index fb3ad35..19ea15e 100644 --- a/e2e/game-model/gamesystems/actions/AddActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/AddActions.spec.ts @@ -2,8 +2,8 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/projects/game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/game-model/gamesystems/actions/ScriptAccountAction"; test.describe('Test Create SimpleActions', () => { test('Test creating gamesystem with invalid name', async => { diff --git a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts index 69f29e1..40cd9a4 100644 --- a/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts +++ b/e2e/game-model/gamesystems/actions/RemoveActions.spec.ts @@ -2,9 +2,9 @@ import { test, expect } from '@playwright/test'; import {GamesystemTrainer} from "../GamesystemTrainer"; import {SimpleActionTrainer} from "./SimpleActionTrainer"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/projects/game-model/gamesystems/actions/ScriptAccountAction"; -import {SimpleTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/game-model/gamesystems/actions/ScriptAccountAction"; +import {SimpleTransition} from "../../../../src/app/project/game-model/gamesystems/transitions/SimpleTransition"; test.describe('Test Remove SimpleActions', () => { test("Test Removing invalid Actions", async () => { diff --git a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts index 4b68c63..1e0b7d3 100644 --- a/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts +++ b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts @@ -1,8 +1,8 @@ -import {SimpleState} from "../../../../src/app/projects/game-model/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/SimpleTransition"; +import {SimpleState} from "../../../../src/app/project/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/project/game-model/gamesystems/transitions/SimpleTransition"; import {Script} from "node:vm"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountAction} from "../../../../src/app/projects/game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/game-model/gamesystems/actions/ScriptAccountAction"; export class SimpleActionTrainer { static withEmptyActions() { diff --git a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts index 32203c5..5cb1797 100644 --- a/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts +++ b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts index e21bcf7..d71e5ef 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; import {Conditional} from "@angular/compiler"; diff --git a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts index c724edd..112de84 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); test.describe('Test Create Gamesystems', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts index 560f282..bd5b2cb 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; -import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; import exp = require("node:constants"); import {ConditionTrainer} from "./ConditionTrainer"; test.describe('Test Expand Conditions', () => { diff --git a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts index 6d4dc44..47718d3 100644 --- a/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -1,5 +1,5 @@ -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition"; export class ConditionTrainer { static withSimpleCondition(): ScriptAccountCondition { diff --git a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts index b219670..7c94d20 100644 --- a/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts +++ b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts @@ -1,7 +1,7 @@ -import {SimpleState} from "../../../../src/app/projects/game-model/gamesystems/states/SimpleState"; -import {SimpleTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/SimpleTransition"; -import {ScriptAccount} from "../../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; -import {ScriptAccountCondition} from "../../../../src/app/projects/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {SimpleState} from "../../../../src/app/project/game-model/gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../../../src/app/project/game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccount} from "../../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../../../src/app/project/game-model/gamesystems/conditions/ScriptAccountCondition"; export class TransitionConditionTrainer { static withTransitionWithoutConditions() { const startingState = new SimpleState("StartingState", ""); diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts index 990a1f7..0e35828 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {SimpleState} from "../../../../src/app/projects/game-model/gamesystems/states/SimpleState"; +import {SimpleState} from "../../../../src/app/project/game-model/gamesystems/states/SimpleState"; test.describe('Test Create ProductStates', () => { test("Adding already existent ProductState", async () => { diff --git a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts index ccf4186..44b3dce 100644 --- a/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/CreateProductTransitions.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; import {ProductStateTrainer} from "./ProductStateTrainer"; -import {ProductState} from "../../../../src/app/projects/game-model/gamesystems/states/ProductState"; -import {SimpleGamesystem} from "../../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/project/game-model/gamesystems/states/ProductState"; +import {SimpleGamesystem} from "../../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; test.describe('Test Create ProductTransitions', () => { test("Test ProductTransition Creation with invalid inputs", async ()=> { const gamesystem = ProductStateTrainer.givenFullProductGamesystemWithTwoStates(); diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts index 5f57cb8..a9a2d9c 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer.ts @@ -1,7 +1,7 @@ -import {ProductGamesystem} from "../../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; -import {ProductState} from "../../../../src/app/projects/game-model/gamesystems/states/ProductState"; -import {ProductTransition} from "../../../../src/app/projects/game-model/gamesystems/transitions/ProductTransition"; +import {ProductGamesystem} from "../../../../src/app/project/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../src/app/project/game-model/gamesystems/states/ProductState"; +import {ProductTransition} from "../../../../src/app/project/game-model/gamesystems/transitions/ProductTransition"; export class ProductStateTrainer { static INNERSTATE_LETTER_1 = "A"; diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts index b3f585f..2d6011e 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts @@ -1,5 +1,5 @@ -import {ProductGamesystem} from "../../../../src/app/projects/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/projects/game-model/gamesystems/SimpleGamesystem"; +import {ProductGamesystem} from "../../../../src/app/project/game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; export class ProductSystemGenerationTrainer { diff --git a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts index 88c6ba7..27aaed2 100644 --- a/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts +++ b/e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts @@ -1,10 +1,10 @@ import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; import { test, expect } from '@playwright/test'; import * as PATH from 'path'; -import {GameModel} from "../../../src/app/projects/game-model/GameModel"; -import {Gamesystem} from "../../src/app/projects/game-model/gamesystems/Gamesystem"; -import {ScriptAccount} from "../../../src/app/projects/game-model/scriptAccounts/ScriptAccount"; -import {ModelComponentType} from "../../../src/app/projects/game-model/ModelComponentType"; +import {GameModel} from "../../../src/app/project/game-model/GameModel"; +import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../../src/app/project/game-model/scriptAccounts/ScriptAccount"; +import {ModelComponentType} from "../../../src/app/project/game-model/ModelComponentType"; test.describe('Test ScriptAccounts', () => { From 86fb22e701fe1bb247c2e6c08b7ab60c215a10b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:14:19 +0100 Subject: [PATCH 55/58] Fix GameModel Import Path in SimpleGamesystem.spec.ts --- e2e/game-model/gamesystems/SimpleGamesystem.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts index 12e0d7d..a47f181 100644 --- a/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts +++ b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import {SimpleGamesystem} from "../../../src/app/game-model/gamesystems/SimpleGamesystem"; +import {SimpleGamesystem} from "../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; test.describe('Test SimpleGamesystem', () => { From 40680006e63208b53dfd1be1bd6a3ea320cadf88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:20:42 +0100 Subject: [PATCH 56/58] Remove logging statement --- src/app/project/game-model/GameModel.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 625d3d2..66dd46c 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -52,7 +52,6 @@ export class GameModel { const parentProductGamesystem = ProductGamesystem.constructFromSimpleGamesystem(parentGamesystem, this); parentProductGamesystem.addChildGamesystem(simpleGamesystem); simpleGamesystem.parentGamesystem = parentProductGamesystem; - console.log("The parent of my parent is ", parentProductGamesystem.parentGamesystem!.componentName) } else { const productParentGamesystem = parentGamesystem as ProductGamesystem; productParentGamesystem.addChildGamesystem(simpleGamesystem); From 2416e226fc8ee84db1fa9e35744b183cb0e258ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:34:54 +0100 Subject: [PATCH 57/58] Load ScriptAccountActions --- .../ScriptAccountActionParser.ts | 36 ++++++++++++++++++ .../gamesystemParser/TransitionParser.ts | 4 ++ testModel/gamesystems/Testsystem.json | 37 +++++++++++++++++++ .../Weathersystem/Weathersystem.json | 13 +------ 4 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts create mode 100644 testModel/gamesystems/Testsystem.json diff --git a/src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts b/src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts new file mode 100644 index 0000000..b0d071f --- /dev/null +++ b/src/app/project/parser/gamesystemParser/ScriptAccountActionParser.ts @@ -0,0 +1,36 @@ +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountAction} from "../../game-model/gamesystems/actions/ScriptAccountAction"; + +export class ScriptAccountActionParser { + private scriptAccounts: ScriptAccount[] + + + constructor(scriptAccounts: ScriptAccount[]) { + this.scriptAccounts = scriptAccounts; + } + + parseActions(actionData: any) { + const actions: ScriptAccountAction[] = [] + for(let i=0; i scriptAccount.componentName === scriptAccountName); + } +} diff --git a/src/app/project/parser/gamesystemParser/TransitionParser.ts b/src/app/project/parser/gamesystemParser/TransitionParser.ts index f886d34..2bd13df 100644 --- a/src/app/project/parser/gamesystemParser/TransitionParser.ts +++ b/src/app/project/parser/gamesystemParser/TransitionParser.ts @@ -2,17 +2,20 @@ import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; import {ScriptAccountConditionParser} from "./ScriptAccountConditionParser"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {SimpleTransition} from "../../game-model/gamesystems/transitions/SimpleTransition"; +import {ScriptAccountActionParser} from "./ScriptAccountActionParser"; export class TransitionParser { private states: SimpleState[] private conditionParser: ScriptAccountConditionParser + private actionParser: ScriptAccountActionParser constructor(states: SimpleState[], scriptAccounts: ScriptAccount[]) { this.states = states; this.conditionParser = new ScriptAccountConditionParser(scriptAccounts); + this.actionParser = new ScriptAccountActionParser(scriptAccounts) } public parseTransitions(transitionData: any): SimpleTransition[] { @@ -36,6 +39,7 @@ export class TransitionParser { const simpleTransition = new SimpleTransition(startingState, endingState) simpleTransition.scriptAccountConditions = this.conditionParser.parseStoredConditions(transitionData.scriptAccountConditions) + simpleTransition.scriptAccountActions = this.actionParser.parseActions(transitionData.scriptAccountActions); return simpleTransition; } diff --git a/testModel/gamesystems/Testsystem.json b/testModel/gamesystems/Testsystem.json new file mode 100644 index 0000000..654df19 --- /dev/null +++ b/testModel/gamesystems/Testsystem.json @@ -0,0 +1,37 @@ +{ + "componentName": "Testsystem", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "A", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "B", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "changingValue": 5, + "scriptAccount": "New ScriptAccount" + } + ], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": "10" + } + ], + "startingState": "A", + "endingState": "B" + } + ] +} \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Weathersystem.json b/testModel/gamesystems/Weathersystem/Weathersystem.json index 47d644a..df066e7 100644 --- a/testModel/gamesystems/Weathersystem/Weathersystem.json +++ b/testModel/gamesystems/Weathersystem/Weathersystem.json @@ -1,12 +1 @@ -{ - "componentName": "Weathersystem", - "componentDescription": "Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt.", - "childsystems": [ - { - "componentName": "Season" - }, - { - "componentName": "Weather" - } - ] -} \ No newline at end of file +{"componentName":"Weathersystem","componentDescription":"Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt.","childsystems":[{"componentName":"Season"},{"componentName":"Weather"}]} \ No newline at end of file From 4bb37a5a183916134aa2cb6e7ad7b674d2b0e7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 08:36:59 +0100 Subject: [PATCH 58/58] Indent for ProductSystems --- src/app/project/serializer/GamesystemSerializer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index d071a0b..8ffcafc 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -65,7 +65,7 @@ export class GamesystemSerializer { 'childsystems': innerGamesystemJsonArray } - const storedProductsystem = new StoreComponent(JSON.stringify(jsonString), fileName, ModelComponentType.GAMESYTEM) + const storedProductsystem = new StoreComponent(JSON.stringify(jsonString, null, SerializeConstants.JSON_INDENT), fileName, ModelComponentType.GAMESYTEM) storedGamesystems.push(storedProductsystem) return storedGamesystems;
{{col.displayedName}} {{getLeafStateByIndex(transition, i).stateLabel}} + + Ending State
+
+

Expanded Row

+
+
No data matching the filter "{{input.value}}"
-

Expanded Row

+