From b2b4b936cd79a978640ac8965f889e4ce729db51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 11:58:31 +0200 Subject: [PATCH 01/26] Introduce new TemplateType: Character-Relation --- app/main.ts | 6 ++ .../game-model/templates/TemplateType.ts | 3 +- .../templates/TemplateTypeUtilities.ts | 2 + testModel/characters/Astrid Hofferson.json | 47 +---------- testModel/characters/Hicks Haddock.json | 57 +------------ testModel/gamesystems/NormalGamesystem.json | 6 -- .../gamesystems/Producttest/Letters.json | 27 ------- .../gamesystems/Producttest/Numbers.json | 26 ------ .../gamesystems/Producttest/Producttest.json | 13 --- testModel/gamesystems/TemplateGamesystem.json | 50 ------------ testModel/gamesystems/Testsystem.json | 37 --------- .../gamesystems/Weathersystem/Season.json | 80 ------------------- .../gamesystems/Weathersystem/Weather.json | 80 ------------------- .../Weathersystem/Weathersystem.json | 12 --- .../script-accounts/Luftfeuchtigkeit.json | 6 -- .../script-accounts/New ScriptAccount.json | 6 -- testModel/script-accounts/Temperature.json | 6 -- 17 files changed, 12 insertions(+), 452 deletions(-) delete mode 100644 testModel/gamesystems/NormalGamesystem.json delete mode 100644 testModel/gamesystems/Producttest/Letters.json delete mode 100644 testModel/gamesystems/Producttest/Numbers.json delete mode 100644 testModel/gamesystems/Producttest/Producttest.json delete mode 100644 testModel/gamesystems/TemplateGamesystem.json delete mode 100644 testModel/gamesystems/Testsystem.json delete mode 100644 testModel/gamesystems/Weathersystem/Season.json delete mode 100644 testModel/gamesystems/Weathersystem/Weather.json delete mode 100644 testModel/gamesystems/Weathersystem/Weathersystem.json delete mode 100644 testModel/script-accounts/Luftfeuchtigkeit.json delete mode 100644 testModel/script-accounts/New ScriptAccount.json delete mode 100644 testModel/script-accounts/Temperature.json diff --git a/app/main.ts b/app/main.ts index 449ef21..ba1a8b6 100644 --- a/app/main.ts +++ b/app/main.ts @@ -76,6 +76,12 @@ function createWindow(): BrowserWindow { click: () => { win!.webContents.send('context-menu', "new-gamesystem-character"); } + }, + { + label: "Character-Relation", + click: () => { + win!.webContents.send('context-menu', "new-gamesystem-character_relation"); + } } ] }, diff --git a/src/app/project/game-model/templates/TemplateType.ts b/src/app/project/game-model/templates/TemplateType.ts index 6961052..f8318e7 100644 --- a/src/app/project/game-model/templates/TemplateType.ts +++ b/src/app/project/game-model/templates/TemplateType.ts @@ -1,3 +1,4 @@ export enum TemplateType { - CHARACTER + CHARACTER, + CHARACTER_RELATION } diff --git a/src/app/project/game-model/templates/TemplateTypeUtilities.ts b/src/app/project/game-model/templates/TemplateTypeUtilities.ts index 7efc792..837b610 100644 --- a/src/app/project/game-model/templates/TemplateTypeUtilities.ts +++ b/src/app/project/game-model/templates/TemplateTypeUtilities.ts @@ -4,6 +4,8 @@ export class TemplateTypeUtilities { static fromString(string: string) { if(string === 'character') { return TemplateType.CHARACTER + } else if(string === 'character_relation') { + return TemplateType.CHARACTER_RELATION } } } diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json index 014ec69..9437d7c 100644 --- a/testModel/characters/Astrid Hofferson.json +++ b/testModel/characters/Astrid Hofferson.json @@ -1,50 +1,5 @@ { "componentName": "Astrid Hofferson", "componentDescription": "", - "characterSpecificTemplateSystems": [ - { - "componentName": "TemplateGamesystem", - "states": [ - { - "stateLabel": "A", - "conditionMap": [ - { - "scriptAccount": "Luftfeuchtigkeit", - "minValue": 0, - "maxValue": "10" - } - ] - }, - { - "stateLabel": "B", - "conditionMap": [ - { - "scriptAccount": "New ScriptAccount", - "minValue": 0, - "maxValue": 100 - } - ] - } - ], - "transitions": [ - { - "startingState": "A", - "endingState": "B", - "conditionMap": [ - { - "scriptAccount": "Temperature", - "minValue": 0, - "maxValue": 10 - } - ], - "actionMap": [ - { - "changingValue": 10, - "scriptAccount": "Luftfeuchtigkeit" - } - ] - } - ] - } - ] + "characterSpecificTemplateSystems": [] } \ No newline at end of file diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 158b912..1f75bd9 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -1,60 +1,5 @@ { "componentName": "Hicks Haddock", "componentDescription": "", - "characterSpecificTemplateSystems": [ - { - "componentName": "TemplateGamesystem", - "states": [ - { - "stateLabel": "A", - "conditionMap": [ - { - "scriptAccount": "Luftfeuchtigkeit", - "minValue": 0, - "maxValue": "10" - } - ] - }, - { - "stateLabel": "B", - "conditionMap": [ - { - "scriptAccount": "New ScriptAccount", - "minValue": 0, - "maxValue": 100 - } - ] - } - ], - "transitions": [ - { - "startingState": "A", - "endingState": "B", - "conditionMap": [], - "actionMap": [] - } - ] - }, - { - "componentName": "Letters", - "states": [ - { - "stateLabel": "A", - "conditionMap": [] - }, - { - "stateLabel": "B", - "conditionMap": [] - } - ], - "transitions": [ - { - "startingState": "A", - "endingState": "B", - "conditionMap": [], - "actionMap": [] - } - ] - } - ] + "characterSpecificTemplateSystems": [] } \ No newline at end of file diff --git a/testModel/gamesystems/NormalGamesystem.json b/testModel/gamesystems/NormalGamesystem.json deleted file mode 100644 index 7525520..0000000 --- a/testModel/gamesystems/NormalGamesystem.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "componentName": "NormalGamesystem", - "componentDescription": "", - "states": [], - "transitions": [] -} \ No newline at end of file diff --git a/testModel/gamesystems/Producttest/Letters.json b/testModel/gamesystems/Producttest/Letters.json deleted file mode 100644 index 9bab958..0000000 --- a/testModel/gamesystems/Producttest/Letters.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "componentName": "Letters", - "componentDescription": "", - "states": [ - { - "initial": false, - "conditions": [], - "stateLabel": "A", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [], - "stateLabel": "B", - "stateDescription": "" - } - ], - "transitions": [ - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "A", - "endingState": "B" - } - ], - "templateType": 0 -} \ No newline at end of file diff --git a/testModel/gamesystems/Producttest/Numbers.json b/testModel/gamesystems/Producttest/Numbers.json deleted file mode 100644 index 89f1e28..0000000 --- a/testModel/gamesystems/Producttest/Numbers.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "componentName": "Numbers", - "componentDescription": "", - "states": [ - { - "initial": false, - "conditions": [], - "stateLabel": "1", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [], - "stateLabel": "2", - "stateDescription": "" - } - ], - "transitions": [ - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "1", - "endingState": "2" - } - ] -} \ No newline at end of file diff --git a/testModel/gamesystems/Producttest/Producttest.json b/testModel/gamesystems/Producttest/Producttest.json deleted file mode 100644 index 239e216..0000000 --- a/testModel/gamesystems/Producttest/Producttest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "componentName": "Producttest", - "componentDescription": "", - "childsystems": [ - { - "componentName": "Letters" - }, - { - "componentName": "Numbers" - } - ], - "templateType": 0 -} \ No newline at end of file diff --git a/testModel/gamesystems/TemplateGamesystem.json b/testModel/gamesystems/TemplateGamesystem.json deleted file mode 100644 index 0a1da3d..0000000 --- a/testModel/gamesystems/TemplateGamesystem.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "componentName": "TemplateGamesystem", - "componentDescription": "", - "states": [ - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Luftfeuchtigkeit", - "minValue": 0, - "maxValue": "10" - } - ], - "stateLabel": "A", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "New ScriptAccount", - "minValue": 0, - "maxValue": 100 - } - ], - "stateLabel": "B", - "stateDescription": "" - } - ], - "transitions": [ - { - "scriptAccountActions": [ - { - "changingValue": 10, - "scriptAccount": "Luftfeuchtigkeit" - } - ], - "scriptAccountConditions": [ - { - "scriptAccount": "Temperature", - "minValue": 0, - "maxValue": 10 - } - ], - "startingState": "A", - "endingState": "B" - } - ], - "templateType": 0 -} \ No newline at end of file diff --git a/testModel/gamesystems/Testsystem.json b/testModel/gamesystems/Testsystem.json deleted file mode 100644 index 654df19..0000000 --- a/testModel/gamesystems/Testsystem.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "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/Season.json b/testModel/gamesystems/Weathersystem/Season.json deleted file mode 100644 index a815ccb..0000000 --- a/testModel/gamesystems/Weathersystem/Season.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "componentName": "Season", - "componentDescription": "Ein simples Gamesystem zur Modellierung verschiedener Jahreszeiten und deren Übergänge", - "states": [ - { - "initial": true, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": 0, - "maxValue": "10" - } - ], - "stateLabel": "Frühling", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": "10", - "maxValue": "30" - } - ], - "stateLabel": "Sommer", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": "10", - "maxValue": "20" - } - ], - "stateLabel": "Herbst", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": "-10", - "maxValue": "10" - } - ], - "stateLabel": "Winter", - "stateDescription": "" - } - ], - "transitions": [ - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Frühling", - "endingState": "Sommer" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Sommer", - "endingState": "Herbst" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Herbst", - "endingState": "Winter" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Winter", - "endingState": "Frühling" - } - ] -} \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Weather.json b/testModel/gamesystems/Weathersystem/Weather.json deleted file mode 100644 index b9de825..0000000 --- a/testModel/gamesystems/Weathersystem/Weather.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "componentName": "Weather", - "componentDescription": "A small Gamesystem about local weather events", - "states": [ - { - "initial": true, - "conditions": [], - "stateLabel": "Sonne", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": 0, - "maxValue": "30" - } - ], - "stateLabel": "Regen", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [], - "stateLabel": "Wolke", - "stateDescription": "" - }, - { - "initial": false, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": "-5", - "maxValue": 0 - } - ], - "stateLabel": "Schnee", - "stateDescription": "" - } - ], - "transitions": [ - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Sonne", - "endingState": "Wolke" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Wolke", - "endingState": "Sonne" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Wolke", - "endingState": "Regen" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Regen", - "endingState": "Wolke" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Wolke", - "endingState": "Schnee" - }, - { - "scriptAccountActions": [], - "scriptAccountConditions": [], - "startingState": "Schnee", - "endingState": "Wolke" - } - ] -} \ No newline at end of file diff --git a/testModel/gamesystems/Weathersystem/Weathersystem.json b/testModel/gamesystems/Weathersystem/Weathersystem.json deleted file mode 100644 index b9abfec..0000000 --- a/testModel/gamesystems/Weathersystem/Weathersystem.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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 diff --git a/testModel/script-accounts/Luftfeuchtigkeit.json b/testModel/script-accounts/Luftfeuchtigkeit.json deleted file mode 100644 index b4593b2..0000000 --- a/testModel/script-accounts/Luftfeuchtigkeit.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "componentName": "Luftfeuchtigkeit", - "componentDescription": "", - "minValue": 0, - "maxValue": 100 -} \ No newline at end of file diff --git a/testModel/script-accounts/New ScriptAccount.json b/testModel/script-accounts/New ScriptAccount.json deleted file mode 100644 index c4a4176..0000000 --- a/testModel/script-accounts/New ScriptAccount.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "componentName": "New ScriptAccount", - "componentDescription": "", - "minValue": 0, - "maxValue": 100 -} \ No newline at end of file diff --git a/testModel/script-accounts/Temperature.json b/testModel/script-accounts/Temperature.json deleted file mode 100644 index 91a3a6c..0000000 --- a/testModel/script-accounts/Temperature.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "componentName": "Temperature", - "componentDescription": "", - "minValue": -30, - "maxValue": 50 -} \ No newline at end of file From 26db5392a4df11ac5ca2ca653950d0563699f622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 12:32:31 +0200 Subject: [PATCH 02/26] Introduce Concept of Character-Relations --- .../character-editor.component.html | 9 +++++++++ src/app/project/game-model/GameModel.ts | 10 ++++++++++ src/app/project/game-model/characters/Character.ts | 7 +++++++ .../game-model/characters/CharacterRelation.ts | 14 ++++++++++++++ .../parser/characterParser/CharacterParser.ts | 13 +++++++++++-- 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/app/project/game-model/characters/CharacterRelation.ts diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index b13fddf..b860b2f 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -14,3 +14,12 @@ + + + + Character-Relations + + +

{{characterRelation.firstCharacter.componentName}} - {{characterRelation.secondCharacter.componentName}}

+
+
diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index b59445a..1089ccc 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -10,6 +10,7 @@ import {TemplateType} from "./templates/TemplateType"; import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem"; import {ProductTemplateSystem} from "./templates/productGamesystem/ProductTemplateSystem"; import {ProductTemplateCreator} from "./templates/productGamesystem/ProductTemplateCreator"; +import {CharacterRelation} from "./characters/CharacterRelation"; export class GameModel { gameModelName: string @@ -127,12 +128,21 @@ export class GameModel { const searchedCharacter = this.characters.find(character => character.componentName === characterName); if(searchedCharacter == undefined) { const character = new Character(characterName, ""); + this.createCharacterRelation(character) this.characters.push(character) return character } return undefined } + private createCharacterRelation(addedCharacter: Character) { + this.characters.forEach(character => { + const characterRelation = new CharacterRelation(character, addedCharacter); + character.addCharacterRelation(characterRelation); + addedCharacter.addCharacterRelation(characterRelation); + }) + } + removeScriptAccount(scriptAccount: ScriptAccount) { if(scriptAccount != undefined) { this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount); diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 4d9bf6c..a8b0bd7 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -6,11 +6,14 @@ import {Gamesystem} from "../gamesystems/Gamesystem"; import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; import {ProductGamesystem} from "../gamesystems/ProductGamesystem"; +import {CharacterRelation} from "./CharacterRelation"; export class Character extends ModelComponent implements TemplateElement { characterSpecificTemplateSystems: Gamesystem[] = [] + characterRelations: CharacterRelation[] = [] + constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); } @@ -36,6 +39,10 @@ export class Character extends ModelComponent implements TemplateElement { } } + addCharacterRelation(characterRelation: CharacterRelation) { + this.characterRelations.push(characterRelation) + } + private isTemplateSystemCharacterSpecific(gamesystemName: string) { return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined } diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts new file mode 100644 index 0000000..b54e4f9 --- /dev/null +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -0,0 +1,14 @@ +import {TemplateElement} from "../templates/TemplateElement"; +import {Character} from "./Character"; + +export class CharacterRelation implements TemplateElement{ + + firstCharacter: Character + secondCharacter: Character + + + constructor(firstCharacter: Character, secondCharacter: Character) { + this.firstCharacter = firstCharacter; + this.secondCharacter = secondCharacter; + } +} diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index 0570861..f980445 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -6,6 +6,8 @@ import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountCon import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/SimpleTemplateState"; import {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition"; +import {CharacterRelation} from "../../game-model/characters/CharacterRelation"; +import {load} from "@angular-devkit/build-angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks"; export class CharacterParser { @@ -23,12 +25,19 @@ export class CharacterParser { public parseCharacters(characters: StoreComponent[]): Character[] { const loadedCharacters: Character[] = [] - characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString)))) + characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString), loadedCharacters))) return loadedCharacters; } - private parseSingleCharacter(characterData: any): Character { + private parseSingleCharacter(characterData: any, loadedCharacters: Character[]): Character { const character = new Character(characterData.componentName, characterData.componentDescription); + + loadedCharacters.forEach(loadedCharacter => { + const characterRelation = new CharacterRelation(loadedCharacter, character); + loadedCharacter.addCharacterRelation(characterRelation) + character.addCharacterRelation(characterRelation) + }) + const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems); templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system)) return character; From 93498845ec9debcfb690553e9769eaaffb0734b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 12:52:20 +0200 Subject: [PATCH 03/26] Add Character-Relation-Specific Gamesystems --- .../character-editor.component.html | 18 +++++++ .../character-editor.component.ts | 8 +++ .../game-model/characters/Character.ts | 14 +++++ .../Characterbeziehungssystem.json | 51 +++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 testModel/gamesystems/Characterbeziehungssystem.json diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index b860b2f..358ad58 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -15,6 +15,24 @@ + + + Characterrelationspecifc Gamesystems + + + + + + {{templateSystem.componentName}} + + + + + + + + + Character-Relations diff --git a/src/app/editor/character-editor/character-editor.component.ts b/src/app/editor/character-editor/character-editor.component.ts index 72bd256..9c1a072 100644 --- a/src/app/editor/character-editor/character-editor.component.ts +++ b/src/app/editor/character-editor/character-editor.component.ts @@ -29,4 +29,12 @@ export class CharacterEditorComponent { }) } + openCharacterRelationTemplateSpecificator() { + const dialogRef = this.dialog.open(TemplateSpecificatorComponent, {data: this.gameModel!.getTemplateSystems(TemplateType.CHARACTER_RELATION), minWidth: "400px"}); + dialogRef.afterClosed().subscribe(res => { + if(res != undefined) { + this.character!.addAsymetricCharacterRelationGamesystem(res); + } + }) + } } diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index a8b0bd7..af8173e 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -14,6 +14,8 @@ export class Character extends ModelComponent implements TemplateElement { characterRelations: CharacterRelation[] = [] + assymetricCharacterRelationSpecificTemplateSystems: Gamesystem[] = [] + constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); } @@ -39,6 +41,12 @@ export class Character extends ModelComponent implements TemplateElement { } } + addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem, recursiveCall: boolean = false) { + if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) { + this.assymetricCharacterRelationSpecificTemplateSystems.push(gamesystem) + } + } + addCharacterRelation(characterRelation: CharacterRelation) { this.characterRelations.push(characterRelation) } @@ -47,4 +55,10 @@ export class Character extends ModelComponent implements TemplateElement { return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined } + private isTemplateSystemCharacterRelationSpecific(gamesystemName: string) { + return this.assymetricCharacterRelationSpecificTemplateSystems.find(gamesystem => + gamesystem.componentName === gamesystemName) != undefined; + + } + } diff --git a/testModel/gamesystems/Characterbeziehungssystem.json b/testModel/gamesystems/Characterbeziehungssystem.json new file mode 100644 index 0000000..66d038b --- /dev/null +++ b/testModel/gamesystems/Characterbeziehungssystem.json @@ -0,0 +1,51 @@ +{ + "componentName": "Characterbeziehungssystem", + "componentDescription": "", + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "Feind", + "stateDescription": "" + }, + { + "initial": true, + "conditions": [], + "stateLabel": "Freund", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "Fester Freund", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "Feind", + "endingState": "Freund" + }, + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "Freund", + "endingState": "Feind" + }, + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "Freund", + "endingState": "Fester Freund" + }, + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "Fester Freund", + "endingState": "Feind" + } + ], + "templateType": 1 +} \ No newline at end of file From 6a711ec579a7a1f79c612d878ac6fa538eb788c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 13:49:01 +0200 Subject: [PATCH 04/26] Add Character as TemplateElement to added character-relation specific assymetric gamesystems --- .../project/game-model/characters/Character.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index af8173e..cba8e91 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -43,7 +43,22 @@ export class Character extends ModelComponent implements TemplateElement { addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem, recursiveCall: boolean = false) { if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) { - this.assymetricCharacterRelationSpecificTemplateSystems.push(gamesystem) + if(gamesystem instanceof SimpleTemplateGamesystem) { + this.assymetricCharacterRelationSpecificTemplateSystems.push(gamesystem); + gamesystem.addTemplateElement(this); + } else if(gamesystem instanceof ProductTemplateSystem) { + this.characterSpecificTemplateSystems.push(gamesystem); + gamesystem.addTemplateElement(this); + + if(!recursiveCall) { + gamesystem.innerGamesystems.forEach(innerGamesystem => this.addAsymetricCharacterRelationGamesystem(innerGamesystem, true)) + } + } + + if(gamesystem.parentGamesystem != undefined) { + this.addAsymetricCharacterRelationGamesystem(gamesystem.parentGamesystem, true) + } + } } From fee41efb217b1283148e87e94b96e03a3369d495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 14:23:17 +0200 Subject: [PATCH 05/26] Serialize and Load Character-Relation Specific Gamesystems --- src/app/app.component.ts | 3 +- .../game-model/characters/Character.ts | 13 +++-- .../parser/characterParser/CharacterParser.ts | 22 +++++---- .../project/serializer/CharacterSerializer.ts | 2 +- testModel/characters/Astrid Hofferson.json | 3 +- testModel/characters/Hicks Haddock.json | 47 ++++++++++++++++++- 6 files changed, 74 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6b962e0..3ad2831 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -219,7 +219,8 @@ export class AppComponent implements OnInit{ gameModel.generateProductSystemContents() const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem) - const characterParser = new CharacterParser(characterTemplateSystems, gameModel.scriptAccounts); + const characterRelationTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER_RELATION).map(templateSystem => templateSystem as SimpleTemplateGamesystem) + const characterParser = new CharacterParser(characterTemplateSystems, characterRelationTemplateSystems, gameModel.scriptAccounts); gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters) this.gameModel = gameModel; diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index cba8e91..411abf6 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -14,7 +14,7 @@ export class Character extends ModelComponent implements TemplateElement { characterRelations: CharacterRelation[] = [] - assymetricCharacterRelationSpecificTemplateSystems: Gamesystem[] = [] + characterRelationGamesystems: Gamesystem[] = [] constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); @@ -44,10 +44,12 @@ export class Character extends ModelComponent implements TemplateElement { addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem, recursiveCall: boolean = false) { if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) { if(gamesystem instanceof SimpleTemplateGamesystem) { - this.assymetricCharacterRelationSpecificTemplateSystems.push(gamesystem); + this.characterRelationGamesystems.push(gamesystem); gamesystem.addTemplateElement(this); + console.log("Should have been added") + console.log(this.characterRelationGamesystems) } else if(gamesystem instanceof ProductTemplateSystem) { - this.characterSpecificTemplateSystems.push(gamesystem); + this.characterRelationGamesystems.push(gamesystem); gamesystem.addTemplateElement(this); if(!recursiveCall) { @@ -59,6 +61,9 @@ export class Character extends ModelComponent implements TemplateElement { this.addAsymetricCharacterRelationGamesystem(gamesystem.parentGamesystem, true) } + } else { + console.log("Was already added") + console.log(this) } } @@ -71,7 +76,7 @@ export class Character extends ModelComponent implements TemplateElement { } private isTemplateSystemCharacterRelationSpecific(gamesystemName: string) { - return this.assymetricCharacterRelationSpecificTemplateSystems.find(gamesystem => + return this.characterRelationGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined; } diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index f980445..4e4e770 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -8,16 +8,19 @@ import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/S import {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition"; import {CharacterRelation} from "../../game-model/characters/CharacterRelation"; import {load} from "@angular-devkit/build-angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks"; +import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; export class CharacterParser { characterSpecificGamesystems: SimpleTemplateGamesystem[] + characterRelationSpecificGamesystems: SimpleTemplateGamesystem[] scriptAccountConditionParser: ScriptAccountConditionParser scriptAccountActionParser: ScriptAccountActionParser - constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) { + constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], characterRelationSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) { this.characterSpecificGamesystems = characterSpecificGamesystems; + this.characterRelationSpecificGamesystems = characterRelationSpecificGamesystems; this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts); this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts) } @@ -38,23 +41,26 @@ export class CharacterParser { character.addCharacterRelation(characterRelation) }) - const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems); + const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems, this.characterSpecificGamesystems); templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system)) + + const characterRelationGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterRelationGamesystems, this.characterRelationSpecificGamesystems) + characterRelationGamesystems.forEach(gamesystem => character.addAsymetricCharacterRelationGamesystem(gamesystem)) return character; } - private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem[] { + private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem[] { const result: SimpleTemplateGamesystem[] = [] for(let i=0; i gamesystem.componentName === componentName) + private findCharacterSpecificGamesystem(gamesystems: SimpleTemplateGamesystem[], componentName: string): SimpleTemplateGamesystem | undefined{ + return gamesystems.find(gamesystem => gamesystem.componentName === componentName) } private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) { diff --git a/src/app/project/serializer/CharacterSerializer.ts b/src/app/project/serializer/CharacterSerializer.ts index bc0d21e..600d065 100644 --- a/src/app/project/serializer/CharacterSerializer.ts +++ b/src/app/project/serializer/CharacterSerializer.ts @@ -7,7 +7,7 @@ import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; export class CharacterSerializer { - private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions'] + private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions', 'characterRelations'] public static serializeCharacters(characters: Character[]): StoreComponent[] { const storedCharacters: StoreComponent[] = [] diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json index 9437d7c..21cfeca 100644 --- a/testModel/characters/Astrid Hofferson.json +++ b/testModel/characters/Astrid Hofferson.json @@ -1,5 +1,6 @@ { "componentName": "Astrid Hofferson", "componentDescription": "", - "characterSpecificTemplateSystems": [] + "characterSpecificTemplateSystems": [], + "characterRelationGamesystems": [] } \ No newline at end of file diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 1f75bd9..414d072 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -1,5 +1,50 @@ { "componentName": "Hicks Haddock", "componentDescription": "", - "characterSpecificTemplateSystems": [] + "characterSpecificTemplateSystems": [], + "characterRelationGamesystems": [ + { + "componentName": "Characterbeziehungssystem", + "states": [ + { + "stateLabel": "Feind", + "conditionMap": [] + }, + { + "stateLabel": "Freund", + "conditionMap": [] + }, + { + "stateLabel": "Fester Freund", + "conditionMap": [] + } + ], + "transitions": [ + { + "startingState": "Feind", + "endingState": "Freund", + "conditionMap": [], + "actionMap": [] + }, + { + "startingState": "Freund", + "endingState": "Feind", + "conditionMap": [], + "actionMap": [] + }, + { + "startingState": "Freund", + "endingState": "Fester Freund", + "conditionMap": [], + "actionMap": [] + }, + { + "startingState": "Fester Freund", + "endingState": "Feind", + "conditionMap": [], + "actionMap": [] + } + ] + } + ] } \ No newline at end of file From 5074396f888eb0d1e76bd8e9a1b07e100cc86be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 14:24:00 +0200 Subject: [PATCH 06/26] Fix wrong reference to characterRelationGamesystems --- src/app/editor/character-editor/character-editor.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index 358ad58..eefda53 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -21,7 +21,7 @@ - + {{templateSystem.componentName}} From 448ff5bd1bf9dcf1670c97cd57498faff91b0230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 14:46:02 +0200 Subject: [PATCH 07/26] Add CharacterRelation Gamesystems to CharacterRelation and adjust ProductGeneration --- .../game-model/characters/Character.ts | 8 +++-- .../characters/CharacterRelation.ts | 18 +++++++++++ .../ProductSystemGenerator.ts | 32 +++++++++---------- .../TemplateProductSystemGenerator.ts | 31 ++++++++++++------ 4 files changed, 62 insertions(+), 27 deletions(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 411abf6..51ec902 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -46,11 +46,15 @@ export class Character extends ModelComponent implements TemplateElement { if(gamesystem instanceof SimpleTemplateGamesystem) { this.characterRelationGamesystems.push(gamesystem); gamesystem.addTemplateElement(this); - console.log("Should have been added") - console.log(this.characterRelationGamesystems) + this.characterRelations.forEach(characterRelation => { + characterRelation.addCharacterRelationSystem(gamesystem) + }) } else if(gamesystem instanceof ProductTemplateSystem) { this.characterRelationGamesystems.push(gamesystem); gamesystem.addTemplateElement(this); + this.characterRelations.forEach(characterRelation => { + characterRelation.addCharacterRelationSystem(gamesystem) + }) if(!recursiveCall) { gamesystem.innerGamesystems.forEach(innerGamesystem => this.addAsymetricCharacterRelationGamesystem(innerGamesystem, true)) diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts index b54e4f9..e5a5d96 100644 --- a/src/app/project/game-model/characters/CharacterRelation.ts +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -1,14 +1,32 @@ import {TemplateElement} from "../templates/TemplateElement"; import {Character} from "./Character"; +import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; +import {Gamesystem} from "../gamesystems/Gamesystem"; +import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {TemplateType} from "../templates/TemplateType"; export class CharacterRelation implements TemplateElement{ firstCharacter: Character secondCharacter: Character + characterRelationGamesystems: ProductTemplateSystem[] = [] constructor(firstCharacter: Character, secondCharacter: Character) { this.firstCharacter = firstCharacter; this.secondCharacter = secondCharacter; } + + addCharacterRelationSystem(gamesystem: Gamesystem) { + if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) { + const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION); + templateGamesystem.addChildGamesystem(gamesystem); + templateGamesystem.addChildGamesystem(gamesystem); + this.characterRelationGamesystems.push(templateGamesystem); + } + } + + private isGamesystemCharacterRelationSpecific(gamesystemName: string) { + return this.characterRelationGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined + } } diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts index 816533b..aa667a1 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts @@ -59,12 +59,12 @@ export class ProductSystemGenerator { if(startingState != undefined) { const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates); if(endingState_right != undefined) { - this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions); + this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions, false); } const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates); if(endingState_left != undefined) { - this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i], generatedProductTransitions) + this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i], generatedProductTransitions, true) } const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates); @@ -79,7 +79,7 @@ export class ProductSystemGenerator { const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates); if(startingState != undefined && endingState != undefined) { - this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions) + this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions, true) } } @@ -91,7 +91,7 @@ export class ProductSystemGenerator { const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates); if(startingState != undefined && endingState != undefined) { - this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions); + this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions, false); } @@ -108,10 +108,10 @@ export class ProductSystemGenerator { this.productGamesystem.transitions = generationResult.transitions; } - protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition, generatedTransitions: ProductTransition[]) { + protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition, generatedTransitions: ProductTransition[], leftSystem: boolean) { const transition = new ProductTransition(startingState, endingState); - transition.scriptAccountActions = [... this.getTransitionActions(usedTransition)]; - transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition)]; + transition.scriptAccountActions = [... this.getTransitionActions(usedTransition, leftSystem)]; + transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition, leftSystem)]; if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { generatedTransitions.push(transition) @@ -119,13 +119,13 @@ export class ProductSystemGenerator { } protected generateBinaryProductTransitionMulti(startingState: ProductState, endingState: ProductState, leftTransition: Transition, rightTransition: Transition, generatedTransitions: ProductTransition[]) { - const leftConditions = this.getTransitionConditions(leftTransition) - const rightConditions = this.getTransitionConditions(rightTransition) + const leftConditions = this.getTransitionConditions(leftTransition, true) + const rightConditions = this.getTransitionConditions(rightTransition, false) if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { const transition = new ProductTransition(startingState, endingState) - transition.scriptAccountActions = this.generateCombinedActions(this.getTransitionActions(leftTransition), this.getTransitionActions(rightTransition)); - transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition), this.getTransitionConditions(rightTransition)); + transition.scriptAccountActions = this.generateCombinedActions(this.getTransitionActions(leftTransition, true), this.getTransitionActions(rightTransition, false)); + transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition, true), this.getTransitionConditions(rightTransition, false)); if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { generatedTransitions.push(transition) @@ -134,8 +134,8 @@ export class ProductSystemGenerator { } protected generateBinaryProductState(leftState: State, rightState: State, generatedStates: ProductState[]): ProductState | undefined { - const leftConditions = this.getStateConditions(leftState) - const rightConditions = this.getStateConditions(rightState) + const leftConditions = this.getStateConditions(leftState, true) + const rightConditions = this.getStateConditions(rightState, false) const combinedStateConditions: ScriptAccountCondition[] = leftConditions.concat(rightConditions) for(let i=0; i) { + protected getTransitionConditions(transition: Transition, leftSystem: boolean) { return transition.scriptAccountConditions; } - protected getTransitionActions(transition: Transition) { + protected getTransitionActions(transition: Transition, leftSystem: boolean) { return transition.scriptAccountActions; } - protected getStateConditions(state: State) { + protected getStateConditions(state: State, leftSystem: boolean) { return state.conditions; } diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts index 9a7915d..ba66f19 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts @@ -10,6 +10,8 @@ import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleT import {state, transition} from "@angular/animations"; import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState"; +import {Character} from "../../characters/Character"; +import {CharacterRelation} from "../../characters/CharacterRelation"; export class TemplateProductSystemGenerator extends ProductSystemGenerator { @@ -27,16 +29,18 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { productTemplateSystem.stateMap.set(this.templateElement, generationResult.states) } - protected getTransitionConditions(transition: Transition) { - if(transition instanceof SimpleTemplateTransition) { - return transition.conditionMap.get(this.templateElement)! - } else { - return transition.scriptAccountConditions; + protected getTransitionConditions(transition: Transition, leftSystem: boolean) { + const templateElement = this.determineTemplateElement(leftSystem)!; + if(transition instanceof SimpleTemplateTransition && transition.conditionMap.has(templateElement)) { + return transition.conditionMap.get(templateElement)! } + return transition.scriptAccountConditions; } - protected getTransitionActions(transition: Transition) { - if(transition instanceof SimpleTemplateTransition) { + protected getTransitionActions(transition: Transition, leftSystem: boolean) { + const templateElement = this.determineTemplateElement(leftSystem)!; + + if(transition instanceof SimpleTemplateTransition && transition.actionMap.has(templateElement)) { return transition.actionMap.get(this.templateElement)! } else { return transition.scriptAccountActions; @@ -44,11 +48,20 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { } - protected getStateConditions(state: State): ScriptAccountCondition[] { - if(state instanceof SimpleTemplateState) { + protected getStateConditions(state: State, leftSystem: boolean): ScriptAccountCondition[] { + const templateElement = this.determineTemplateElement(leftSystem)! + if(state instanceof SimpleTemplateState && state.conditionMap.has(templateElement)) { return state.conditionMap.get(this.templateElement)! } else { return state.conditions } } + + private determineTemplateElement(leftSystem: boolean) { + if(this.templateElement instanceof Character) { + return this.templateElement; + } else if(this.templateElement instanceof CharacterRelation) { + return leftSystem ? this.templateElement.firstCharacter : this.templateElement.secondCharacter; + } + } } From 3efa6124351bbfce8c8cb5a4fe8dd410807a763e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 14:52:59 +0200 Subject: [PATCH 08/26] Open CharacterRelationSpecific Gamesystem in GamesystemEditor --- .../character-editor.component.html | 17 ++++++++++++++++- .../game-model/characters/CharacterRelation.ts | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index eefda53..959cad6 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -38,6 +38,21 @@ Character-Relations -

{{characterRelation.firstCharacter.componentName}} - {{characterRelation.secondCharacter.componentName}}

+ + + + {{characterRelation.firstCharacter.componentName}} - {{characterRelation.secondCharacter.componentName}} + +

Templatesystems: {{characterRelation.characterRelationGamesystems.length}}

+ + + + {{templateSystem.componentName}} + + + + +
+
diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts index e5a5d96..68dfdfd 100644 --- a/src/app/project/game-model/characters/CharacterRelation.ts +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -18,11 +18,13 @@ export class CharacterRelation implements TemplateElement{ } addCharacterRelationSystem(gamesystem: Gamesystem) { - if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) { + if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) { const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION); templateGamesystem.addChildGamesystem(gamesystem); templateGamesystem.addChildGamesystem(gamesystem); this.characterRelationGamesystems.push(templateGamesystem); + } else { + console.log("Test") } } From 98ef46b83a21bd312d96d32c763effe25cba4d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 15:27:23 +0200 Subject: [PATCH 09/26] Adapt Product Gamesystem Editor for Productsystems with identical innersystems --- .../product-state-editor.component.html | 4 ++-- .../product-state-editor.component.ts | 23 ++++++++++++++++++- .../product-transition-editor.component.ts | 16 +++++++++++++ 3 files changed, 40 insertions(+), 3 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 96ad526..69a13cd 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 @@ -5,8 +5,8 @@ - - + + 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 f09ff92..df09ed5 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 @@ -35,11 +35,14 @@ export class SimpleStateEditorComponent implements OnInit{ editedStateLabelError: boolean = false; + testState: SimpleState | undefined = undefined + constructor(private snackbar: MatSnackBar) { } ngOnInit() { this.dataSource.data = this.states; + this.testState = this.states[0] this.dataSource.filterPredicate = (data: SimpleState, filter: string) => { return data.stateLabel.toLowerCase().includes(filter); } @@ -127,4 +130,6 @@ export class SimpleStateEditorComponent implements OnInit{ return []; } } + + } diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts index 50bb918..a3e99ad 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts @@ -5,10 +5,12 @@ import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccount export class SimpleTemplateState extends SimpleState { conditionMap: Map = new Map(); + initialMap: Map = new Map(); addTemplateElement(templateElement: TemplateElement) { if(!this.conditionMap.has(templateElement)) { this.conditionMap.set(templateElement, this.conditions) + this.initialMap.set(templateElement, this.initial); } } From ce344fe303eadc21108b81969ad2c00725ada46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 20:47:00 +0200 Subject: [PATCH 23/26] Introduce state-initial-editor --- .../state-initial-cell.component.html | 8 +++++ .../state-initial-cell.component.scss | 0 .../state-initial-cell.component.spec.ts | 23 +++++++++++++ .../state-initial-cell.component.ts | 33 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.html create mode 100644 src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.scss create mode 100644 src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.spec.ts create mode 100644 src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.ts diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.html b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.html new file mode 100644 index 0000000..fc7f81b --- /dev/null +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.html @@ -0,0 +1,8 @@ +
+
+ done + close +
+ + +
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.scss b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.spec.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.spec.ts new file mode 100644 index 0000000..fab76c6 --- /dev/null +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { StateInitialCellComponent } from './state-initial-cell.component'; + +describe('StateInitialCellComponent', () => { + let component: StateInitialCellComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [StateInitialCellComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(StateInitialCellComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.ts new file mode 100644 index 0000000..0858bb4 --- /dev/null +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component.ts @@ -0,0 +1,33 @@ +import {Component, Input} from '@angular/core'; +import {SimpleState} from "../../../../../project/game-model/gamesystems/states/SimpleState"; +import {NgIf} from "@angular/common"; +import {TemplateElement} from "../../../../../project/game-model/templates/TemplateElement"; +import {SimpleTemplateState} from "../../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateState"; + +@Component({ + selector: 'app-state-initial-cell', + templateUrl: './state-initial-cell.component.html', + styleUrl: './state-initial-cell.component.scss' +}) +export class StateInitialCellComponent { + + @Input() state: SimpleState | undefined + @Input() editedState: SimpleState | undefined | null + @Input() templateElement: TemplateElement | undefined + + get initialValue(): boolean { + if(this.templateElement != undefined && this.state instanceof SimpleTemplateState && this.state.initialMap.has(this.templateElement!)) { + return this.state!.initialMap.get(this.templateElement!)! + } else { + return this.state!.initial; + } + } + + set initialValue(value: boolean) { + if(this.templateElement != undefined && this.state instanceof SimpleTemplateState && this.state.initialMap.has(this.templateElement!)) { + this.state.initialMap.set(this.templateElement!, value) + } else { + this.state!.initial = value; + } + } +} From 8521d808812220c96de17b5fbdb9da3fccfd6eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 20:59:45 +0200 Subject: [PATCH 24/26] Add templateElement to initialMap independent of conditionMap and serialize initialMap --- .../simpleGamesystem/SimpleTemplateState.ts | 3 + .../project/serializer/CharacterSerializer.ts | 5 +- .../serializer/GamesystemSerializer.ts | 2 +- testModel/characters/Astrid Hofferson.json | 66 ++++++++++++++++++- testModel/characters/Hicks Haddock.json | 18 +++-- .../Characterbeziehungssystem.json | 2 +- 6 files changed, 86 insertions(+), 10 deletions(-) diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts index a3e99ad..1c130be 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts @@ -10,6 +10,9 @@ export class SimpleTemplateState extends SimpleState { addTemplateElement(templateElement: TemplateElement) { if(!this.conditionMap.has(templateElement)) { this.conditionMap.set(templateElement, this.conditions) + } + + if(!this.initialMap.has(templateElement)) { this.initialMap.set(templateElement, this.initial); } } diff --git a/src/app/project/serializer/CharacterSerializer.ts b/src/app/project/serializer/CharacterSerializer.ts index 600d065..56dcff2 100644 --- a/src/app/project/serializer/CharacterSerializer.ts +++ b/src/app/project/serializer/CharacterSerializer.ts @@ -33,7 +33,10 @@ export class CharacterSerializer { return value.componentName } - if(key === 'conditionMap' || key === 'actionMap') { + if(key === 'conditionMap' || key === 'actionMap' || key === 'initialMap') { + if(key === 'initialMap') { + console.log(value) + } if(value.get(character) == undefined) { return [] } diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index 438ab8b..2ec8b43 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -8,7 +8,7 @@ import {ProductTemplateSystem} from "../game-model/templates/productGamesystem/P export class GamesystemSerializer { - private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap", "actionMap"] + private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap", "actionMap", "initialMap"] public static serializeGamesystems(gamesystems: Gamesystem[]): StoreComponent[] { let storedGamesystems: StoreComponent[] = [] diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json index 21cfeca..64ad8a6 100644 --- a/testModel/characters/Astrid Hofferson.json +++ b/testModel/characters/Astrid Hofferson.json @@ -2,5 +2,69 @@ "componentName": "Astrid Hofferson", "componentDescription": "", "characterSpecificTemplateSystems": [], - "characterRelationGamesystems": [] + "characterRelationGamesystems": [ + { + "componentName": "Characterbeziehungssystem", + "states": [ + { + "stateLabel": "Feind", + "conditionMap": [], + "initialMap": true + }, + { + "stateLabel": "Freund", + "conditionMap": [], + "initialMap": false + }, + { + "stateLabel": "Fester Freund", + "conditionMap": [], + "initialMap": false + }, + { + "stateLabel": "Eltern", + "conditionMap": [], + "initialMap": false + }, + { + "stateLabel": "Geschwister", + "conditionMap": [], + "initialMap": false + }, + { + "stateLabel": "Großeltern", + "conditionMap": [], + "initialMap": false + } + ], + "transitions": [ + { + "startingState": "Feind", + "endingState": "Freund", + "conditionMap": [], + "actionMap": [] + }, + { + "startingState": "Freund", + "endingState": "Feind", + "conditionMap": [], + "actionMap": [] + }, + { + "startingState": "Freund", + "endingState": "Fester Freund", + "conditionMap": [], + "actionMap": [] + }, + { + "startingState": "Fester Freund", + "endingState": "Feind", + "conditionMap": [], + "actionMap": [] + } + ], + "generateIsolatedStates": true, + "symmetric": true + } + ] } \ No newline at end of file diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 8f7bf3a..bfb5c9c 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -8,27 +8,33 @@ "states": [ { "stateLabel": "Feind", - "conditionMap": [] + "conditionMap": [], + "initialMap": false }, { "stateLabel": "Freund", - "conditionMap": [] + "conditionMap": [], + "initialMap": false }, { "stateLabel": "Fester Freund", - "conditionMap": [] + "conditionMap": [], + "initialMap": true }, { "stateLabel": "Eltern", - "conditionMap": [] + "conditionMap": [], + "initialMap": false }, { "stateLabel": "Geschwister", - "conditionMap": [] + "conditionMap": [], + "initialMap": false }, { "stateLabel": "Großeltern", - "conditionMap": [] + "conditionMap": [], + "initialMap": false } ], "transitions": [ diff --git a/testModel/gamesystems/Characterbeziehungssystem.json b/testModel/gamesystems/Characterbeziehungssystem.json index 3a39efd..43ebb7c 100644 --- a/testModel/gamesystems/Characterbeziehungssystem.json +++ b/testModel/gamesystems/Characterbeziehungssystem.json @@ -9,7 +9,7 @@ "stateDescription": "" }, { - "initial": true, + "initial": false, "conditions": [], "stateLabel": "Freund", "stateDescription": "" From 9df0a07b1f0de297a2a90a4b110c131be87f0bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 21:03:05 +0200 Subject: [PATCH 25/26] Load initialMap --- src/app/project/parser/characterParser/CharacterParser.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index 4e4e770..cefa511 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -69,6 +69,9 @@ export class CharacterParser { const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap); state.conditionMap.set(character, conditions) + state.initialMap.set(character, stateReference.initialMap) + + console.log(state.initialMap) } for(let i=0; i Date: Fri, 19 Apr 2024 21:07:37 +0200 Subject: [PATCH 26/26] Remove Debugging Printing --- .../product-state-editor/product-state-editor.component.ts | 1 - .../simple-state-editor/simple-state-editor.component.ts | 1 - .../productSystemGenerator/IsolatedProductStateGenerator.ts | 1 - .../IsolatedSymmetricTemplateStateGenerator.ts | 6 ------ .../productSystemGenerator/ProductSystemGenerator.ts | 1 - .../TemplateProductSystemGenerator.ts | 3 --- .../templates/productGamesystem/ProductTemplateSystem.ts | 4 ---- src/app/project/parser/characterParser/CharacterParser.ts | 5 ----- 8 files changed, 22 deletions(-) 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 ab1168d..1c7a7e8 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 @@ -50,7 +50,6 @@ export class ProductStateEditorComponent implements OnInit{ if(this.templateElement == undefined) { this.datasource.data = this.gamesystem!.states; } else if(this.gamesystem instanceof ProductTemplateSystem) { - console.log("Product Template System: ", this.gamesystem!.stateMap.get(this.templateElement)) this.datasource.data = this.gamesystem!.stateMap.get(this.templateElement)! } 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 df09ed5..b6e03e9 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 @@ -46,7 +46,6 @@ export class SimpleStateEditorComponent implements OnInit{ this.dataSource.filterPredicate = (data: SimpleState, filter: string) => { return data.stateLabel.toLowerCase().includes(filter); } - console.log(this.templateElement) } editState(state: SimpleState) { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts index db982a9..8f3933b 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts @@ -29,7 +29,6 @@ export class IsolatedProductStateGenerator extends ProductSystemGenerator { protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) { this.productGamesystem.states = this.productGamesystem.states.concat(generationResult.states); - console.log("Generation-Result: ", this.productGamesystem.states) } protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts index e9301c2..fccf00c 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts @@ -10,16 +10,11 @@ export class IsolatedSymmetricTemplateStateGenerator extends IsolatedTemplateSta protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { - console.log("Calling test") - - console.log(leftSystemData.states) - console.log(rightSystemData.states) const generatedProductStates: ProductState[] = [] leftSystemData.states.forEach(leftState => { if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) { rightSystemData.states.forEach(rightState => { - console.log("LeftState is isolated") if(leftState.equals(rightState)) { if(rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) { const leftConditions = this.getStateConditions(leftState, true); @@ -37,7 +32,6 @@ export class IsolatedSymmetricTemplateStateGenerator extends IsolatedTemplateSta if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { const generatedState = this.generateBinaryProductState(leftState, rightState, generatedProductStates); - console.log(generatedProductStates) } } }) diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts index f001f1e..e1902a0 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts @@ -108,7 +108,6 @@ export class ProductSystemGenerator { this.productGamesystem.states = generationResult.states; this.productGamesystem.transitions = generationResult.transitions; - console.log("General ", generationResult.transitions.length) } protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition, generatedTransitions: ProductTransition[], leftSystem: boolean) { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts index f8b0e74..1047a70 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts @@ -28,9 +28,6 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { const productTemplateSystem = this.productGamesystem as ProductTemplateSystem productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions) productTemplateSystem.stateMap.set(this.templateElement, generationResult.states) - - console.log("Symmetric", (this.productGamesystem as ProductTemplateSystem).symmetric) - console.log("Template: ", generationResult.transitions.length) } protected getTransitionConditions(transition: Transition, leftSystem: boolean) { diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 1c8fa26..70caac1 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -36,10 +36,6 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template if(this.generateIsolatedStates) { const isolatedTemplateStateGenerator = new IsolatedSymmetricTemplateStateGenerator(this, templateElement); isolatedTemplateStateGenerator.generateIsolatedProductStates(); - console.log(this.states) - console.log("Generate symmetric isolated states") - } else { - console.log("Do not generate symmetric isolated states") } } else { const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index cefa511..6472cb1 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -70,8 +70,6 @@ export class CharacterParser { state.conditionMap.set(character, conditions) state.initialMap.set(character, stateReference.initialMap) - - console.log(state.initialMap) } for(let i=0; i
{{col}}{{displayedColumns[i]}} {{getLeafState(state, i).stateLabel}} 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 066e478..1c7a7e8 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 @@ -29,6 +29,8 @@ export class ProductStateEditorComponent implements OnInit{ @Input() templateElement: TemplateElement | undefined @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter(); displayedColumns: string[] = []; + internalColumnNames: string[] = [] + expandedColumns: string[] = [] datasource = new MatTableDataSource(); @@ -38,7 +40,12 @@ export class ProductStateEditorComponent implements OnInit{ this.gamesystem!.generateFromChildsystems(); this.generateColumnNamesRecursively(this.gamesystem!, ""); this.displayedColumns.push('Initial'); - this.expandedColumns = [...this.displayedColumns, 'expand']; + + this.internalColumnNames = this.displayedColumns.concat(); + + this.renameDuplicateColumnNames(this.internalColumnNames) + + this.expandedColumns = [...this.internalColumnNames, 'expand']; if(this.templateElement == undefined) { this.datasource.data = this.gamesystem!.states; @@ -52,6 +59,20 @@ export class ProductStateEditorComponent implements OnInit{ } } + private renameDuplicateColumnNames(columnNames: string[]) { + for(let i=0; i { if(innerGamesystem instanceof SimpleGamesystem) { 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 6c12eec..8bf42e1 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 @@ -50,6 +50,8 @@ export class ProductTransitionEditorComponent implements OnInit{ const leafGamesystems: SimpleGamesystem[] = LeafGamesystemCalculator.calcLeafGeamesystems(this.gamesystem); this.displayedColumns = leafGamesystems.map(leafGamesystem => new DisplayedColumnName(leafGamesystem.componentName, leafGamesystem.componentName + "-start")); this.displayedColumns = this.displayedColumns.concat( leafGamesystems.map(leafGamesystem => new DisplayedColumnName(leafGamesystem.componentName, leafGamesystem.componentName + "-end"))); + this.renameDuplicateColumnNames(this.displayedColumns) + this.numberLeafSystems = leafGamesystems.length; this.columns = this.displayedColumns.map(column => column.internalName) @@ -72,6 +74,20 @@ export class ProductTransitionEditorComponent implements OnInit{ } } + private renameDuplicateColumnNames(columnNames: DisplayedColumnName[]) { + for(let i=0; i Date: Fri, 19 Apr 2024 15:52:52 +0200 Subject: [PATCH 10/26] Introduce symmetric flag in Gamesystem Properties --- .../gamesystem-editor.component.html | 3 +++ .../gamesystem-editor.component.ts | 17 +++++++++++++++++ .../productGamesystem/ProductTemplateSystem.ts | 1 + .../SimpleTemplateGamesystem.ts | 1 + testModel/characters/Hicks Haddock.json | 3 ++- .../gamesystems/Characterbeziehungssystem.json | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index f4ef23b..c32d36c 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,3 +1,6 @@ +
+ Gamesystem is symmetric template +
diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index 2174be0..907935a 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -6,6 +6,8 @@ import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccou import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; import {TemplateElement} from "../../project/game-model/templates/TemplateElement"; +import {SimpleTemplateGamesystem} from "../../project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {ProductTemplateSystem} from "../../project/game-model/templates/productGamesystem/ProductTemplateSystem"; @Component({ selector: 'app-gamesystem-editor', @@ -42,4 +44,19 @@ export class GamesystemEditorComponent implements OnInit{ onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { this.openGamesystemEmitter.emit(gamesystem); } + + isGamesystemTemplate() { + return this.gamesystem instanceof SimpleTemplateGamesystem || this.gamesystem instanceof ProductTemplateSystem; + } + + convertGamesystemToTemplate(gamesystem: Gamesystem, Transition> | undefined) { + if(gamesystem instanceof SimpleTemplateGamesystem) { + return gamesystem as SimpleTemplateGamesystem; + } else if(gamesystem instanceof ProductTemplateSystem) { + return gamesystem as ProductTemplateSystem + } else { + return undefined + } + + } } diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index e6957fd..02a50ce 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -13,6 +13,7 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template stateMap: Map = new Map(); transitionMap: Map = new Map() templateType: TemplateType + symmetric: boolean = false constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts index 17856d2..0c844f4 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts @@ -10,6 +10,7 @@ import {TemplateType} from "../TemplateType"; export class SimpleTemplateGamesystem extends SimpleGamesystem implements TemplateGamesystem { templateType: TemplateType + symmetric: boolean = true constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { super(gamesystemName, gamesystemDescription); diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 414d072..debd75a 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -44,7 +44,8 @@ "conditionMap": [], "actionMap": [] } - ] + ], + "symmetric": true } ] } \ No newline at end of file diff --git a/testModel/gamesystems/Characterbeziehungssystem.json b/testModel/gamesystems/Characterbeziehungssystem.json index 66d038b..ad1b1b4 100644 --- a/testModel/gamesystems/Characterbeziehungssystem.json +++ b/testModel/gamesystems/Characterbeziehungssystem.json @@ -47,5 +47,6 @@ "endingState": "Feind" } ], + "symmetric": true, "templateType": 1 } \ No newline at end of file From f98ad400e36b723aff7b1a54eb4485f34740f0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 16:07:08 +0200 Subject: [PATCH 11/26] Fix Product Template Generation for Relations (generation was not triggered) --- src/app/project/game-model/GameModel.ts | 1 + src/app/project/game-model/characters/CharacterRelation.ts | 2 ++ .../TemplateProductSystemGenerator.ts | 6 ++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 1089ccc..295b6bb 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -76,6 +76,7 @@ export class GameModel { let parentProductGamesystem: ProductGamesystem; if(parentGamesystem instanceof SimpleTemplateGamesystem) { + console.log("Simple Template") parentProductGamesystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(parentGamesystem, this, templateType!) } else if(parentGamesystem instanceof SimpleGamesystem) { if(simpleGamesystem instanceof SimpleTemplateGamesystem) { diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts index 68dfdfd..bdbd03a 100644 --- a/src/app/project/game-model/characters/CharacterRelation.ts +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -4,6 +4,7 @@ import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTempl import {Gamesystem} from "../gamesystems/Gamesystem"; import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; import {TemplateType} from "../templates/TemplateType"; +import {ProductTemplateCreator} from "../templates/productGamesystem/ProductTemplateCreator"; export class CharacterRelation implements TemplateElement{ @@ -23,6 +24,7 @@ export class CharacterRelation implements TemplateElement{ templateGamesystem.addChildGamesystem(gamesystem); templateGamesystem.addChildGamesystem(gamesystem); this.characterRelationGamesystems.push(templateGamesystem); + templateGamesystem.addTemplateElement(this); } else { console.log("Test") } diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts index ba66f19..9fb3666 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts @@ -27,6 +27,8 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { const productTemplateSystem = this.productGamesystem as ProductTemplateSystem productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions) productTemplateSystem.stateMap.set(this.templateElement, generationResult.states) + + console.log("Test") } protected getTransitionConditions(transition: Transition, leftSystem: boolean) { @@ -41,7 +43,7 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { const templateElement = this.determineTemplateElement(leftSystem)!; if(transition instanceof SimpleTemplateTransition && transition.actionMap.has(templateElement)) { - return transition.actionMap.get(this.templateElement)! + return transition.actionMap.get(templateElement)! } else { return transition.scriptAccountActions; } @@ -51,7 +53,7 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { protected getStateConditions(state: State, leftSystem: boolean): ScriptAccountCondition[] { const templateElement = this.determineTemplateElement(leftSystem)! if(state instanceof SimpleTemplateState && state.conditionMap.has(templateElement)) { - return state.conditionMap.get(this.templateElement)! + return state.conditionMap.get(templateElement)! } else { return state.conditions } From 566a58e35c96262f104af237d70075be5aebfbb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 16:40:01 +0200 Subject: [PATCH 12/26] Adjust symmetric Productsystemgeneration --- .../characters/CharacterRelation.ts | 1 + .../ProductSystemGenerator.ts | 3 + .../TemplateProductSystemGenerator.ts | 73 ++++++++++++++++++- 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts index bdbd03a..ea9ecb1 100644 --- a/src/app/project/game-model/characters/CharacterRelation.ts +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -21,6 +21,7 @@ export class CharacterRelation implements TemplateElement{ addCharacterRelationSystem(gamesystem: Gamesystem) { if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) { const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION); + templateGamesystem.symmetric = gamesystem.symmetric templateGamesystem.addChildGamesystem(gamesystem); templateGamesystem.addChildGamesystem(gamesystem); this.characterRelationGamesystems.push(templateGamesystem); diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts index aa667a1..f001f1e 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts @@ -9,6 +9,7 @@ import {Gamesystem} from "../Gamesystem"; import {ProductGenerationData} from "./ProductGenerationData"; import {ProductTransition} from "../transitions/ProductTransition"; import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition"; +import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem"; export class ProductSystemGenerator { productGamesystem: ProductGamesystem @@ -106,6 +107,8 @@ export class ProductSystemGenerator { protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult): void { this.productGamesystem.states = generationResult.states; this.productGamesystem.transitions = generationResult.transitions; + + console.log("General ", generationResult.transitions.length) } protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition, generatedTransitions: ProductTransition[], leftSystem: boolean) { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts index 9fb3666..f969da2 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts @@ -12,6 +12,7 @@ import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState"; import {Character} from "../../characters/Character"; import {CharacterRelation} from "../../characters/CharacterRelation"; +import {ProductGenerationData} from "./ProductGenerationData"; export class TemplateProductSystemGenerator extends ProductSystemGenerator { @@ -28,7 +29,77 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator { productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions) productTemplateSystem.stateMap.set(this.templateElement, generationResult.states) - console.log("Test") + console.log("Symmetric", (this.productGamesystem as ProductTemplateSystem).symmetric) + console.log("Template: ", generationResult.transitions.length) + } + + protected generateFromBinaryChildsystems(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { + const generatedProductStates: ProductState[] = [] + const generatedProductTransitions: ProductTransition[] = [] + + leftSystemData.states.forEach(leftState => { + rightSystemData.states.forEach(rightState => { + for(let i=0; i, leftSystem: boolean) { From 909e2f5c46bb6d71c869509ebe6b8c79d9aff49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 16:55:30 +0200 Subject: [PATCH 13/26] Remove unreachable states when generating symmetric-product-template --- .../SymmetricProductTemplateGenerator.ts | 34 +++++++++ .../TemplateProductSystemGenerator.ts | 69 ------------------- .../ProductTemplateSystem.ts | 13 +++- 3 files changed, 45 insertions(+), 71 deletions(-) create mode 100644 src/app/project/game-model/gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator.ts diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator.ts new file mode 100644 index 0000000..848aa04 --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator.ts @@ -0,0 +1,34 @@ +import {TemplateProductSystemGenerator} from "./TemplateProductSystemGenerator"; +import {ProductGenerationData} from "./ProductGenerationData"; +import {ProductGeneratorResult} from "./ProductGeneratorResult"; +import {ProductState} from "../states/ProductState"; +import {ProductTransition} from "../transitions/ProductTransition"; +import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem"; + +export class SymmetricProductTemplateGenerator extends TemplateProductSystemGenerator { + protected generateFromBinaryChildsystems(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { + const generatedProductStates: ProductState[] = [] + const generatedProductTransitions: ProductTransition[] = [] + + leftSystemData.states.forEach(leftState => { + rightSystemData.states.forEach(rightState => { + if(leftState.equals(rightState)) { + for(let i=0; i { - rightSystemData.states.forEach(rightState => { - for(let i=0; i, leftSystem: boolean) { const templateElement = this.determineTemplateElement(leftSystem)!; if(transition instanceof SimpleTemplateTransition && transition.conditionMap.has(templateElement)) { diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 02a50ce..4193ecd 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -7,6 +7,9 @@ import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; import {GameModel} from "../../GameModel"; import {TemplateType} from "../TemplateType"; import {TemplateProductSystemGenerator} from "../../gamesystems/productSystemGenerator/TemplateProductSystemGenerator"; +import { + SymmetricProductTemplateGenerator +} from "../../gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator"; export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ @@ -22,8 +25,14 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template } addTemplateElement(templateElement: TemplateElement): void { - const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); - productTemplateGenerator.generateFromChildsystems() + if(this.symmetric) { + const symmetricGenerator = new SymmetricProductTemplateGenerator(this, templateElement); + symmetricGenerator.generateFromChildsystems() + } else { + const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); + productTemplateGenerator.generateFromChildsystems() + } + } } From 3d9db9b143b9c6af32dc447b7e3850f263d83663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 17:42:25 +0200 Subject: [PATCH 14/26] Generate isolated states --- .../gamesystems/ProductGamesystem.ts | 4 ++ .../IsolatedProductStateGenerator.ts | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index a7d380f..eade33e 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -11,6 +11,7 @@ import {ScriptAccountAction} from "./actions/ScriptAccountAction"; import {ProductSystemGenerator} from "./productSystemGenerator/ProductSystemGenerator"; import {TemplateType} from "../templates/TemplateType"; import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; +import {IsolatedProductStateGenerator} from "./productSystemGenerator/IsolatedProductStateGenerator"; export class ProductGamesystem extends Gamesystem { @@ -74,6 +75,9 @@ export class ProductGamesystem extends Gamesystem, Transition>) { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts new file mode 100644 index 0000000..99b8919 --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts @@ -0,0 +1,53 @@ +import {ProductSystemGenerator} from "./ProductSystemGenerator"; +import {ProductGenerationData} from "./ProductGenerationData"; +import {ProductGeneratorResult} from "./ProductGeneratorResult"; +import {ProductState} from "../states/ProductState"; + +export class IsolatedProductStateGenerator extends ProductSystemGenerator { + + generateIsolatedProductStates() { + if(this.productGamesystem.innerGamesystems.length < 2) return; + + const leftInitialData = this.prepareChildsystemForGeneration(this.productGamesystem.innerGamesystems[0]) + const rightInitialData = this.prepareChildsystemForGeneration(this.productGamesystem.innerGamesystems[1]) + + const initialGenerationResult = this.generateBinaryIsolatedProductStates(leftInitialData, rightInitialData); + + if(this.productGamesystem.innerGamesystems.length > 2) { + for(let i=2; i { + if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) { + rightSystemData.states.forEach(rightState => { + if(rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) { + const leftConditions = this.getStateConditions(leftState, true); + const rightConditions = this.getStateConditions(rightState, true); + + if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { + this.generateBinaryProductState(leftState, rightState, generatedProductStates); + } + } + }) + } + }) + return new ProductGeneratorResult(generatedProductStates, []); + } + +} From ee970db7164c5b3c2987f84d8d8b05359a2a772d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 17:45:58 +0200 Subject: [PATCH 15/26] Generate isolated template States --- .../IsolatedProductStateGenerator.ts | 2 +- .../IsolatedTemplateStateGenerator.ts | 57 +++++++++++++++++++ .../ProductTemplateSystem.ts | 3 + 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts index 99b8919..3577424 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts @@ -31,7 +31,7 @@ export class IsolatedProductStateGenerator extends ProductSystemGenerator { this.productGamesystem.states = generationResult.states; } - generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { + protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { const generatedProductStates: ProductState[] = [] leftSystemData.states.forEach(leftState => { if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts new file mode 100644 index 0000000..b9244a4 --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts @@ -0,0 +1,57 @@ +import {IsolatedProductStateGenerator} from "./IsolatedProductStateGenerator"; +import {Transition} from "../transitions/Transition"; +import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition"; +import {State} from "../states/State"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; +import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState"; +import {Character} from "../../characters/Character"; +import {CharacterRelation} from "../../characters/CharacterRelation"; +import {TemplateElement} from "../../templates/TemplateElement"; +import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem"; + +export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerator { + templateElement: TemplateElement + + constructor(productGamesystem: ProductTemplateSystem, templateElement: TemplateElement) { + super(productGamesystem); + this.templateElement = templateElement; + } + + + + protected getTransitionConditions(transition: Transition, leftSystem: boolean) { + const templateElement = this.determineTemplateElement(leftSystem)!; + if(transition instanceof SimpleTemplateTransition && transition.conditionMap.has(templateElement)) { + return transition.conditionMap.get(templateElement)! + } + return transition.scriptAccountConditions; + } + + protected getTransitionActions(transition: Transition, leftSystem: boolean) { + const templateElement = this.determineTemplateElement(leftSystem)!; + + if(transition instanceof SimpleTemplateTransition && transition.actionMap.has(templateElement)) { + return transition.actionMap.get(templateElement)! + } else { + return transition.scriptAccountActions; + } + } + + + protected getStateConditions(state: State, leftSystem: boolean): ScriptAccountCondition[] { + const templateElement = this.determineTemplateElement(leftSystem)! + if(state instanceof SimpleTemplateState && state.conditionMap.has(templateElement)) { + return state.conditionMap.get(templateElement)! + } else { + return state.conditions + } + } + + private determineTemplateElement(leftSystem: boolean) { + if(this.templateElement instanceof Character) { + return this.templateElement; + } else if(this.templateElement instanceof CharacterRelation) { + return leftSystem ? this.templateElement.firstCharacter : this.templateElement.secondCharacter; + } + } +} diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 4193ecd..1e5a9da 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -10,6 +10,7 @@ import {TemplateProductSystemGenerator} from "../../gamesystems/productSystemGen import { SymmetricProductTemplateGenerator } from "../../gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator"; +import {IsolatedTemplateStateGenerator} from "../../gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator"; export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ @@ -33,6 +34,8 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template productTemplateGenerator.generateFromChildsystems() } + const isolatedTemplateStateGenerator = new IsolatedTemplateStateGenerator(this, templateElement); + isolatedTemplateStateGenerator.generateIsolatedProductStates(); } } From 87a0dd775e50f70172fd283f70c39c05953941cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 17:50:03 +0200 Subject: [PATCH 16/26] Generate isolated states only on demand --- .../product-gamesystem-editor.component.html | 1 + .../project/game-model/gamesystems/ProductGamesystem.ts | 7 +++++-- .../templates/productGamesystem/ProductTemplateSystem.ts | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html index 0eee76f..fde7130 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html @@ -1,3 +1,4 @@ +Generate Isolated States
diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index eade33e..00889a5 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -16,6 +16,7 @@ import {IsolatedProductStateGenerator} from "./productSystemGenerator/IsolatedPr export class ProductGamesystem extends Gamesystem { innerGamesystems: Gamesystem, Transition>[] = []; + generateIsolatedStates: boolean = false static constructFromSimpleGamesystem(simpleGamesystem: SimpleGamesystem, gameModel: GameModel) { const productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription); @@ -76,8 +77,10 @@ export class ProductGamesystem extends Gamesystem, Transition>) { diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 1e5a9da..62816c4 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -32,10 +32,14 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template } else { const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); productTemplateGenerator.generateFromChildsystems() + + if(this.generateIsolatedStates) { + const isolatedTemplateStateGenerator = new IsolatedTemplateStateGenerator(this, templateElement); + isolatedTemplateStateGenerator.generateIsolatedProductStates(); + } } - const isolatedTemplateStateGenerator = new IsolatedTemplateStateGenerator(this, templateElement); - isolatedTemplateStateGenerator.generateIsolatedProductStates(); + } } From 7cb02030d9a80c6a855571f0089ed9ce6df5a983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 17:52:50 +0200 Subject: [PATCH 17/26] Generate only symmetric isolated states --- ...IsolatedSymmetricTemplateStateGenerator.ts | 27 +++++++++++++++++++ .../ProductTemplateSystem.ts | 8 ++++++ 2 files changed, 35 insertions(+) create mode 100644 src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts new file mode 100644 index 0000000..d0032ec --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts @@ -0,0 +1,27 @@ +import {IsolatedTemplateStateGenerator} from "./IsolatedTemplateStateGenerator"; +import {ProductGenerationData} from "./ProductGenerationData"; +import {ProductGeneratorResult} from "./ProductGeneratorResult"; +import {ProductState} from "../states/ProductState"; + +export class IsolatedSymmetricTemplateStateGenerator extends IsolatedTemplateStateGenerator{ + + + protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { + const generatedProductStates: ProductState[] = [] + leftSystemData.states.forEach(leftState => { + if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) { + rightSystemData.states.forEach(rightState => { + if(leftState.equals(rightState) && rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) { + const leftConditions = this.getStateConditions(leftState, true); + const rightConditions = this.getStateConditions(rightState, true); + + if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { + this.generateBinaryProductState(leftState, rightState, generatedProductStates); + } + } + }) + } + }) + return new ProductGeneratorResult(generatedProductStates, []); + } +} diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 62816c4..23b7783 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -11,6 +11,9 @@ import { SymmetricProductTemplateGenerator } from "../../gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator"; import {IsolatedTemplateStateGenerator} from "../../gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator"; +import { + IsolatedSymmetricTemplateStateGenerator +} from "../../gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator"; export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ @@ -29,6 +32,11 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template if(this.symmetric) { const symmetricGenerator = new SymmetricProductTemplateGenerator(this, templateElement); symmetricGenerator.generateFromChildsystems() + + if(this.generateIsolatedStates) { + const isolatedTemplateStateGenerator = new IsolatedSymmetricTemplateStateGenerator(this, templateElement); + isolatedTemplateStateGenerator.generateFromChildsystems(); + } } else { const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); productTemplateGenerator.generateFromChildsystems() From 0104df8084d3062d5e755fdc964e77cf428d95ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 19:53:31 +0200 Subject: [PATCH 18/26] Add generated isolated states to already generated states --- .../gamesystem-editor.component.html | 14 ++++++++--- .../product-gamesystem-editor.component.html | 2 +- .../product-gamesystem-editor.component.ts | 7 ++++-- .../product-state-editor.component.ts | 1 + .../characters/CharacterRelation.ts | 1 + .../game-model/gamesystems/Gamesystem.ts | 2 ++ .../gamesystems/ProductGamesystem.ts | 1 - .../IsolatedProductStateGenerator.ts | 3 ++- ...IsolatedSymmetricTemplateStateGenerator.ts | 23 ++++++++++++++++++- .../IsolatedTemplateStateGenerator.ts | 9 ++++++++ .../ProductTemplateSystem.ts | 6 ++++- testModel/characters/Hicks Haddock.json | 13 +++++++++++ .../Characterbeziehungssystem.json | 19 +++++++++++++++ 13 files changed, 91 insertions(+), 10 deletions(-) diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index c32d36c..81b08a1 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,6 +1,14 @@ -
- Gamesystem is symmetric template -
+ + + + + Product Generation Settings + +
+ Use symmetric Productgenerators +
+ Generate Isolated ProductStates +
diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html index fde7130..b812aca 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html @@ -1,4 +1,4 @@ -Generate Isolated States +
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 29319ca..e96554b 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,4 +1,4 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import { ProductTransitionEditorComponent } from "../transition-editor/product-transition-editor/product-transition-editor.component"; @@ -13,12 +13,15 @@ import {TemplateElement} from "../../../project/game-model/templates/TemplateEle templateUrl: './product-gamesystem-editor.component.html', styleUrl: './product-gamesystem-editor.component.scss' }) -export class ProductGamesystemEditorComponent { +export class ProductGamesystemEditorComponent implements OnInit{ @Input() gamesystem: ProductGamesystem | undefined @Input() templateElement: TemplateElement | undefined @Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter(); + ngOnInit() { + } + onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { this.openGamesystemEditorEmitter.emit(gamesystem); } 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 1c7a7e8..ab1168d 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 @@ -50,6 +50,7 @@ export class ProductStateEditorComponent implements OnInit{ if(this.templateElement == undefined) { this.datasource.data = this.gamesystem!.states; } else if(this.gamesystem instanceof ProductTemplateSystem) { + console.log("Product Template System: ", this.gamesystem!.stateMap.get(this.templateElement)) this.datasource.data = this.gamesystem!.stateMap.get(this.templateElement)! } diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts index ea9ecb1..fe1307a 100644 --- a/src/app/project/game-model/characters/CharacterRelation.ts +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -22,6 +22,7 @@ export class CharacterRelation implements TemplateElement{ if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) { const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION); templateGamesystem.symmetric = gamesystem.symmetric + templateGamesystem.generateIsolatedStates = gamesystem.generateIsolatedStates templateGamesystem.addChildGamesystem(gamesystem); templateGamesystem.addChildGamesystem(gamesystem); this.characterRelationGamesystems.push(templateGamesystem); diff --git a/src/app/project/game-model/gamesystems/Gamesystem.ts b/src/app/project/game-model/gamesystems/Gamesystem.ts index 2e94174..d08bbf2 100644 --- a/src/app/project/game-model/gamesystems/Gamesystem.ts +++ b/src/app/project/game-model/gamesystems/Gamesystem.ts @@ -8,6 +8,8 @@ export abstract class Gamesystem extends ModelComponent{ states: S[] = []; transitions: T[] = []; parentGamesystem: ProductGamesystem | undefined + generateIsolatedStates: boolean = true + constructor(gamesystemName: string, gamesystemDescription: string) { super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM); } diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index 00889a5..2b77cdc 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -16,7 +16,6 @@ import {IsolatedProductStateGenerator} from "./productSystemGenerator/IsolatedPr export class ProductGamesystem extends Gamesystem { innerGamesystems: Gamesystem, Transition>[] = []; - generateIsolatedStates: boolean = false static constructFromSimpleGamesystem(simpleGamesystem: SimpleGamesystem, gameModel: GameModel) { const productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription); diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts index 3577424..db982a9 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedProductStateGenerator.ts @@ -28,7 +28,8 @@ export class IsolatedProductStateGenerator extends ProductSystemGenerator { protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) { - this.productGamesystem.states = generationResult.states; + this.productGamesystem.states = this.productGamesystem.states.concat(generationResult.states); + console.log("Generation-Result: ", this.productGamesystem.states) } protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts index d0032ec..e9301c2 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator.ts @@ -2,21 +2,42 @@ import {IsolatedTemplateStateGenerator} from "./IsolatedTemplateStateGenerator"; import {ProductGenerationData} from "./ProductGenerationData"; import {ProductGeneratorResult} from "./ProductGeneratorResult"; import {ProductState} from "../states/ProductState"; +import {SimpleState} from "../states/SimpleState"; +import {State} from "../states/State"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; export class IsolatedSymmetricTemplateStateGenerator extends IsolatedTemplateStateGenerator{ protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult { + console.log("Calling test") + + console.log(leftSystemData.states) + console.log(rightSystemData.states) + const generatedProductStates: ProductState[] = [] leftSystemData.states.forEach(leftState => { if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) { rightSystemData.states.forEach(rightState => { + console.log("LeftState is isolated") + if(leftState.equals(rightState)) { + if(rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) { + const leftConditions = this.getStateConditions(leftState, true); + const rightConditions = this.getStateConditions(rightState, true); + + if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { + this.generateBinaryProductState(leftState, rightState, generatedProductStates); + } + } + } + if(leftState.equals(rightState) && rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) { const leftConditions = this.getStateConditions(leftState, true); const rightConditions = this.getStateConditions(rightState, true); if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { - this.generateBinaryProductState(leftState, rightState, generatedProductStates); + const generatedState = this.generateBinaryProductState(leftState, rightState, generatedProductStates); + console.log(generatedProductStates) } } }) diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts index b9244a4..ad2fe31 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator.ts @@ -8,6 +8,8 @@ import {Character} from "../../characters/Character"; import {CharacterRelation} from "../../characters/CharacterRelation"; import {TemplateElement} from "../../templates/TemplateElement"; import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem"; +import {ProductGeneratorResult} from "./ProductGeneratorResult"; +import {state, transition} from "@angular/animations"; export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerator { templateElement: TemplateElement @@ -18,6 +20,13 @@ export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerato } + protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) { + const templateSystem = this.productGamesystem as ProductTemplateSystem; + + const nonIsolatedStates = templateSystem.stateMap.get(this.templateElement)! + const states = nonIsolatedStates.concat(generationResult.states); + templateSystem.stateMap.set(this.templateElement, states) + } protected getTransitionConditions(transition: Transition, leftSystem: boolean) { const templateElement = this.determineTemplateElement(leftSystem)!; diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 23b7783..1c8fa26 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -35,7 +35,11 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template if(this.generateIsolatedStates) { const isolatedTemplateStateGenerator = new IsolatedSymmetricTemplateStateGenerator(this, templateElement); - isolatedTemplateStateGenerator.generateFromChildsystems(); + isolatedTemplateStateGenerator.generateIsolatedProductStates(); + console.log(this.states) + console.log("Generate symmetric isolated states") + } else { + console.log("Do not generate symmetric isolated states") } } else { const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index debd75a..8f7bf3a 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -17,6 +17,18 @@ { "stateLabel": "Fester Freund", "conditionMap": [] + }, + { + "stateLabel": "Eltern", + "conditionMap": [] + }, + { + "stateLabel": "Geschwister", + "conditionMap": [] + }, + { + "stateLabel": "Großeltern", + "conditionMap": [] } ], "transitions": [ @@ -45,6 +57,7 @@ "actionMap": [] } ], + "generateIsolatedStates": true, "symmetric": true } ] diff --git a/testModel/gamesystems/Characterbeziehungssystem.json b/testModel/gamesystems/Characterbeziehungssystem.json index ad1b1b4..8ad03fd 100644 --- a/testModel/gamesystems/Characterbeziehungssystem.json +++ b/testModel/gamesystems/Characterbeziehungssystem.json @@ -19,6 +19,24 @@ "conditions": [], "stateLabel": "Fester Freund", "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "Eltern", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "Geschwister", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "Großeltern", + "stateDescription": "" } ], "transitions": [ @@ -47,6 +65,7 @@ "endingState": "Feind" } ], + "generateIsolatedStates": true, "symmetric": true, "templateType": 1 } \ No newline at end of file From 5b1e711a118e0fdc455ebb9e254bf1d8a6320d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 19:56:04 +0200 Subject: [PATCH 19/26] Change symmetric default values to be false --- src/app/project/game-model/gamesystems/Gamesystem.ts | 2 +- .../templates/simpleGamesystem/SimpleTemplateGamesystem.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/project/game-model/gamesystems/Gamesystem.ts b/src/app/project/game-model/gamesystems/Gamesystem.ts index d08bbf2..981590a 100644 --- a/src/app/project/game-model/gamesystems/Gamesystem.ts +++ b/src/app/project/game-model/gamesystems/Gamesystem.ts @@ -8,7 +8,7 @@ export abstract class Gamesystem extends ModelComponent{ states: S[] = []; transitions: T[] = []; parentGamesystem: ProductGamesystem | undefined - generateIsolatedStates: boolean = true + generateIsolatedStates: boolean = false constructor(gamesystemName: string, gamesystemDescription: string) { super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM); diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts index 0c844f4..bb8af87 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts @@ -10,7 +10,7 @@ import {TemplateType} from "../TemplateType"; export class SimpleTemplateGamesystem extends SimpleGamesystem implements TemplateGamesystem { templateType: TemplateType - symmetric: boolean = true + symmetric: boolean = false constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { super(gamesystemName, gamesystemDescription); From 48478d340a64d62b4af3ef1306cabfb8f2638851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 20:01:22 +0200 Subject: [PATCH 20/26] Fix gamesystem undefined error in gamesystem-editor --- .../editor/gamesystem-editor/gamesystem-editor.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index 81b08a1..a055b2d 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -3,12 +3,12 @@ - + Product Generation Settings
Use symmetric Productgenerators
- Generate Isolated ProductStates + Generate Isolated ProductStates
From 743af8c0a11acf7a32320c5481826862050cf3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 19 Apr 2024 20:13:13 +0200 Subject: [PATCH 21/26] Serialize and Load Gernation Settings of Gamesystems --- .../parser/gamesystemParser/GamesystemParser.ts | 5 +++++ src/app/project/serializer/GamesystemSerializer.ts | 5 ++++- .../gamesystems/Characterbeziehungssystem.json | 2 +- .../gamesystems/ProductGamesystem/Letter.json | 14 ++++++++++++++ .../gamesystems/ProductGamesystem/Number.json | 14 ++++++++++++++ .../ProductGamesystem/ProductGamesystem.json | 13 +++++++++++++ testModel/script-accounts/Test.json | 6 ++++++ 7 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 testModel/gamesystems/ProductGamesystem/Letter.json create mode 100644 testModel/gamesystems/ProductGamesystem/Number.json create mode 100644 testModel/gamesystems/ProductGamesystem/ProductGamesystem.json create mode 100644 testModel/script-accounts/Test.json diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index 0e4ce93..5e7ad14 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -45,6 +45,7 @@ export class GamesystemParser { let simpleGamesystem if(gamesystemData.templateType != undefined) { simpleGamesystem = new SimpleTemplateGamesystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType) + simpleGamesystem.symmetric = gamesystemData.symmetric } else { simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) } @@ -56,6 +57,7 @@ export class GamesystemParser { const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions, gamesystemData.templateType) + simpleGamesystem.generateIsolatedStates = gamesystemData.generateIsolatedStates; return simpleGamesystem } @@ -66,8 +68,11 @@ export class GamesystemParser { productGamesystem = new ProductGamesystem(gamesystemData.componentName, gamesystemData.componentDescription); } else { productGamesystem = new ProductTemplateSystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType) + productGamesystem.symmetric = gamesystemData.symmetric } + productGamesystem.generateIsolatedStates = gamesystemData.generateIsolatedStates + const childsystemNames: string[] = [] for(let i=0; i Date: Fri, 19 Apr 2024 20:46:37 +0200 Subject: [PATCH 22/26] Edit Initial Value of SimpleState per TemplateElement --- src/app/app.module.ts | 132 +++++++++--------- .../simple-state-editor.component.html | 7 +- .../simple-state-editor.component.ts | 5 + .../simpleGamesystem/SimpleTemplateState.ts | 2 + 4 files changed, 76 insertions(+), 70 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0523803..34970f6 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -79,6 +79,9 @@ import { import { TemplateSpecificatorComponent } from "./editor/gamesystem-editor/template-specificator/template-specificator.component"; +import { + StateInitialCellComponent +} from "./editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -103,71 +106,72 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl ScriptaccountConditionEditorComponent, CharacterOverviewComponent, CharacterEditorComponent, - TemplateSpecificatorComponent - ], - 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, - MatCardHeader, - MatAccordion, - MatExpansionPanel, - MatExpansionPanelTitle, - MatCardTitle, - MatExpansionPanelHeader + TemplateSpecificatorComponent, + StateInitialCellComponent ], + 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, + MatCardHeader, + MatAccordion, + MatExpansionPanel, + MatExpansionPanelTitle, + MatCardTitle, + MatExpansionPanelHeader + ], providers: [], bootstrap: [AppComponent] }) 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 c8f2e06..95b9422 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 @@ -39,12 +39,7 @@
Initial -
- done - close -
- - +