symetric-template-relation-systems #38
@ -21,6 +21,7 @@ export class CharacterRelation implements TemplateElement{
|
|||||||
addCharacterRelationSystem(gamesystem: Gamesystem<any, any>) {
|
addCharacterRelationSystem(gamesystem: Gamesystem<any, any>) {
|
||||||
if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) {
|
if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) {
|
||||||
const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION);
|
const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION);
|
||||||
|
templateGamesystem.symmetric = gamesystem.symmetric
|
||||||
templateGamesystem.addChildGamesystem(gamesystem);
|
templateGamesystem.addChildGamesystem(gamesystem);
|
||||||
templateGamesystem.addChildGamesystem(gamesystem);
|
templateGamesystem.addChildGamesystem(gamesystem);
|
||||||
this.characterRelationGamesystems.push(templateGamesystem);
|
this.characterRelationGamesystems.push(templateGamesystem);
|
||||||
|
@ -9,6 +9,7 @@ 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";
|
import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition";
|
||||||
|
import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
|
||||||
|
|
||||||
export class ProductSystemGenerator {
|
export class ProductSystemGenerator {
|
||||||
productGamesystem: ProductGamesystem
|
productGamesystem: ProductGamesystem
|
||||||
@ -106,6 +107,8 @@ export class ProductSystemGenerator {
|
|||||||
protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult): void {
|
protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult): void {
|
||||||
this.productGamesystem.states = generationResult.states;
|
this.productGamesystem.states = generationResult.states;
|
||||||
this.productGamesystem.transitions = generationResult.transitions;
|
this.productGamesystem.transitions = generationResult.transitions;
|
||||||
|
|
||||||
|
console.log("General ", generationResult.transitions.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[], leftSystem: boolean) {
|
protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[], leftSystem: boolean) {
|
||||||
|
@ -12,6 +12,7 @@ import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
|
|||||||
import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState";
|
import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState";
|
||||||
import {Character} from "../../characters/Character";
|
import {Character} from "../../characters/Character";
|
||||||
import {CharacterRelation} from "../../characters/CharacterRelation";
|
import {CharacterRelation} from "../../characters/CharacterRelation";
|
||||||
|
import {ProductGenerationData} from "./ProductGenerationData";
|
||||||
|
|
||||||
export class TemplateProductSystemGenerator extends ProductSystemGenerator {
|
export class TemplateProductSystemGenerator extends ProductSystemGenerator {
|
||||||
|
|
||||||
@ -28,7 +29,77 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator {
|
|||||||
productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions)
|
productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions)
|
||||||
productTemplateSystem.stateMap.set(this.templateElement, generationResult.states)
|
productTemplateSystem.stateMap.set(this.templateElement, generationResult.states)
|
||||||
|
|
||||||
console.log("Test")
|
console.log("Symmetric", (this.productGamesystem as ProductTemplateSystem).symmetric)
|
||||||
|
console.log("Template: ", generationResult.transitions.length)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected 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<leftState.outgoingTransitions.length; i++) {
|
||||||
|
for(let j=0; j<rightState.outgoingTransitions.length; j++) {
|
||||||
|
const startingState = this.generateBinaryProductState(leftState, rightState, generatedProductStates);
|
||||||
|
|
||||||
|
if(startingState != undefined) {
|
||||||
|
|
||||||
|
if(!(this.productGamesystem as ProductTemplateSystem).symmetric) {
|
||||||
|
const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
||||||
|
if(endingState_right != undefined) {
|
||||||
|
this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
|
||||||
|
if(endingState_left != undefined) {
|
||||||
|
this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i], generatedProductTransitions, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
||||||
|
if(endingState_left_right != undefined) {
|
||||||
|
if((this.productGamesystem as ProductTemplateSystem).symmetric) {
|
||||||
|
if(leftState.equals(rightState) && leftState.outgoingTransitions[i].endingState.equals(rightState.outgoingTransitions[j].endingState)) {
|
||||||
|
this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j], generatedProductTransitions);
|
||||||
|
} else {
|
||||||
|
console.log(startingState , endingState_left_right)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j], generatedProductTransitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rightState.outgoingTransitions.length == 0 && !(this.productGamesystem as ProductTemplateSystem).symmetric) {
|
||||||
|
const startingState = this.generateBinaryProductState(leftState, rightState, generatedProductStates);
|
||||||
|
const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
|
||||||
|
|
||||||
|
if(startingState != undefined && endingState != undefined) {
|
||||||
|
this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions, true)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(leftState.outgoingTransitions.length == 0 && !(this.productGamesystem as ProductTemplateSystem).symmetric) {
|
||||||
|
for(let j=0; j<rightState.outgoingTransitions.length; j++) {
|
||||||
|
const startingState = this.generateBinaryProductState(leftState, rightState, generatedProductStates);
|
||||||
|
const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
||||||
|
|
||||||
|
if(startingState != undefined && endingState != undefined) {
|
||||||
|
this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return new ProductGeneratorResult(generatedProductStates, generatedProductTransitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getTransitionConditions(transition: Transition<any>, leftSystem: boolean) {
|
protected getTransitionConditions(transition: Transition<any>, leftSystem: boolean) {
|
||||||
|
Loading…
Reference in New Issue
Block a user