issue-5-product-gamesystems #10
@ -11,7 +11,8 @@
 | 
				
			|||||||
    <app-script-account-editor *ngIf="modelComponent.type === ModelComponentType.SCRIPTACCOUNT"
 | 
					    <app-script-account-editor *ngIf="modelComponent.type === ModelComponentType.SCRIPTACCOUNT"
 | 
				
			||||||
                               [scriptAccount]="convertModelComponentToScriptAccount(modelComponent)"></app-script-account-editor>
 | 
					                               [scriptAccount]="convertModelComponentToScriptAccount(modelComponent)"></app-script-account-editor>
 | 
				
			||||||
    <app-gamesystem-editor *ngIf="modelComponent.type == ModelComponentType.GAMESYTEM"
 | 
					    <app-gamesystem-editor *ngIf="modelComponent.type == ModelComponentType.GAMESYTEM"
 | 
				
			||||||
                                [gamesystem]="convertModelComponentToGamesystem(modelComponent)"></app-gamesystem-editor>
 | 
					                                [gamesystem]="convertModelComponentToGamesystem(modelComponent)"
 | 
				
			||||||
 | 
					                                (onOpenGamesystemEditor)="openGameModelComponent($event)"></app-gamesystem-editor>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  </mat-tab>
 | 
					  </mat-tab>
 | 
				
			||||||
</mat-tab-group>
 | 
					</mat-tab-group>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,2 +1,3 @@
 | 
				
			|||||||
<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()"></app-simple-gamesystem-editor>
 | 
					<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()"></app-simple-gamesystem-editor>
 | 
				
			||||||
