isolated-state-generation #39
@ -31,7 +31,7 @@ export class IsolatedProductStateGenerator extends ProductSystemGenerator {
 | 
				
			|||||||
    this.productGamesystem.states = generationResult.states;
 | 
					    this.productGamesystem.states = generationResult.states;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult {
 | 
					  protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult {
 | 
				
			||||||
    const generatedProductStates: ProductState[] = []
 | 
					    const generatedProductStates: ProductState[] = []
 | 
				
			||||||
    leftSystemData.states.forEach(leftState => {
 | 
					    leftSystemData.states.forEach(leftState => {
 | 
				
			||||||
      if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) {
 | 
					      if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) {
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					import {IsolatedProductStateGenerator} from "./IsolatedProductStateGenerator";
 | 
				
			||||||
 | 
					import {Transition} from "../transitions/Transition";
 | 
				
			||||||
 | 
					import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition";
 | 
				
			||||||
 | 
					import {State} from "../states/State";
 | 
				
			||||||
 | 
					import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
 | 
				
			||||||
 | 
					import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState";
 | 
				
			||||||
 | 
					import {Character} from "../../characters/Character";
 | 
				
			||||||
 | 
					import {CharacterRelation} from "../../characters/CharacterRelation";
 | 
				
			||||||
 | 
					import {TemplateElement} from "../../templates/TemplateElement";
 | 
				
			||||||
 | 
					import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerator {
 | 
				
			||||||
 | 
					  templateElement: TemplateElement
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  constructor(productGamesystem: ProductTemplateSystem, templateElement: TemplateElement) {
 | 
				
			||||||
 | 
					    super(productGamesystem);
 | 
				
			||||||
 | 
					    this.templateElement = templateElement;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  protected getTransitionConditions(transition: Transition<any>, leftSystem: boolean) {
 | 
				
			||||||
 | 
					    const templateElement = this.determineTemplateElement(leftSystem)!;
 | 
				
			||||||
 | 
					    if(transition instanceof SimpleTemplateTransition && transition.conditionMap.has(templateElement)) {
 | 
				
			||||||
 | 
					      return transition.conditionMap.get(templateElement)!
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return transition.scriptAccountConditions;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  protected getTransitionActions(transition: Transition<any>, leftSystem: boolean) {
 | 
				
			||||||
 | 
					    const templateElement = this.determineTemplateElement(leftSystem)!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(transition instanceof SimpleTemplateTransition && transition.actionMap.has(templateElement)) {
 | 
				
			||||||
 | 
					      return transition.actionMap.get(templateElement)!
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      return transition.scriptAccountActions;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  protected getStateConditions(state: State<any>, leftSystem: boolean): ScriptAccountCondition[] {
 | 
				
			||||||
 | 
					    const templateElement = this.determineTemplateElement(leftSystem)!
 | 
				
			||||||
 | 
					    if(state instanceof  SimpleTemplateState && state.conditionMap.has(templateElement)) {
 | 
				
			||||||
 | 
					      return state.conditionMap.get(templateElement)!
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      return state.conditions
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  private determineTemplateElement(leftSystem: boolean) {
 | 
				
			||||||
 | 
					    if(this.templateElement instanceof Character) {
 | 
				
			||||||
 | 
					      return this.templateElement;
 | 
				
			||||||
 | 
					    } else if(this.templateElement instanceof CharacterRelation) {
 | 
				
			||||||
 | 
					      return leftSystem ? this.templateElement.firstCharacter : this.templateElement.secondCharacter;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -10,6 +10,7 @@ import {TemplateProductSystemGenerator} from "../../gamesystems/productSystemGen
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
  SymmetricProductTemplateGenerator
 | 
					  SymmetricProductTemplateGenerator
 | 
				
			||||||
} from "../../gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator";
 | 
					} from "../../gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator";
 | 
				
			||||||
 | 
					import {IsolatedTemplateStateGenerator} from "../../gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{
 | 
					export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,6 +34,8 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template
 | 
				
			|||||||
      productTemplateGenerator.generateFromChildsystems()
 | 
					      productTemplateGenerator.generateFromChildsystems()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const isolatedTemplateStateGenerator = new IsolatedTemplateStateGenerator(this, templateElement);
 | 
				
			||||||
 | 
					    isolatedTemplateStateGenerator.generateIsolatedProductStates();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user