From e2cfe97b61cf61fda38e299cff098f92b5110c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 11 Feb 2024 18:41:01 +0100 Subject: [PATCH] Test triple ProductGamesystem generation --- .../ProductStateGeneration.spec.ts | 7 +++++++ .../ProductSystemGenerationTrainer.ts | 14 ++++++++++++++ .../game-model/gamesystems/ProductGamesystem.ts | 14 ++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts index 77f7c29..c9991f3 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductStateGeneration.spec.ts @@ -23,5 +23,12 @@ test.describe('Test Create ProductStates', () => { expect(gamesystem.transitions.length).toEqual(5); }) + test("Test simple triple Product State", async () => { + const gamesystem = ProductSystemGenerationTrainer.givenTrippleProductSystem(); + gamesystem.generateFromChildsystems(); + + expect(gamesystem.states.length).toEqual(8); + expect(gamesystem.transitions.length).toEqual(19) + }) }); diff --git a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts index f847f9a..aa34557 100644 --- a/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts +++ b/e2e/game-model/gamesystems/productGamesystems/ProductSystemGenerationTrainer.ts @@ -6,12 +6,16 @@ export class ProductSystemGenerationTrainer { static PRODUCTGAMESYSTEMNAME = "ProductGamesystem"; static CHILDGAMESYSTEMNAME_LEFT = "Left Child System"; static CHILDGAMESYSTEMNAME_RIGHT = "Right Child System"; + static CHILDGAMESYSTEMNAME_MIDDLE = "Middle Child System"; static LEFTCHILDSYSTEM_A_NODE_NAME = "A"; static LEFTCHILDSYSTEM_B_NODE_NAME = "B"; static RIGHTCHILDSYSTEM_A_NODE_NAME = "1"; static RIGHTCHILDSYSTEM_B_NODE_NAME = "2"; + + static MIDDLECHILDSYSTEM_A_NODE_NAME = "Sun"; + static MIDDLECHILDSYSTEM_B_NODE_NAME = "Rain"; static givenSimplestProductSystem() { const productsystem = new ProductGamesystem(ProductSystemGenerationTrainer.PRODUCTGAMESYSTEMNAME); const left_childsystem = new SimpleGamesystem(ProductSystemGenerationTrainer.CHILDGAMESYSTEMNAME_LEFT); @@ -26,4 +30,14 @@ export class ProductSystemGenerationTrainer { return productsystem; } + + static givenTrippleProductSystem() { + const gamesystem = this.givenSimplestProductSystem(); + const middle_childsystem = new SimpleGamesystem(this.CHILDGAMESYSTEMNAME_MIDDLE); + + middle_childsystem.createTransition(middle_childsystem.createState(ProductSystemGenerationTrainer.MIDDLECHILDSYSTEM_A_NODE_NAME, "")!, + middle_childsystem.createState(ProductSystemGenerationTrainer.MIDDLECHILDSYSTEM_B_NODE_NAME, "")!); + gamesystem.addChildGamesystem(middle_childsystem); + return gamesystem; + } } diff --git a/src/app/game-model/gamesystems/ProductGamesystem.ts b/src/app/game-model/gamesystems/ProductGamesystem.ts index 11583f3..6fd5e31 100644 --- a/src/app/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/game-model/gamesystems/ProductGamesystem.ts @@ -65,18 +65,21 @@ export class ProductGamesystem extends Gamesystem[] = [this.innerGamesystems[0], this.innerGamesystems[1]]; + let gamesystem: ProductGamesystem = ProductGamesystem.generateFromChildsystems(this.innerGamesystems[0], this.innerGamesystems[1], false, integratedSystems); + for(let i=2; i, rightSystem: Gamesystem, left_temp: boolean) { + static generateFromChildsystems(leftSystem: Gamesystem, rightSystem: Gamesystem, left_temp: boolean, integratedSystems: Gamesystem[]) { const productGamesystem = new ProductGamesystem("Temporary Gamesystem"); - productGamesystem.addChildGamesystem(leftSystem); - productGamesystem.addChildGamesystem(rightSystem); + integratedSystems.forEach(integratedSystem => productGamesystem.addChildGamesystem(integratedSystem)); + leftSystem.states.forEach(leftState => { rightSystem.states.forEach(rightState => { for(let i=0; i