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/app/LoadModel.js b/app/LoadModel.js deleted file mode 100644 index a376e51..0000000 --- a/app/LoadModel.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.LoadModel = void 0; -class LoadModel { - constructor(jsonString, modelType) { - this.jsonString = jsonString; - this.modelType = modelType; - } -} -exports.LoadModel = LoadModel; -//# sourceMappingURL=LoadModel.js.map \ No newline at end of file diff --git a/app/LoadModel.ts b/app/LoadModel.ts deleted file mode 100644 index 9effb8d..0000000 --- a/app/LoadModel.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {ModelComponentType} from "../src/app/game-model/ModelComponentType"; - -export class LoadModel { - jsonString: string - modelType: ModelComponentType - - - constructor(jsonString: string, modelType: ModelComponentType) { - this.jsonString = jsonString; - this.modelType = modelType; - } -} diff --git a/app/LoadedProject.js b/app/LoadedProject.js deleted file mode 100644 index 66d4596..0000000 --- a/app/LoadedProject.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.LoadedProject = void 0; -class LoadedProject { - constructor(projectName, loadedModels) { - this.projectName = projectName; - this.loadedModels = loadedModels; - } -} -exports.LoadedProject = LoadedProject; -//# sourceMappingURL=LoadedProject.js.map \ No newline at end of file diff --git a/app/LoadedProject.ts b/app/LoadedProject.ts deleted file mode 100644 index be710b8..0000000 --- a/app/LoadedProject.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {LoadModel} from "./LoadModel"; - -export class LoadedProject { - projectName: string - loadedModels: LoadModel[] - - - constructor(projectName: string, loadedModels: LoadModel[]) { - this.projectName = projectName; - this.loadedModels = loadedModels; - } -} diff --git a/app/RecursiveLoadModel.js b/app/RecursiveLoadModel.js deleted file mode 100644 index 7599083..0000000 --- a/app/RecursiveLoadModel.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RecursiveLoadModel = void 0; -const LoadModel_1 = require("./LoadModel"); -class RecursiveLoadModel extends LoadModel_1.LoadModel { - constructor(jsonString, modelType, parentLoadModelname) { - super(jsonString, modelType); - this.parentLoadModelname = parentLoadModelname; - } -} -exports.RecursiveLoadModel = RecursiveLoadModel; -//# sourceMappingURL=RecursiveLoadModel.js.map \ No newline at end of file diff --git a/app/RecursiveLoadModel.ts b/app/RecursiveLoadModel.ts deleted file mode 100644 index 1b9d251..0000000 --- a/app/RecursiveLoadModel.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {LoadModel} from "./LoadModel"; -import {ModelComponentType} from "../src/app/game-model/ModelComponentType"; - -export class RecursiveLoadModel extends LoadModel { - parentLoadModelname: string - - - constructor(jsonString: string, modelType: ModelComponentType, parentLoadModelname: string) { - super(jsonString, modelType); - this.parentLoadModelname = parentLoadModelname; - } -} diff --git a/app/SaveProject.js b/app/SaveProject.js deleted file mode 100644 index 0e77adc..0000000 --- a/app/SaveProject.js +++ /dev/null @@ -1,100 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SaveProject = void 0; -const fs = require("fs"); -const path = require("node:path"); -const LoadModel_1 = require("./LoadModel"); -const ModelComponentType_1 = require("../src/app/game-model/ModelComponentType"); -const LoadedProject_1 = require("./LoadedProject"); -const RecursiveLoadModel_1 = require("./RecursiveLoadModel"); -class SaveProject { - static saveProject(projectDir, storageModels) { - 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) { - 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"); - const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); - console.log("LoadedGamesystems: ", loadedGamesystems.length); - return loadedGamesystems; - } - 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 7c010d3..0000000 --- a/app/SaveProject.ts +++ /dev/null @@ -1,110 +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"); - const loadedGamesystems = this.loadGamesystemsRecursively(gamesystemDir); - console.log("LoadedGamesystems: ", loadedGamesystems.length); - return loadedGamesystems; - } - - 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 af69ce5..f651a10 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 {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), @@ -94,11 +96,15 @@ 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) + deleteComponent(deletedComponent); + })*/ + const menuTemplate = [ { label: 'File', @@ -127,6 +133,10 @@ function createWindow(): BrowserWindow { const menu = Menu.buildFromTemplate(menuTemplate); Menu.setApplicationMenu(menu) + win.webContents.on('did-finish-load', () => { + loadDevProjectAtStart() + }) + return win; } @@ -160,6 +170,10 @@ try { }) }) + + + + } catch (e) { // Catch Error // throw e; @@ -179,13 +193,39 @@ function openProject() { }) if(selectedPaths != undefined) { - projectDirectory = selectedPaths[0]; - console.log("Open Project-Directory: ", projectDirectory) - const loadedProject = SaveProject.loadProject(projectDirectory) - win!.webContents.send("open-project", loadedProject) + openProjectFromFile(selectedPaths[0]) } } +function loadDevProjectAtStart() { + const projectDir = path.join(process.cwd(), "testModel/") + openProjectFromFile(projectDir) +} + +function openProjectFromFile(openProjectDir: string) { + projectDirectory = openProjectDir + const gameModelLoader = new GameModelLoader(openProjectDir); + const loadedProject = gameModelLoader.loadGameModel(); + win!.webContents.send("open-project", loadedProject) +} + 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) + + const gamesystemStorage = new GamesystemStorage(path.join(projectDirectory, ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME)) + gamesystemStorage.storeGamesystems(gameModel.storedGamesystems) +} + +/*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.js b/app/storage/FileUtils.js new file mode 100644 index 0000000..55d504f --- /dev/null +++ b/app/storage/FileUtils.js @@ -0,0 +1,34 @@ +"use strict"; +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()) { + return fs.readdirSync(directory).map(fileName => path.join(directory, fileName)); + } + else { + return []; + } + } + static prepareFileForWriting(file) { + const parentDirectory = path.dirname(file); + if (!fs.existsSync(parentDirectory)) { + (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 new file mode 100644 index 0000000..cfab96a --- /dev/null +++ b/app/storage/FileUtils.ts @@ -0,0 +1,33 @@ +import * as fs from "fs"; +import * as path from "node:path"; +import {mkdirSync} from "fs"; +import {lstatSync} from "node:fs"; + + +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 []; + } + } + + public static prepareFileForWriting(file: string) { + const parentDirectory = path.dirname(file) + + if(!fs.existsSync(parentDirectory)) { + 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/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/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.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/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.js b/app/storage/StoredGameModel.js new file mode 100644 index 0000000..126a61b --- /dev/null +++ b/app/storage/StoredGameModel.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StoredGameModel = void 0; +class StoredGameModel { + constructor(gameModelName, storedScriptAccounts, storedGamesystems) { + this.gameModelName = gameModelName; + this.storedGamesystems = storedGamesystems; + this.storedScriptAccounts = storedScriptAccounts; + } +} +exports.StoredGameModel = StoredGameModel; +//# sourceMappingURL=StoredGameModel.js.map \ No newline at end of file diff --git a/app/storage/StoredGameModel.ts b/app/storage/StoredGameModel.ts new file mode 100644 index 0000000..8edfee0 --- /dev/null +++ b/app/storage/StoredGameModel.ts @@ -0,0 +1,15 @@ +import {StoreComponent} from "./StoreComponent"; + +export class StoredGameModel { + gameModelName: string + + storedGamesystems: StoreComponent[] + storedScriptAccounts: StoreComponent[] + + + constructor(gameModelName: string, storedScriptAccounts: StoreComponent[], storedGamesystems: StoreComponent[]) { + this.gameModelName = gameModelName; + this.storedGamesystems = storedGamesystems; + this.storedScriptAccounts = storedScriptAccounts; + } +} diff --git a/app/storage/loader/GameModelLoader.js b/app/storage/loader/GameModelLoader.js new file mode 100644 index 0000000..7139cc9 --- /dev/null +++ b/app/storage/loader/GameModelLoader.js @@ -0,0 +1,31 @@ +"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"); +const GamesystemLoader_1 = require("./GamesystemLoader"); +class GameModelLoader { + constructor(gameModelDir) { + this.gameModelDir = gameModelDir; + } + loadGameModel() { + const gameModelName = path.basename(this.gameModelDir); + 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); + const scriptAccountLoader = new ScriptAccountLoader_1.ScriptAccountLoader(scriptAccountDir); + return scriptAccountLoader.loadScriptAccounts(); + } + loadGamesystems() { + 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; +//# sourceMappingURL=GameModelLoader.js.map \ No newline at end of file diff --git a/app/storage/loader/GameModelLoader.ts b/app/storage/loader/GameModelLoader.ts new file mode 100644 index 0000000..bcbfa63 --- /dev/null +++ b/app/storage/loader/GameModelLoader.ts @@ -0,0 +1,42 @@ +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"; +import {GamesystemLoader} from "./GamesystemLoader"; + +export class GameModelLoader { + gameModelDir: string + + + constructor(gameModelDir: string) { + this.gameModelDir = gameModelDir; + } + + loadGameModel(): StoredGameModel { + const gameModelName = path.basename(this.gameModelDir) + + const storedScriptAccounts = this.loadScriptAccountComponents(); + const storedGamesystems = this.loadGamesystems(); + + return new StoredGameModel(gameModelName, storedScriptAccounts, storedGamesystems); + } + + private loadScriptAccountComponents() { + const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME); + const scriptAccountLoader = new ScriptAccountLoader(scriptAccountDir); + return scriptAccountLoader.loadScriptAccounts() + } + + private loadGamesystems(): StoreComponent[] { + 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.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/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/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/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/app/storage/storing/GamesystemStorage.js b/app/storage/storing/GamesystemStorage.js new file mode 100644 index 0000000..003890e --- /dev/null +++ b/app/storage/storing/GamesystemStorage.js @@ -0,0 +1,57 @@ +"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) { + const unreferencedFiles = this.detectUnusedGamesystemFiles(gamesystems); + FileUtils_1.FileUtils.removeFiles(unreferencedFiles); + gamesystems.forEach(gamesystem => this.storeGamesystem(gamesystem)); + } + 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 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); + } + } + } + } + if (fs.lstatSync(currentGamesystemFile).isDirectory()) { + gamesystemFiles.push(...FileUtils_1.FileUtils.listFilesInDirectory(currentGamesystemFile)); + } + } + return unreferencedFiles; + } + findReferencedGamesystem(referencedName, gamesystems) { + return gamesystems.find(gamesystem => path.basename(gamesystem.fileName) === referencedName); + } + storeGamesystem(gamesystem) { + const gamesystemFile = path.join(...gamesystem.fileName.split("/")); + 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..c414f65 --- /dev/null +++ b/app/storage/storing/GamesystemStorage.ts @@ -0,0 +1,64 @@ +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[]) { + const unreferencedFiles = this.detectUnusedGamesystemFiles(gamesystems) + FileUtils.removeFiles(unreferencedFiles) + gamesystems.forEach(gamesystem => this.storeGamesystem(gamesystem)) + } + + 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 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!) + } + } + } + } + + 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("/")) + const completeGamesystemFile = path.join(this.gamesystemRootDir, gamesystemFile) + FileUtils.prepareFileForWriting(completeGamesystemFile) + fs.writeFileSync(completeGamesystemFile + ".json", gamesystem.jsonString, 'utf-8') + } +} 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/e2e/game-model/AddingGamesystems.spec.ts b/e2e/game-model/AddingGamesystems.spec.ts index 4d65fd0..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/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('Adding Gamesystems', () => { diff --git a/e2e/game-model/RemovingGamesystems.spec.ts b/e2e/game-model/RemovingGamesystems.spec.ts index e5777fe..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/game-model/GameModel"; -import {Gamesystem} from "../../src/app/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 84e01c5..fffea92 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/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 879717b..095432d 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/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 515882e..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/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/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/SimpleGamesystem.spec.ts b/e2e/game-model/gamesystems/SimpleGamesystem.spec.ts index 4c61efd..a47f181 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"; +import {SimpleGamesystem} from "../../../src/app/project/game-model/gamesystems/SimpleGamesystem"; test.describe('Test SimpleGamesystem', () => { 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..19ea15e --- /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/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 => { + 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..40cd9a4 --- /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/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 () => { + 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..1e0b7d3 --- /dev/null +++ b/e2e/game-model/gamesystems/actions/SimpleActionTrainer.ts @@ -0,0 +1,25 @@ +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/project/game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountAction} from "../../../../src/app/project/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/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts b/e2e/game-model/gamesystems/conditions/AddTransitionConditions.spec.ts new file mode 100644 index 0000000..5cb1797 --- /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/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"; +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/ConditionContradicting.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionContradicting.spec.ts new file mode 100644 index 0000000..d71e5ef --- /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/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"; +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/ConditionCreation.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionCreation.spec.ts new file mode 100644 index 0000000..112de84 --- /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/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', () => { + + 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/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts b/e2e/game-model/gamesystems/conditions/ConditionExpansion.spec.ts new file mode 100644 index 0000000..bd5b2cb --- /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/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', () => { + + 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 new file mode 100644 index 0000000..47718d3 --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/ConditionTrainer.ts @@ -0,0 +1,17 @@ +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 { + const scriptAccount = new ScriptAccount("Test", ""); + return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10); + } + + 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..7c94d20 --- /dev/null +++ b/e2e/game-model/gamesystems/conditions/TransitionConditionTrainer.ts @@ -0,0 +1,24 @@ +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", ""); + 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/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/CreateProductStates.spec.ts index 3ee77ef..0e35828 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/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 fc7dcab..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/game-model/gamesystems/ProductState"; -import {SimpleGamesystem} from "../../../../src/app/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/EqualInnerStates.spec.ts b/e2e/game-model/gamesystems/productGamesystems/EqualInnerStates.spec.ts index 1b6415e..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/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..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/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..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/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 {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 aa34557..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/game-model/gamesystems/ProductGamesystem"; -import {SimpleGamesystem} from "../../../../src/app/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 00688ac..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/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/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', () => { diff --git a/src/app/app.component.html b/src/app/app.component.html index 85d1f15..2801b21 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@