<app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [gamesystem]="convertGamesystemToProductGamesystem()"></app-product-gamesystem-editor>
 | 
					<app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [gamesystem]="convertGamesystemToProductGamesystem()"
 | 
				
			||||||
 | 
					                               (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
import {Component, Input} from '@angular/core';
 | 
					import {Component, EventEmitter, Input, Output} from '@angular/core';
 | 
				
			||||||
import {GameModel} from "../../game-model/GameModel";
 | 
					import {GameModel} from "../../game-model/GameModel";
 | 
				
			||||||
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
 | 
					import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
 | 
				
			||||||
import {State} from "../../game-model/gamesystems/State";
 | 
					import {State} from "../../game-model/gamesystems/State";
 | 
				
			||||||
@ -14,6 +14,7 @@ import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"
 | 
				
			|||||||
export class GamesystemEditorComponent {
 | 
					export class GamesystemEditorComponent {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Input() gamesystem: Gamesystem<State<any>, Transition<any>> | undefined
 | 
					  @Input() gamesystem: Gamesystem<State<any>, Transition<any>> | undefined
 | 
				
			||||||
 | 
					  @Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter<SimpleGamesystem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  isSimpleGamesystem() {
 | 
					  isSimpleGamesystem() {
 | 
				
			||||||
    return this.gamesystem instanceof SimpleGamesystem;
 | 
					    return this.gamesystem instanceof SimpleGamesystem;
 | 
				
			||||||
@ -30,4 +31,8 @@ export class GamesystemEditorComponent {
 | 
				
			|||||||
      return this.gamesystem as ProductGamesystem;
 | 
					      return this.gamesystem as ProductGamesystem;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  onOpenGamesystemEditor(gamesystem: SimpleGamesystem) {
 | 
				
			||||||
 | 
					    this.openGamesystemEmitter.emit(gamesystem);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1 +1 @@
 | 
				
			|||||||
<app-product-state-editor [gamesystem]="gamesystem"></app-product-state-editor>
 | 
					<app-product-state-editor [gamesystem]="gamesystem" (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-state-editor>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
import {Component, Input} from '@angular/core';
 | 
					import {Component, EventEmitter, Input, Output} from '@angular/core';
 | 
				
			||||||
import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem";
 | 
					import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem";
 | 
				
			||||||
import {ProductStateEditorComponent} from "../state-editor/product-state-editor/product-state-editor.component";
 | 
					import {ProductStateEditorComponent} from "../state-editor/product-state-editor/product-state-editor.component";
 | 
				
			||||||
 | 
					import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-product-gamesystem-editor',
 | 
					  selector: 'app-product-gamesystem-editor',
 | 
				
			||||||
@ -14,4 +15,9 @@ import {ProductStateEditorComponent} from "../state-editor/product-state-editor/
 | 
				
			|||||||
export class ProductGamesystemEditorComponent {
 | 
					export class ProductGamesystemEditorComponent {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Input() gamesystem: ProductGamesystem | undefined
 | 
					  @Input() gamesystem: ProductGamesystem | undefined
 | 
				
			||||||
 | 
					  @Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  onOpenGamesystemEditor(gamesystem: SimpleGamesystem) {
 | 
				
			||||||
 | 
					    this.openGamesystemEditorEmitter.emit(gamesystem);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
  <ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col">
 | 
					  <ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col">
 | 
				
			||||||
    <th mat-header-cell *matHeaderCellDef>{{col}}</th>
 | 
					    <th mat-header-cell *matHeaderCellDef>{{col}}</th>
 | 
				
			||||||
    <td mat-cell *matCellDef="let state">
 | 
					    <td mat-cell *matCellDef="let state">
 | 
				
			||||||
      <span *ngIf="i < displayedColumns.length-1">{{getStateLabel(state, i)}}</span>
 | 
					      <a *ngIf="i < displayedColumns.length-1" role="button" (click)="clickOnInnerState(i)">{{getLeafState(state, i).stateLabel}}</a>
 | 
				
			||||||
      <mat-icon *ngIf="i == displayedColumns.length-1">
 | 
					      <mat-icon *ngIf="i == displayedColumns.length-1">
 | 
				
			||||||
        {{state.initial? 'done':'close'}}
 | 
					        {{state.initial? 'done':'close'}}
 | 
				
			||||||
      </mat-icon>
 | 
					      </mat-icon>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
import {Component, Input, OnInit} from '@angular/core';
 | 
					import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
 | 
				
			||||||
import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem";
 | 
					import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem";
 | 
				
			||||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
 | 
					import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@ -16,6 +16,7 @@ import {State} from "../../../../game-model/gamesystems/State";
 | 
				
			|||||||
import {NgForOf, NgIf} from "@angular/common";
 | 
					import {NgForOf, NgIf} from "@angular/common";
 | 
				
			||||||
import {ProductState} from "../../../../game-model/gamesystems/ProductState";
 | 
					import {ProductState} from "../../../../game-model/gamesystems/ProductState";
 | 
				
			||||||
import {MatIcon} from "@angular/material/icon";
 | 
					import {MatIcon} from "@angular/material/icon";
 | 
				
			||||||
 | 
					import {Gamesystem} from "../../../../game-model/gamesystems/Gamesystem";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-product-state-editor',
 | 
					  selector: 'app-product-state-editor',
 | 
				
			||||||
@ -41,6 +42,7 @@ import {MatIcon} from "@angular/material/icon";
 | 
				
			|||||||
export class ProductStateEditorComponent implements OnInit{
 | 
					export class ProductStateEditorComponent implements OnInit{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Input() gamesystem: ProductGamesystem | undefined
 | 
					  @Input() gamesystem: ProductGamesystem | undefined
 | 
				
			||||||
 | 
					  @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>();
 | 
				
			||||||
  displayedColumns: string[] = [];
 | 
					  displayedColumns: string[] = [];
 | 
				
			||||||
  datasource = new MatTableDataSource();
 | 
					  datasource = new MatTableDataSource();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -64,8 +66,8 @@ export class ProductStateEditorComponent implements OnInit{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  protected readonly SimpleState = SimpleState;
 | 
					  protected readonly SimpleState = SimpleState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getStateLabel(state: State<any>, i: number) {
 | 
					  getLeafState(state: State<any>, i: number) {
 | 
				
			||||||
    return this.computeLeafStates(state)[i].stateLabel;
 | 
					    return this.computeLeafStates(state)[i];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  computeLeafStates(state: State<any>) {
 | 
					  computeLeafStates(state: State<any>) {
 | 
				
			||||||
@ -80,4 +82,23 @@ export class ProductStateEditorComponent implements OnInit{
 | 
				
			|||||||
      return leafStates;
 | 
					      return leafStates;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  clickOnInnerState(leafIndex: number) {
 | 
				
			||||||
 | 
					    const leaf_gamesystems = this.computeLeafGamesystems(this.gamesystem!);
 | 
				
			||||||
 | 
					    const clicked_gamesystem = leaf_gamesystems[leafIndex];
 | 
				
			||||||
 | 
					    this.openGamesystemEditorEmitter.emit(clicked_gamesystem);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  computeLeafGamesystems(gamesystem: Gamesystem<any, any>) {
 | 
				
			||||||
 | 
					    if(gamesystem instanceof SimpleGamesystem) {
 | 
				
			||||||
 | 
					      return [gamesystem];
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      const product_gamesystem = gamesystem as ProductGamesystem;
 | 
				
			||||||
 | 
					      const leaf_gamesystems: SimpleGamesystem[] = [];
 | 
				
			||||||
 | 
					      product_gamesystem.innerGamesystems.forEach(innerGamesystem => {
 | 
				
			||||||
 | 
					        this.computeLeafGamesystems(innerGamesystem).forEach(leafGamesystem => leaf_gamesystems.push(leafGamesystem))
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      return leaf_gamesystems;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user