Introduce Symetric and Asymetric Template Relation Systems #40
@ -1,6 +1,14 @@
 | 
			
		||||
<div *ngIf="isGamesystemTemplate()">
 | 
			
		||||
  <mat-checkbox [(ngModel)]="convertGamesystemToTemplate(gamesystem)!.symmetric">Gamesystem is symmetric template</mat-checkbox>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()"  [templateElement]="templateElement" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()" [scriptAccunts]="scriptAccounts"></app-simple-gamesystem-editor>
 | 
			
		||||
<app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()"  [templateElement]="templateElement" [gamesystem]="convertGamesystemToProductGamesystem()"
 | 
			
		||||
                               (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor>
 | 
			
		||||
 | 
			
		||||
<mat-expansion-panel>
 | 
			
		||||
  <mat-expansion-panel-header>
 | 
			
		||||
    <mat-panel-title>Product Generation Settings</mat-panel-title>
 | 
			
		||||
  </mat-expansion-panel-header>
 | 
			
		||||
  <div *ngIf="isGamesystemTemplate()">
 | 
			
		||||
    <mat-checkbox [(ngModel)]="convertGamesystemToTemplate(gamesystem)!.symmetric">Use symmetric Productgenerators</mat-checkbox>
 | 
			
		||||
  </div>
 | 
			
		||||
  <mat-checkbox [(ngModel)]="gamesystem.generateIsolatedStates">Generate Isolated ProductStates</mat-checkbox>
 | 
			
		||||
</mat-expansion-panel>
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
<mat-checkbox [(ngModel)]="this.gamesystem!.generateIsolatedStates">Generate Isolated States</mat-checkbox>
 | 
			
		||||
 | 
			
		||||
<app-product-state-editor [templateElement]="templateElement" [gamesystem]="gamesystem" (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-state-editor>
 | 
			
		||||
<div id="productStateEditor">
 | 
			
		||||
  <app-product-transition-editor [templateElement]="templateElement" [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor>
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
 | 
			
		||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
			
		||||
import {
 | 
			
		||||
  ProductTransitionEditorComponent
 | 
			
		||||
} from "../transition-editor/product-transition-editor/product-transition-editor.component";
 | 
			
		||||
@ -13,12 +13,15 @@ import {TemplateElement} from "../../../project/game-model/templates/TemplateEle
 | 
			
		||||
  templateUrl: './product-gamesystem-editor.component.html',
 | 
			
		||||
  styleUrl: './product-gamesystem-editor.component.scss'
 | 
			
		||||
})
 | 
			
		||||
export class ProductGamesystemEditorComponent {
 | 
			
		||||
export class ProductGamesystemEditorComponent implements OnInit{
 | 
			
		||||
 | 
			
		||||
  @Input() gamesystem: ProductGamesystem | undefined
 | 
			
		||||
  @Input() templateElement: TemplateElement | undefined
 | 
			
		||||
  @Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>();
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onOpenGamesystemEditor(gamesystem: SimpleGamesystem) {
 | 
			
		||||
    this.openGamesystemEditorEmitter.emit(gamesystem);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -50,6 +50,7 @@ export class ProductStateEditorComponent implements OnInit{
 | 
			
		||||
    if(this.templateElement == undefined) {
 | 
			
		||||
      this.datasource.data = this.gamesystem!.states;
 | 
			
		||||
    } else if(this.gamesystem instanceof ProductTemplateSystem) {
 | 
			
		||||
      console.log("Product Template System: ", this.gamesystem!.stateMap.get(this.templateElement))
 | 
			
		||||
      this.datasource.data = this.gamesystem!.stateMap.get(this.templateElement)!
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,7 @@ export class CharacterRelation implements TemplateElement{
 | 
			
		||||
    if((gamesystem instanceof SimpleTemplateGamesystem || gamesystem instanceof ProductTemplateSystem) && !this.isGamesystemCharacterRelationSpecific(gamesystem.componentName)) {
 | 
			
		||||
       const templateGamesystem = new ProductTemplateSystem(gamesystem.componentName, gamesystem.componentDescription, TemplateType.CHARACTER_RELATION);
 | 
			
		||||
       templateGamesystem.symmetric = gamesystem.symmetric
 | 
			
		||||
       templateGamesystem.generateIsolatedStates = gamesystem.generateIsolatedStates
 | 
			
		||||
       templateGamesystem.addChildGamesystem(gamesystem);
 | 
			
		||||
       templateGamesystem.addChildGamesystem(gamesystem);
 | 
			
		||||
       this.characterRelationGamesystems.push(templateGamesystem);
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,8 @@ export abstract class Gamesystem<S, T> extends ModelComponent{
 | 
			
		||||
  states: S[] = [];
 | 
			
		||||
  transitions: T[] = [];
 | 
			
		||||
  parentGamesystem: ProductGamesystem | undefined
 | 
			
		||||
  generateIsolatedStates: boolean = true
 | 
			
		||||
 | 
			
		||||
  constructor(gamesystemName: string, gamesystemDescription: string) {
 | 
			
		||||
   super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,6 @@ import {IsolatedProductStateGenerator} from "./productSystemGenerator/IsolatedPr
 | 
			
		||||
export class ProductGamesystem extends Gamesystem<ProductState, ProductTransition> {
 | 
			
		||||
 | 
			
		||||
  innerGamesystems: Gamesystem<State<any>, Transition<any>>[] = [];
 | 
			
		||||
  generateIsolatedStates: boolean = false
 | 
			
		||||
 | 
			
		||||
  static constructFromSimpleGamesystem(simpleGamesystem: SimpleGamesystem, gameModel: GameModel) {
 | 
			
		||||
    const productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription);
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,8 @@ export class IsolatedProductStateGenerator extends ProductSystemGenerator {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) {
 | 
			
		||||
    this.productGamesystem.states = generationResult.states;
 | 
			
		||||
    this.productGamesystem.states = this.productGamesystem.states.concat(generationResult.states);
 | 
			
		||||
    console.log("Generation-Result: ", this.productGamesystem.states)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult {
 | 
			
		||||
 | 
			
		||||
@ -2,21 +2,42 @@ import {IsolatedTemplateStateGenerator} from "./IsolatedTemplateStateGenerator";
 | 
			
		||||
import {ProductGenerationData} from "./ProductGenerationData";
 | 
			
		||||
import {ProductGeneratorResult} from "./ProductGeneratorResult";
 | 
			
		||||
import {ProductState} from "../states/ProductState";
 | 
			
		||||
import {SimpleState} from "../states/SimpleState";
 | 
			
		||||
import {State} from "../states/State";
 | 
			
		||||
import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
 | 
			
		||||
 | 
			
		||||
export class IsolatedSymmetricTemplateStateGenerator extends IsolatedTemplateStateGenerator{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult {
 | 
			
		||||
    console.log("Calling test")
 | 
			
		||||
 | 
			
		||||
    console.log(leftSystemData.states)
 | 
			
		||||
    console.log(rightSystemData.states)
 | 
			
		||||
 | 
			
		||||
    const generatedProductStates: ProductState[] = []
 | 
			
		||||
    leftSystemData.states.forEach(leftState => {
 | 
			
		||||
      if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) {
 | 
			
		||||
        rightSystemData.states.forEach(rightState => {
 | 
			
		||||
          console.log("LeftState is isolated")
 | 
			
		||||
          if(leftState.equals(rightState)) {
 | 
			
		||||
            if(rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) {
 | 
			
		||||
              const leftConditions = this.getStateConditions(leftState, true);
 | 
			
		||||
              const rightConditions = this.getStateConditions(rightState, true);
 | 
			
		||||
 | 
			
		||||
              if(!this.contradictCombinedConditions(leftConditions, rightConditions)) {
 | 
			
		||||
                this.generateBinaryProductState(leftState, rightState, generatedProductStates);
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          if(leftState.equals(rightState) && rightState.outgoingTransitions.length == 0 && rightState.incomingTransitions.length == 0) {
 | 
			
		||||
            const leftConditions = this.getStateConditions(leftState, true);
 | 
			
		||||
            const rightConditions = this.getStateConditions(rightState, true);
 | 
			
		||||
 | 
			
		||||
            if(!this.contradictCombinedConditions(leftConditions, rightConditions)) {
 | 
			
		||||
              this.generateBinaryProductState(leftState, rightState, generatedProductStates);
 | 
			
		||||
              const generatedState = this.generateBinaryProductState(leftState, rightState, generatedProductStates);
 | 
			
		||||
              console.log(generatedProductStates)
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,8 @@ import {Character} from "../../characters/Character";
 | 
			
		||||
import {CharacterRelation} from "../../characters/CharacterRelation";
 | 
			
		||||
import {TemplateElement} from "../../templates/TemplateElement";
 | 
			
		||||
import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
 | 
			
		||||
import {ProductGeneratorResult} from "./ProductGeneratorResult";
 | 
			
		||||
import {state, transition} from "@angular/animations";
 | 
			
		||||
 | 
			
		||||
export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerator {
 | 
			
		||||
  templateElement: TemplateElement
 | 
			
		||||
@ -18,6 +20,13 @@ export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerato
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) {
 | 
			
		||||
    const templateSystem = this.productGamesystem as ProductTemplateSystem;
 | 
			
		||||
 | 
			
		||||
    const nonIsolatedStates = templateSystem.stateMap.get(this.templateElement)!
 | 
			
		||||
    const states = nonIsolatedStates.concat(generationResult.states);
 | 
			
		||||
    templateSystem.stateMap.set(this.templateElement, states)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected getTransitionConditions(transition: Transition<any>, leftSystem: boolean) {
 | 
			
		||||
    const templateElement = this.determineTemplateElement(leftSystem)!;
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,11 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template
 | 
			
		||||
 | 
			
		||||
      if(this.generateIsolatedStates) {
 | 
			
		||||
        const isolatedTemplateStateGenerator = new IsolatedSymmetricTemplateStateGenerator(this, templateElement);
 | 
			
		||||
        isolatedTemplateStateGenerator.generateFromChildsystems();
 | 
			
		||||
        isolatedTemplateStateGenerator.generateIsolatedProductStates();
 | 
			
		||||
        console.log(this.states)
 | 
			
		||||
        console.log("Generate symmetric isolated states")
 | 
			
		||||
      } else {
 | 
			
		||||
        console.log("Do not generate symmetric isolated states")
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement);
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,18 @@
 | 
			
		||||
                {
 | 
			
		||||
                    "stateLabel": "Fester Freund",
 | 
			
		||||
                    "conditionMap": []
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "stateLabel": "Eltern",
 | 
			
		||||
                    "conditionMap": []
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "stateLabel": "Geschwister",
 | 
			
		||||
                    "conditionMap": []
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "stateLabel": "Großeltern",
 | 
			
		||||
                    "conditionMap": []
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "transitions": [
 | 
			
		||||
@ -45,6 +57,7 @@
 | 
			
		||||
                    "actionMap": []
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "generateIsolatedStates": true,
 | 
			
		||||
            "symmetric": true
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,24 @@
 | 
			
		||||
            "conditions": [],
 | 
			
		||||
            "stateLabel": "Fester Freund",
 | 
			
		||||
            "stateDescription": ""
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "initial": false,
 | 
			
		||||
            "conditions": [],
 | 
			
		||||
            "stateLabel": "Eltern",
 | 
			
		||||
            "stateDescription": ""
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "initial": false,
 | 
			
		||||
            "conditions": [],
 | 
			
		||||
            "stateLabel": "Geschwister",
 | 
			
		||||
            "stateDescription": ""
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "initial": false,
 | 
			
		||||
            "conditions": [],
 | 
			
		||||
            "stateLabel": "Großeltern",
 | 
			
		||||
            "stateDescription": ""
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "transitions": [
 | 
			
		||||
@ -47,6 +65,7 @@
 | 
			
		||||
            "endingState": "Feind"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "generateIsolatedStates": true,
 | 
			
		||||
    "symmetric": true,
 | 
			
		||||
    "templateType": 1
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user