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 1/7] 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, []); + } + +} -- 2.34.1 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 2/7] 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(); } } -- 2.34.1 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 3/7] 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(); + } } -- 2.34.1 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 4/7] 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() -- 2.34.1 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 5/7] 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 -- 2.34.1 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 6/7] 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); -- 2.34.1 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 7/7] 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
-- 2.34.1