From ec69b9f43611b62cd0eefa3c679d3b869f024499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 13 Apr 2024 08:13:15 +0200 Subject: [PATCH] Remove generated Duplicate Transitions --- .../productSystemGenerator/ProductGamesystemGenerator.ts | 6 +++++- .../ProductTemplateGamesystemGenerator.ts | 6 +++++- .../project/game-model/gamesystems/states/ProductState.ts | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts index 28e894e..55bc89c 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts @@ -34,7 +34,11 @@ export class ProductGamesystemGenerator extends AbstractProductGamesystemGenerat transition.scriptAccountActions = this.generateCombinedActions(leftTransition.scriptAccountActions, rightTransition.scriptAccountActions); transition.scriptAccountConditions = this.generateCombinedConditions(leftTransition.scriptAccountConditions, rightTransition.scriptAccountConditions); - generatedTransitions.push(transition) + if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { + generatedTransitions.push(transition) + } else { + console.log(transition) + } } } diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts index 058455f..c82e6ac 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts @@ -141,7 +141,11 @@ export class ProductTemplateGamesystemGenerator extends Abstr transition.scriptAccountConditions = this.generateCombinedConditions(leftConditions, rightConditions); - generatedTransitions.push(transition) + if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { + generatedTransitions.push(transition) + } else { + console.log(transition) + } } } diff --git a/src/app/project/game-model/gamesystems/states/ProductState.ts b/src/app/project/game-model/gamesystems/states/ProductState.ts index e2ed323..d595dc6 100644 --- a/src/app/project/game-model/gamesystems/states/ProductState.ts +++ b/src/app/project/game-model/gamesystems/states/ProductState.ts @@ -2,6 +2,7 @@ import {ProductTransition} from "../transitions/ProductTransition"; import {State} from "./State"; import {SimpleState} from "./SimpleState"; import {Transition} from "../transitions/Transition"; +import {SimpleTemplateState} from "./SimpleTemplateState"; export class ProductState extends State { innerStates: State[] = []; @@ -29,6 +30,10 @@ export class ProductState extends State { return false; } + if(state instanceof SimpleTemplateState) { + return false; + } + for(let i=0; i