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] 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)) {