diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index 83d73ec..08f793b 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -8,10 +8,12 @@ import {SimpleGamesystem} from "./SimpleGamesystem"; import {GameModel} from "../GameModel"; import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition"; import {ScriptAccountAction} from "./actions/ScriptAccountAction"; +import {ProductGamesystemGenerator} from "./productSystemGenerator/ProductGamesystemGenerator"; export class ProductGamesystem extends Gamesystem { innerGamesystems: Gamesystem, Transition>[] = []; + productGamesystemGenerator: ProductGamesystemGenerator = new ProductGamesystemGenerator(this); static constructFromSimpleGamesystem(simpleGamesystem: SimpleGamesystem, gameModel: GameModel) { const productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription); diff --git a/src/app/project/game-model/gamesystems/ProductTemplateSystem.ts b/src/app/project/game-model/gamesystems/ProductTemplateSystem.ts new file mode 100644 index 0000000..e4e792c --- /dev/null +++ b/src/app/project/game-model/gamesystems/ProductTemplateSystem.ts @@ -0,0 +1,14 @@ +import {ProductGamesystem} from "./ProductGamesystem"; +import {ProductState} from "./states/ProductState"; +import {ProductTransition} from "./transitions/ProductTransition"; +import {Gamesystem} from "./Gamesystem"; + +export class ProductTemplateSystem extends ProductGamesystem{ + + stateMap: Map = new Map(); + transitionMap: Map = new Map(); + + + + +} diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/AbstractProductGamesystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/AbstractProductGamesystemGenerator.ts new file mode 100644 index 0000000..495f0f1 --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/AbstractProductGamesystemGenerator.ts @@ -0,0 +1,23 @@ +import {Gamesystem} from "../Gamesystem"; +import {ScriptAccountAction} from "../actions/ScriptAccountAction"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; +import {State} from "../states/State"; +import {ProductGamesystem} from "../ProductGamesystem"; + +export abstract class AbstractProductGamesystemGenerator { + + protected integratedSystems: Gamesystem[] = [] + + + prepare() { + this.integratedSystems = [] + } + + abstract generateFromChildsystems(ProductGamesystem: ProductGamesystem): void; + + abstract generateFromBinaryChildsystems(leftSystem: Gamesystem, rightSystem: any, left_temp: boolean): void; + + abstract generateBinaryProductState(leftInnerState: State, rightInnerState: State, left_temp: boolean): State; + + +} diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts new file mode 100644 index 0000000..b2986cf --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGamesystemGenerator.ts @@ -0,0 +1,211 @@ +import {ProductGamesystem} from "../ProductGamesystem"; +import {Gamesystem} from "../Gamesystem"; +import {ProductGenerationData} from "./ProductGenerationData"; +import {ProductGeneratorResult} from "./ProductGeneratorResult"; +import {State} from "../states/State"; +import {ProductState} from "../states/ProductState"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; +import {ProductTransition} from "../transitions/ProductTransition"; +import {Transition} from "../transitions/Transition"; +import {ScriptAccountAction} from "../actions/ScriptAccountAction"; + +export class ProductGamesystemGenerator { + productGamesystem: ProductGamesystem + + + constructor(productGamesystem: ProductGamesystem) { + this.productGamesystem = productGamesystem; + } + + generateFromChildsystems(): void { + 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.generateFromBinaryChildsystems(leftInitialData, rightInitialData); + + for(let i=2; i) { + if(childsystem instanceof ProductGamesystem) { + childsystem.productGamesystemGenerator.generateFromChildsystems(); + } + + return new ProductGenerationData(childsystem.states, childsystem.transitions) + } + + private 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) { + const transition = new ProductTransition(startingState, endingState); + transition.scriptAccountActions = [... usedTransition.scriptAccountActions]; + transition.scriptAccountConditions = [... usedTransition.scriptAccountConditions]; + + return transition; + } + + private generateBinaryProductState(leftState: State, rightState: State, generatedStates: ProductState[]): ProductState | undefined { + const combinedStateConditions: ScriptAccountCondition[] = leftState.conditions.concat(rightState.conditions); + for(let i=0; i[] = leftState.getInnerStates().concat(rightState.getInnerStates()) + let binaryProductState: ProductState | undefined = this.findGeneratedProductState(innerStates, generatedStates); + if(binaryProductState == undefined) { + binaryProductState = new ProductState(innerStates); + } + + binaryProductState.determineInitialProperty() + binaryProductState.conditions = combinedStateConditions; + + return binaryProductState; + } + + private findGeneratedProductState(innerStates: State[], productStates: ProductState[]) { + return undefined + } + + private generateCombinedActions(leftActions: ScriptAccountAction[], rightActions: ScriptAccountAction[]): ScriptAccountAction[] { + const combinedActions: ScriptAccountAction[] = [] + for(let i=0; i[] + transitions: Transition[] + + + constructor(states: State[], transitions: Transition[]) { + this.states = states; + this.transitions = transitions; + } +} diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGeneratorResult.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGeneratorResult.ts new file mode 100644 index 0000000..ec68f94 --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductGeneratorResult.ts @@ -0,0 +1,18 @@ +import {ProductState} from "../states/ProductState"; +import {ProductTransition} from "../transitions/ProductTransition"; +import {ProductGenerationData} from "./ProductGenerationData"; + +export class ProductGeneratorResult { + states: ProductState[]; + transitions: ProductTransition[] + + + constructor(states: ProductState[], transitions: ProductTransition[]) { + this.states = states; + this.transitions = transitions; + } + + get productGenerationData(): ProductGenerationData { + return new ProductGenerationData(this.states, this.transitions) + } +} diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts new file mode 100644 index 0000000..ff35cd3 --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductTemplateGamesystemGenerator.ts @@ -0,0 +1,5 @@ +import {AbstractProductGamesystemGenerator} from "./AbstractProductGamesystemGenerator"; + +export class ProductTemplateGamesystemGenerator extends AbstractProductGamesystemGenerator{ + +} diff --git a/src/app/project/game-model/gamesystems/states/ProductState.ts b/src/app/project/game-model/gamesystems/states/ProductState.ts index 8a4c504..e2ed323 100644 --- a/src/app/project/game-model/gamesystems/states/ProductState.ts +++ b/src/app/project/game-model/gamesystems/states/ProductState.ts @@ -50,4 +50,18 @@ export class ProductState extends State { return false; } + getInnerStates(): SimpleState[] { + let innerStates: SimpleState[] = []; + this.innerStates.forEach(innerState => + innerStates = innerStates.concat(innerState.getInnerStates()) + ) + return innerStates; + } + + determineInitialProperty() { + this.initial = true; + this.innerStates.forEach(innerState => this.initial = this.innerStates && innerState.initial) + } + + } diff --git a/src/app/project/game-model/gamesystems/states/SimpleState.ts b/src/app/project/game-model/gamesystems/states/SimpleState.ts index 259f8fe..6251aa7 100644 --- a/src/app/project/game-model/gamesystems/states/SimpleState.ts +++ b/src/app/project/game-model/gamesystems/states/SimpleState.ts @@ -20,5 +20,10 @@ export class SimpleState extends State { return this.stateLabel === (state as SimpleState).stateLabel; } + getInnerStates(): SimpleState[] { + return [this] + } + + } diff --git a/src/app/project/game-model/gamesystems/states/State.ts b/src/app/project/game-model/gamesystems/states/State.ts index d1848f5..8205916 100644 --- a/src/app/project/game-model/gamesystems/states/State.ts +++ b/src/app/project/game-model/gamesystems/states/State.ts @@ -1,6 +1,7 @@ import {Transition} from "../transitions/Transition"; import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; import {ScriptAccount} from "../../scriptAccounts/ScriptAccount"; +import {SimpleState} from "./SimpleState"; export abstract class State> { @@ -47,4 +48,6 @@ export abstract class State> { } abstract equals(state: State>): boolean; + + abstract getInnerStates(): SimpleState[]; }