Compare commits
2 Commits
cb2e706ac7
...
b874188b10
Author | SHA1 | Date | |
---|---|---|---|
b874188b10 | |||
|
42388de905 |
@ -8,6 +8,7 @@ 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
|
||||||
@ -109,8 +110,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 = [... usedTransition.scriptAccountActions];
|
transition.scriptAccountActions = [... this.getTransitionActions(usedTransition)];
|
||||||
transition.scriptAccountConditions = [... usedTransition.scriptAccountConditions];
|
transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition)];
|
||||||
|
|
||||||
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)
|
||||||
@ -118,13 +119,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 = leftTransition.scriptAccountConditions;
|
const leftConditions = this.getTransitionConditions(leftTransition)
|
||||||
const rightConditions = rightTransition.scriptAccountConditions;
|
const rightConditions = this.getTransitionConditions(rightTransition)
|
||||||
|
|
||||||
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(leftTransition.scriptAccountActions, rightTransition.scriptAccountActions);
|
transition.scriptAccountActions = this.generateCombinedActions(this.getTransitionActions(leftTransition), this.getTransitionActions(rightTransition));
|
||||||
transition.scriptAccountConditions = this.generateCombinedConditions(leftTransition.scriptAccountConditions, rightTransition.scriptAccountConditions);
|
transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition), this.getTransitionConditions(rightTransition));
|
||||||
|
|
||||||
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)
|
||||||
@ -133,7 +134,10 @@ 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 combinedStateConditions: ScriptAccountCondition[] = leftState.conditions.concat(rightState.conditions);
|
const leftConditions = this.getStateConditions(leftState)
|
||||||
|
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])) {
|
||||||
@ -227,4 +231,16 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ 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{
|
||||||
|
|
||||||
@ -20,7 +21,8 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTemplateElement(templateElement: TemplateElement): void {
|
addTemplateElement(templateElement: TemplateElement): void {
|
||||||
|
const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement);
|
||||||
|
productTemplateGenerator.generateFromChildsystems()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user