From 7bb992200f0df4324d849159ed0e35de10972ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Tue, 19 Mar 2024 15:05:35 +0100 Subject: [PATCH] Consider Transition Conditions and Transition Actions while generating ProductTransitions --- .../gamesystems/ProductGamesystem.ts | 89 ++++++++++++++++++- .../actions/ScriptAccountAction.ts | 10 +++ .../conditions/ScriptAccountCondition.ts | 9 ++ 3 files changed, 105 insertions(+), 3 deletions(-) diff --git a/src/app/game-model/gamesystems/ProductGamesystem.ts b/src/app/game-model/gamesystems/ProductGamesystem.ts index efdadf4..087e019 100644 --- a/src/app/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/game-model/gamesystems/ProductGamesystem.ts @@ -8,6 +8,7 @@ import {SimpleGamesystem} from "./SimpleGamesystem"; import {GameModel} from "../GameModel"; import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer"; import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition"; +import {ScriptAccountAction} from "./actions/ScriptAccountAction"; export class ProductGamesystem extends Gamesystem { @@ -104,18 +105,36 @@ export class ProductGamesystem extends Gamesystem, rightInnerState: State, left_temp: boolean) { const combinedStateConditions: ScriptAccountCondition[] = leftInnerState.conditions.concat(rightInnerState.conditions) for(let i=0; i s.equals(state)) != undefined; } + + } diff --git a/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts b/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts index d258760..f2d88f6 100644 --- a/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts +++ b/src/app/game-model/gamesystems/actions/ScriptAccountAction.ts @@ -1,4 +1,5 @@ import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; export class ScriptAccountAction { scriptAccount: ScriptAccount @@ -9,4 +10,13 @@ export class ScriptAccountAction { this.scriptAccount = scriptAccount; this.changingValue = changingValue; } + + + combineActions(otherAction: ScriptAccountAction) { + if(otherAction.scriptAccount === this.scriptAccount) { + return new ScriptAccountAction(this.scriptAccount, this.changingValue + otherAction.changingValue) + } else { + return undefined; + } + } } diff --git a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts index 5592421..566bfb0 100644 --- a/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts +++ b/src/app/game-model/gamesystems/conditions/ScriptAccountCondition.ts @@ -23,6 +23,15 @@ export class ScriptAccountCondition { } } + combineCondition(condition: ScriptAccountCondition) { + if(condition.scriptAccount === this.scriptAccount) { + const scriptAccount = new ScriptAccountCondition(this.scriptAccount, this.minValue, this.maxValue); + scriptAccount.combineCondition(condition); + return scriptAccount; + } + return undefined; + } + isContradicting(condition: ScriptAccountCondition) { return condition.scriptAccount === this.scriptAccount && (this.maxValue < condition.minValue || this.minValue > condition.maxValue)