Compare commits

..

No commits in common. "b874188b10ac6f7fc049e6df892220cb0c3d0631" and "cb2e706ac765145e7033ac15044809ba79e87d4d" have entirely different histories.

3 changed files with 8 additions and 80 deletions

View File

@ -8,7 +8,6 @@ import {ProductGeneratorResult} from "./ProductGeneratorResult";
import {Gamesystem} from "../Gamesystem"; import {Gamesystem} from "../Gamesystem";
import {ProductGenerationData} from "./ProductGenerationData"; import {ProductGenerationData} from "./ProductGenerationData";
import {ProductTransition} from "../transitions/ProductTransition"; import {ProductTransition} from "../transitions/ProductTransition";
import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition";
export class ProductSystemGenerator { export class ProductSystemGenerator {
productGamesystem: ProductGamesystem productGamesystem: ProductGamesystem
@ -110,8 +109,8 @@ export class ProductSystemGenerator {
protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[]) { protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[]) {
const transition = new ProductTransition(startingState, endingState); const transition = new ProductTransition(startingState, endingState);
transition.scriptAccountActions = [... this.getTransitionActions(usedTransition)]; transition.scriptAccountActions = [... usedTransition.scriptAccountActions];
transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition)]; transition.scriptAccountConditions = [... usedTransition.scriptAccountConditions];
if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) {
generatedTransitions.push(transition) generatedTransitions.push(transition)
@ -119,13 +118,13 @@ export class ProductSystemGenerator {
} }
protected generateBinaryProductTransitionMulti(startingState: ProductState, endingState: ProductState, leftTransition: Transition<any>, rightTransition: Transition<any>, generatedTransitions: ProductTransition[]) { protected generateBinaryProductTransitionMulti(startingState: ProductState, endingState: ProductState, leftTransition: Transition<any>, rightTransition: Transition<any>, generatedTransitions: ProductTransition[]) {
const leftConditions = this.getTransitionConditions(leftTransition) const leftConditions = leftTransition.scriptAccountConditions;
const rightConditions = this.getTransitionConditions(rightTransition) const rightConditions = rightTransition.scriptAccountConditions;
if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { if(!this.contradictCombinedConditions(leftConditions, rightConditions)) {
const transition = new ProductTransition(startingState, endingState) const transition = new ProductTransition(startingState, endingState)
transition.scriptAccountActions = this.generateCombinedActions(this.getTransitionActions(leftTransition), this.getTransitionActions(rightTransition)); transition.scriptAccountActions = this.generateCombinedActions(leftTransition.scriptAccountActions, rightTransition.scriptAccountActions);
transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition), this.getTransitionConditions(rightTransition)); transition.scriptAccountConditions = this.generateCombinedConditions(leftTransition.scriptAccountConditions, rightTransition.scriptAccountConditions);
if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) {
generatedTransitions.push(transition) generatedTransitions.push(transition)
@ -134,10 +133,7 @@ export class ProductSystemGenerator {
} }
protected generateBinaryProductState(leftState: State<any>, rightState: State<any>, generatedStates: ProductState[]): ProductState | undefined { protected generateBinaryProductState(leftState: State<any>, rightState: State<any>, generatedStates: ProductState[]): ProductState | undefined {
const leftConditions = this.getStateConditions(leftState) const combinedStateConditions: ScriptAccountCondition[] = leftState.conditions.concat(rightState.conditions);
const rightConditions = this.getStateConditions(rightState)
const combinedStateConditions: ScriptAccountCondition[] = leftConditions.concat(rightConditions)
for(let i=0; i<combinedStateConditions.length; i++) { for(let i=0; i<combinedStateConditions.length; i++) {
for(let j=0; j<combinedStateConditions.length; j++) { for(let j=0; j<combinedStateConditions.length; j++) {
if(combinedStateConditions[i].isContradicting(combinedStateConditions[j])) { if(combinedStateConditions[i].isContradicting(combinedStateConditions[j])) {
@ -231,16 +227,4 @@ export class ProductSystemGenerator {
return false; return false;
} }
protected getTransitionConditions(transition: Transition<any>) {
return transition.scriptAccountConditions;
}
protected getTransitionActions(transition: Transition<any>) {
return transition.scriptAccountActions;
}
protected getStateConditions(state: State<any>) {
return state.conditions;
}
} }

View File

@ -1,54 +0,0 @@
import {ProductSystemGenerator} from "./ProductSystemGenerator";
import {ProductGeneratorResult} from "./ProductGeneratorResult";
import {TemplateElement} from "../../templates/TemplateElement";
import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
import {ProductState} from "../states/ProductState";
import {Transition} from "../transitions/Transition";
import {ProductTransition} from "../transitions/ProductTransition";
import {State} from "../states/State";
import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition";
import {state, transition} from "@angular/animations";
import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState";
export class TemplateProductSystemGenerator extends ProductSystemGenerator {
templateElement: TemplateElement
constructor(productGamesystem: ProductTemplateSystem, templateElement: TemplateElement) {
super(productGamesystem);
this.templateElement = templateElement;
}
protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) {
const productTemplateSystem = this.productGamesystem as ProductTemplateSystem
productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions)
productTemplateSystem.stateMap.set(this.templateElement, generationResult.states)
}
protected getTransitionConditions(transition: Transition<any>) {
if(transition instanceof SimpleTemplateTransition) {
return transition.conditionMap.get(this.templateElement)!
} else {
return transition.scriptAccountConditions;
}
}
protected getTransitionActions(transition: Transition<any>) {
if(transition instanceof SimpleTemplateTransition) {
return transition.actionMap.get(this.templateElement)!
} else {
return transition.scriptAccountActions;
}
}
protected getStateConditions(state: State<any>): ScriptAccountCondition[] {
if(state instanceof SimpleTemplateState) {
return state.conditionMap.get(this.templateElement)!
} else {
return state.conditions
}
}
}

View File

@ -6,7 +6,6 @@ import {ProductTransition} from "../../gamesystems/transitions/ProductTransition
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
import {GameModel} from "../../GameModel"; import {GameModel} from "../../GameModel";
import {TemplateType} from "../TemplateType"; import {TemplateType} from "../TemplateType";
import {TemplateProductSystemGenerator} from "../../gamesystems/productSystemGenerator/TemplateProductSystemGenerator";
export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{
@ -21,8 +20,7 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template
} }
addTemplateElement(templateElement: TemplateElement): void { addTemplateElement(templateElement: TemplateElement): void {
const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement);
productTemplateGenerator.generateFromChildsystems()
} }
} }