Compare commits

...

31 Commits

Author SHA1 Message Date
c74906687d Merge pull request 'template-systems' (#41) from template-systems into main
All checks were successful
E2E Testing / test (push) Successful in 1m34s
Reviewed-on: #41
2024-04-19 21:10:00 +02:00
Sebastian Böckelmann
d59534c93e Remove Debugging Printing
All checks were successful
E2E Testing / test (push) Successful in 1m30s
2024-04-19 21:07:37 +02:00
Sebastian Böckelmann
9df0a07b1f Load initialMap
All checks were successful
E2E Testing / test (push) Successful in 1m35s
2024-04-19 21:03:05 +02:00
Sebastian Böckelmann
8521d80881 Add templateElement to initialMap independent of conditionMap and serialize initialMap
All checks were successful
E2E Testing / test (push) Successful in 1m35s
2024-04-19 20:59:45 +02:00
Sebastian Böckelmann
ce344fe303 Introduce state-initial-editor
All checks were successful
E2E Testing / test (push) Successful in 1m31s
2024-04-19 20:47:00 +02:00
Sebastian Böckelmann
2e6363e090 Edit Initial Value of SimpleState per TemplateElement
Some checks failed
E2E Testing / test (push) Failing after 1m30s
2024-04-19 20:46:37 +02:00
Sebastian Böckelmann
743af8c0a1 Serialize and Load Gernation Settings of Gamesystems
All checks were successful
E2E Testing / test (push) Successful in 1m34s
2024-04-19 20:13:13 +02:00
8b0b8c5234 Merge pull request 'Introduce Symetric and Asymetric Template Relation Systems' (#40) from assymetric-template-relation-systems into template-systems
All checks were successful
E2E Testing / test (push) Successful in 1m36s
Reviewed-on: #40
2024-04-19 20:04:53 +02:00
0979d2c678 Merge pull request 'isolated-state-generation' (#39) from isolated-state-generation into assymetric-template-relation-systems
All checks were successful
E2E Testing / test (push) Successful in 1m32s
Reviewed-on: #39
2024-04-19 20:03:10 +02:00
Sebastian Böckelmann
48478d340a Fix gamesystem undefined error in gamesystem-editor
All checks were successful
E2E Testing / test (push) Successful in 1m31s
2024-04-19 20:01:22 +02:00
Sebastian Böckelmann
5b1e711a11 Change symmetric default values to be false
Some checks failed
E2E Testing / test (push) Failing after 1m29s
2024-04-19 19:56:04 +02:00
Sebastian Böckelmann
0104df8084 Add generated isolated states to already generated states
Some checks failed
E2E Testing / test (push) Failing after 1m31s
2024-04-19 19:53:31 +02:00
Sebastian Böckelmann
7cb02030d9 Generate only symmetric isolated states
All checks were successful
E2E Testing / test (push) Successful in 1m36s
2024-04-19 17:52:50 +02:00
Sebastian Böckelmann
87a0dd775e Generate isolated states only on demand
All checks were successful
E2E Testing / test (push) Successful in 1m40s
2024-04-19 17:50:03 +02:00
Sebastian Böckelmann
ee970db716 Generate isolated template States
Some checks failed
E2E Testing / test (push) Failing after 1m43s
2024-04-19 17:45:58 +02:00
Sebastian Böckelmann
3d9db9b143 Generate isolated states
Some checks failed
E2E Testing / test (push) Failing after 1m43s
2024-04-19 17:42:25 +02:00
3e3b03d722 Merge pull request 'symetric-template-relation-systems' (#38) from symetric-template-relation-systems into assymetric-template-relation-systems
All checks were successful
E2E Testing / test (push) Successful in 1m40s
Reviewed-on: #38
2024-04-19 17:26:00 +02:00
Sebastian Böckelmann
909e2f5c46 Remove unreachable states when generating symmetric-product-template
All checks were successful
E2E Testing / test (push) Successful in 1m33s
2024-04-19 16:55:30 +02:00
Sebastian Böckelmann
566a58e35c Adjust symmetric Productsystemgeneration
All checks were successful
E2E Testing / test (push) Successful in 1m59s
2024-04-19 16:40:01 +02:00
6381488fa1 Merge pull request 'Fix Product Template Generation for Relations (generation was not triggered)' (#37) from assymetric-template-relation-systems into symetric-template-relation-systems
All checks were successful
E2E Testing / test (push) Successful in 1m31s
Reviewed-on: #37
2024-04-19 16:07:49 +02:00
Sebastian Böckelmann
f98ad400e3 Fix Product Template Generation for Relations (generation was not triggered)
All checks were successful
E2E Testing / test (push) Successful in 1m34s
2024-04-19 16:07:08 +02:00
Sebastian Böckelmann
cfc23efb71 Introduce symmetric flag in Gamesystem Properties
All checks were successful
E2E Testing / test (push) Successful in 1m36s
2024-04-19 15:52:52 +02:00
Sebastian Böckelmann
98ef46b83a Adapt Product Gamesystem Editor for Productsystems with identical innersystems
All checks were successful
E2E Testing / test (push) Successful in 1m32s
2024-04-19 15:27:23 +02:00
Sebastian Böckelmann
3efa612435 Open CharacterRelationSpecific Gamesystem in GamesystemEditor
All checks were successful
E2E Testing / test (push) Successful in 1m33s
2024-04-19 14:52:59 +02:00
Sebastian Böckelmann
448ff5bd1b Add CharacterRelation Gamesystems to CharacterRelation and adjust ProductGeneration
All checks were successful
E2E Testing / test (push) Successful in 1m36s
2024-04-19 14:46:02 +02:00
Sebastian Böckelmann
5074396f88 Fix wrong reference to characterRelationGamesystems
All checks were successful
E2E Testing / test (push) Successful in 1m32s
2024-04-19 14:24:00 +02:00
Sebastian Böckelmann
fee41efb21 Serialize and Load Character-Relation Specific Gamesystems
Some checks failed
E2E Testing / test (push) Failing after 1m30s
2024-04-19 14:23:17 +02:00
Sebastian Böckelmann
6a711ec579 Add Character as TemplateElement to added character-relation specific assymetric gamesystems
All checks were successful
E2E Testing / test (push) Successful in 1m33s
2024-04-19 13:49:01 +02:00
Sebastian Böckelmann
93498845ec Add Character-Relation-Specific Gamesystems
All checks were successful
E2E Testing / test (push) Successful in 1m34s
2024-04-19 12:52:20 +02:00
Sebastian Böckelmann
26db5392a4 Introduce Concept of Character-Relations
All checks were successful
E2E Testing / test (push) Successful in 1m33s
2024-04-19 12:32:31 +02:00
Sebastian Böckelmann
b2b4b936cd Introduce new TemplateType: Character-Relation
All checks were successful
E2E Testing / test (push) Successful in 1m41s
2024-04-19 11:58:31 +02:00
56 changed files with 902 additions and 539 deletions

View File

@ -76,6 +76,12 @@ function createWindow(): BrowserWindow {
click: () => { click: () => {
win!.webContents.send('context-menu', "new-gamesystem-character"); win!.webContents.send('context-menu', "new-gamesystem-character");
} }
},
{
label: "Character-Relation",
click: () => {
win!.webContents.send('context-menu', "new-gamesystem-character_relation");
}
} }
] ]
}, },

View File

@ -219,7 +219,8 @@ export class AppComponent implements OnInit{
gameModel.generateProductSystemContents() gameModel.generateProductSystemContents()
const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem) const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
const characterParser = new CharacterParser(characterTemplateSystems, gameModel.scriptAccounts); const characterRelationTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER_RELATION).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
const characterParser = new CharacterParser(characterTemplateSystems, characterRelationTemplateSystems, gameModel.scriptAccounts);
gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters) gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters)
this.gameModel = gameModel; this.gameModel = gameModel;

View File

@ -79,6 +79,9 @@ import {
import { import {
TemplateSpecificatorComponent TemplateSpecificatorComponent
} from "./editor/gamesystem-editor/template-specificator/template-specificator.component"; } from "./editor/gamesystem-editor/template-specificator/template-specificator.component";
import {
StateInitialCellComponent
} from "./editor/gamesystem-editor/state-editor/simple-state-editor/state-initial-cell/state-initial-cell.component";
// AoT requires an exported function for factories // AoT requires an exported function for factories
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
@ -103,7 +106,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
ScriptaccountConditionEditorComponent, ScriptaccountConditionEditorComponent,
CharacterOverviewComponent, CharacterOverviewComponent,
CharacterEditorComponent, CharacterEditorComponent,
TemplateSpecificatorComponent TemplateSpecificatorComponent,
StateInitialCellComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -14,3 +14,45 @@
<button mat-stroked-button class="specify-btn" (click)="openTemplateSpecificator()">Specify Templatesystem</button> <button mat-stroked-button class="specify-btn" (click)="openTemplateSpecificator()">Specify Templatesystem</button>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
<mat-card>
<mat-card-header>
<mat-card-title>Characterrelationspecifc Gamesystems</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-accordion>
<mat-expansion-panel *ngFor="let templateSystem of character!.characterRelationGamesystems">
<mat-expansion-panel-header>
<mat-panel-title>{{templateSystem.componentName}}</mat-panel-title>
</mat-expansion-panel-header>
<app-gamesystem-editor [templateElement]="character" [gamesystem]="templateSystem" [scriptAccounts]="gameModel!.scriptAccounts"></app-gamesystem-editor>
</mat-expansion-panel>
<button mat-stroked-button class="specify-btn" (click)="openCharacterRelationTemplateSpecificator()">Specify Templatesystem</button>
</mat-accordion>
</mat-card-content>
</mat-card>
<mat-card>
<mat-card-header>
<mat-card-title>Character-Relations</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-accordion>
<mat-expansion-panel *ngFor="let characterRelation of character!.characterRelations">
<mat-expansion-panel-header>
<mat-panel-title>{{characterRelation.firstCharacter.componentName}} - {{characterRelation.secondCharacter.componentName}}</mat-panel-title>
</mat-expansion-panel-header>
<p>Templatesystems: {{characterRelation.characterRelationGamesystems.length}}</p>
<mat-accordion>
<mat-expansion-panel *ngFor="let templateSystem of characterRelation.characterRelationGamesystems">
<mat-expansion-panel-header>
<mat-panel-title>{{templateSystem.componentName}}</mat-panel-title>
</mat-expansion-panel-header>
<app-product-gamesystem-editor [gamesystem]="templateSystem" [templateElement]="characterRelation"></app-product-gamesystem-editor>
</mat-expansion-panel>
</mat-accordion>
</mat-expansion-panel>
</mat-accordion>
</mat-card-content>
</mat-card>

View File

@ -29,4 +29,12 @@ export class CharacterEditorComponent {
}) })
} }
openCharacterRelationTemplateSpecificator() {
const dialogRef = this.dialog.open(TemplateSpecificatorComponent, {data: this.gameModel!.getTemplateSystems(TemplateType.CHARACTER_RELATION), minWidth: "400px"});
dialogRef.afterClosed().subscribe(res => {
if(res != undefined) {
this.character!.addAsymetricCharacterRelationGamesystem(res);
}
})
}
} }

View File

@ -1,3 +1,14 @@
<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [templateElement]="templateElement" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()" [scriptAccunts]="scriptAccounts"></app-simple-gamesystem-editor> <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()" <app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [templateElement]="templateElement" [gamesystem]="convertGamesystemToProductGamesystem()"
(onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor> (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor>
<mat-expansion-panel *ngIf="gamesystem != undefined">
<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>

View File

@ -6,6 +6,8 @@ import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccou
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
import {TemplateElement} from "../../project/game-model/templates/TemplateElement"; import {TemplateElement} from "../../project/game-model/templates/TemplateElement";
import {SimpleTemplateGamesystem} from "../../project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem";
import {ProductTemplateSystem} from "../../project/game-model/templates/productGamesystem/ProductTemplateSystem";
@Component({ @Component({
selector: 'app-gamesystem-editor', selector: 'app-gamesystem-editor',
@ -42,4 +44,19 @@ export class GamesystemEditorComponent implements OnInit{
onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { onOpenGamesystemEditor(gamesystem: SimpleGamesystem) {
this.openGamesystemEmitter.emit(gamesystem); this.openGamesystemEmitter.emit(gamesystem);
} }
isGamesystemTemplate() {
return this.gamesystem instanceof SimpleTemplateGamesystem || this.gamesystem instanceof ProductTemplateSystem;
}
convertGamesystemToTemplate(gamesystem: Gamesystem<State<any>, Transition<any>> | undefined) {
if(gamesystem instanceof SimpleTemplateGamesystem) {
return gamesystem as SimpleTemplateGamesystem;
} else if(gamesystem instanceof ProductTemplateSystem) {
return gamesystem as ProductTemplateSystem
} else {
return undefined
}
}
} }

View File

@ -1,3 +1,4 @@
<app-product-state-editor [templateElement]="templateElement" [gamesystem]="gamesystem" (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-state-editor> <app-product-state-editor [templateElement]="templateElement" [gamesystem]="gamesystem" (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-state-editor>
<div id="productStateEditor"> <div id="productStateEditor">
<app-product-transition-editor [templateElement]="templateElement" [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor> <app-product-transition-editor [templateElement]="templateElement" [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor>

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import { import {
ProductTransitionEditorComponent ProductTransitionEditorComponent
} from "../transition-editor/product-transition-editor/product-transition-editor.component"; } 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', templateUrl: './product-gamesystem-editor.component.html',
styleUrl: './product-gamesystem-editor.component.scss' styleUrl: './product-gamesystem-editor.component.scss'
}) })
export class ProductGamesystemEditorComponent { export class ProductGamesystemEditorComponent implements OnInit{
@Input() gamesystem: ProductGamesystem | undefined @Input() gamesystem: ProductGamesystem | undefined
@Input() templateElement: TemplateElement | undefined @Input() templateElement: TemplateElement | undefined
@Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>(); @Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>();
ngOnInit() {
}
onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { onOpenGamesystemEditor(gamesystem: SimpleGamesystem) {
this.openGamesystemEditorEmitter.emit(gamesystem); this.openGamesystemEditorEmitter.emit(gamesystem);
} }

View File

@ -5,8 +5,8 @@
<input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input> <input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input>
</mat-form-field> </mat-form-field>
<table mat-table [dataSource]="datasource" class="mat-elevation-z8" multiTemplateDataRows> <table mat-table [dataSource]="datasource" class="mat-elevation-z8" multiTemplateDataRows>
<ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col"> <ng-container *ngFor="let col of internalColumnNames; let i = index" [matColumnDef]="col">
<th mat-header-cell *matHeaderCellDef>{{col}}</th> <th mat-header-cell *matHeaderCellDef>{{displayedColumns[i]}}</th>
<td mat-cell *matCellDef="let state"> <td mat-cell *matCellDef="let state">
<a *ngIf="i < displayedColumns.length-1" role="button" (click)="clickOnInnerState(i)" [matTooltip]="getLeafState(state, i).stateDescription">{{getLeafState(state, i).stateLabel}}</a> <a *ngIf="i < displayedColumns.length-1" role="button" (click)="clickOnInnerState(i)" [matTooltip]="getLeafState(state, i).stateDescription">{{getLeafState(state, i).stateLabel}}</a>
<mat-icon *ngIf="i == displayedColumns.length-1"> <mat-icon *ngIf="i == displayedColumns.length-1">

View File

@ -29,6 +29,8 @@ export class ProductStateEditorComponent implements OnInit{
@Input() templateElement: TemplateElement | undefined @Input() templateElement: TemplateElement | undefined
@Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>(); @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>();
displayedColumns: string[] = []; displayedColumns: string[] = [];
internalColumnNames: string[] = []
expandedColumns: string[] = [] expandedColumns: string[] = []
datasource = new MatTableDataSource<ProductState>(); datasource = new MatTableDataSource<ProductState>();
@ -38,7 +40,12 @@ export class ProductStateEditorComponent implements OnInit{
this.gamesystem!.generateFromChildsystems(); this.gamesystem!.generateFromChildsystems();
this.generateColumnNamesRecursively(this.gamesystem!, ""); this.generateColumnNamesRecursively(this.gamesystem!, "");
this.displayedColumns.push('Initial'); this.displayedColumns.push('Initial');
this.expandedColumns = [...this.displayedColumns, 'expand'];
this.internalColumnNames = this.displayedColumns.concat();
this.renameDuplicateColumnNames(this.internalColumnNames)
this.expandedColumns = [...this.internalColumnNames, 'expand'];
if(this.templateElement == undefined) { if(this.templateElement == undefined) {
this.datasource.data = this.gamesystem!.states; this.datasource.data = this.gamesystem!.states;
@ -52,6 +59,20 @@ export class ProductStateEditorComponent implements OnInit{
} }
} }
private renameDuplicateColumnNames(columnNames: string[]) {
for(let i=0; i<columnNames.length; i++) {
for(let j=i; j<columnNames.length; j++) {
if(i === j) {
continue;
}
if(columnNames[i] === columnNames[j]) {
columnNames[j] = columnNames[j] + "-" + i
}
}
}
}
generateColumnNamesRecursively(gamesystem: ProductGamesystem, nestedColumnName: string) { generateColumnNamesRecursively(gamesystem: ProductGamesystem, nestedColumnName: string) {
gamesystem.innerGamesystems.forEach(innerGamesystem => { gamesystem.innerGamesystems.forEach(innerGamesystem => {
if(innerGamesystem instanceof SimpleGamesystem) { if(innerGamesystem instanceof SimpleGamesystem) {

View File

@ -39,12 +39,7 @@
<ng-container matColumnDef="initial"> <ng-container matColumnDef="initial">
<th mat-header-cell *matHeaderCellDef>Initial</th> <th mat-header-cell *matHeaderCellDef>Initial</th>
<td mat-cell *matCellDef="let state"> <td mat-cell *matCellDef="let state">
<div *ngIf="editedElement !== state"> <app-state-initial-cell [templateElement]="templateElement" [editedState]="editedElement" [state]="state"></app-state-initial-cell>
<mat-icon *ngIf="state.initial">done</mat-icon>
<mat-icon *ngIf="!state.initial">close</mat-icon>
</div>
<mat-checkbox *ngIf="editedElement === state" [(ngModel)]="state.initial" (ngModelChange)="onStateChange()"></mat-checkbox>
</td> </td>
</ng-container> </ng-container>

View File

@ -35,15 +35,17 @@ export class SimpleStateEditorComponent implements OnInit{
editedStateLabelError: boolean = false; editedStateLabelError: boolean = false;
testState: SimpleState | undefined = undefined
constructor(private snackbar: MatSnackBar) { constructor(private snackbar: MatSnackBar) {
} }
ngOnInit() { ngOnInit() {
this.dataSource.data = this.states; this.dataSource.data = this.states;
this.testState = this.states[0]
this.dataSource.filterPredicate = (data: SimpleState, filter: string) => { this.dataSource.filterPredicate = (data: SimpleState, filter: string) => {
return data.stateLabel.toLowerCase().includes(filter); return data.stateLabel.toLowerCase().includes(filter);
} }
console.log(this.templateElement)
} }
editState(state: SimpleState) { editState(state: SimpleState) {
@ -127,4 +129,6 @@ export class SimpleStateEditorComponent implements OnInit{
return []; return [];
} }
} }
} }

View File

@ -0,0 +1,8 @@
<div *ngIf="state != undefined">
<div *ngIf="editedState !== state">
<mat-icon *ngIf="initialValue">done</mat-icon>
<mat-icon *ngIf="!initialValue">close</mat-icon>
</div>
<mat-checkbox *ngIf="editedState === state" [(ngModel)]="initialValue"></mat-checkbox>
</div>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StateInitialCellComponent } from './state-initial-cell.component';
describe('StateInitialCellComponent', () => {
let component: StateInitialCellComponent;
let fixture: ComponentFixture<StateInitialCellComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [StateInitialCellComponent]
})
.compileComponents();
fixture = TestBed.createComponent(StateInitialCellComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,33 @@
import {Component, Input} from '@angular/core';
import {SimpleState} from "../../../../../project/game-model/gamesystems/states/SimpleState";
import {NgIf} from "@angular/common";
import {TemplateElement} from "../../../../../project/game-model/templates/TemplateElement";
import {SimpleTemplateState} from "../../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateState";
@Component({
selector: 'app-state-initial-cell',
templateUrl: './state-initial-cell.component.html',
styleUrl: './state-initial-cell.component.scss'
})
export class StateInitialCellComponent {
@Input() state: SimpleState | undefined
@Input() editedState: SimpleState | undefined | null
@Input() templateElement: TemplateElement | undefined
get initialValue(): boolean {
if(this.templateElement != undefined && this.state instanceof SimpleTemplateState && this.state.initialMap.has(this.templateElement!)) {
return this.state!.initialMap.get(this.templateElement!)!
} else {
return this.state!.initial;
}
}
set initialValue(value: boolean) {
if(this.templateElement != undefined && this.state instanceof SimpleTemplateState && this.state.initialMap.has(this.templateElement!)) {
this.state.initialMap.set(this.templateElement!, value)
} else {
this.state!.initial = value;
}
}
}

View File

@ -50,6 +50,8 @@ export class ProductTransitionEditorComponent implements OnInit{
const leafGamesystems: SimpleGamesystem[] = LeafGamesystemCalculator.calcLeafGeamesystems(this.gamesystem); const leafGamesystems: SimpleGamesystem[] = LeafGamesystemCalculator.calcLeafGeamesystems(this.gamesystem);
this.displayedColumns = leafGamesystems.map(leafGamesystem => new DisplayedColumnName(leafGamesystem.componentName, leafGamesystem.componentName + "-start")); this.displayedColumns = leafGamesystems.map(leafGamesystem => new DisplayedColumnName(leafGamesystem.componentName, leafGamesystem.componentName + "-start"));
this.displayedColumns = this.displayedColumns.concat( leafGamesystems.map(leafGamesystem => new DisplayedColumnName(leafGamesystem.componentName, leafGamesystem.componentName + "-end"))); this.displayedColumns = this.displayedColumns.concat( leafGamesystems.map(leafGamesystem => new DisplayedColumnName(leafGamesystem.componentName, leafGamesystem.componentName + "-end")));
this.renameDuplicateColumnNames(this.displayedColumns)
this.numberLeafSystems = leafGamesystems.length; this.numberLeafSystems = leafGamesystems.length;
this.columns = this.displayedColumns.map(column => column.internalName) this.columns = this.displayedColumns.map(column => column.internalName)
@ -72,6 +74,20 @@ export class ProductTransitionEditorComponent implements OnInit{
} }
} }
private renameDuplicateColumnNames(columnNames: DisplayedColumnName[]) {
for(let i=0; i<columnNames.length; i++) {
for(let j=i; j<columnNames.length; j++) {
if(i === j) {
continue;
}
if(columnNames[i].internalName === columnNames[j].internalName) {
columnNames[j].internalName = columnNames[j].internalName + "-" + i
}
}
}
}
getLeafStateByIndex(transition: ProductTransition, leafIndex: number) { getLeafStateByIndex(transition: ProductTransition, leafIndex: number) {
let state: ProductState; let state: ProductState;
let index = leafIndex; let index = leafIndex;

View File

@ -10,6 +10,7 @@ import {TemplateType} from "./templates/TemplateType";
import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem"; import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem";
import {ProductTemplateSystem} from "./templates/productGamesystem/ProductTemplateSystem"; import {ProductTemplateSystem} from "./templates/productGamesystem/ProductTemplateSystem";
import {ProductTemplateCreator} from "./templates/productGamesystem/ProductTemplateCreator"; import {ProductTemplateCreator} from "./templates/productGamesystem/ProductTemplateCreator";
import {CharacterRelation} from "./characters/CharacterRelation";
export class GameModel { export class GameModel {
gameModelName: string gameModelName: string
@ -75,6 +76,7 @@ export class GameModel {
let parentProductGamesystem: ProductGamesystem; let parentProductGamesystem: ProductGamesystem;
if(parentGamesystem instanceof SimpleTemplateGamesystem) { if(parentGamesystem instanceof SimpleTemplateGamesystem) {
console.log("Simple Template")
parentProductGamesystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(parentGamesystem, this, templateType!) parentProductGamesystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(parentGamesystem, this, templateType!)
} else if(parentGamesystem instanceof SimpleGamesystem) { } else if(parentGamesystem instanceof SimpleGamesystem) {
if(simpleGamesystem instanceof SimpleTemplateGamesystem) { if(simpleGamesystem instanceof SimpleTemplateGamesystem) {
@ -127,12 +129,21 @@ export class GameModel {
const searchedCharacter = this.characters.find(character => character.componentName === characterName); const searchedCharacter = this.characters.find(character => character.componentName === characterName);
if(searchedCharacter == undefined) { if(searchedCharacter == undefined) {
const character = new Character(characterName, ""); const character = new Character(characterName, "");
this.createCharacterRelation(character)
this.characters.push(character) this.characters.push(character)
return character return character
} }
return undefined return undefined
} }
private createCharacterRelation(addedCharacter: Character) {
this.characters.forEach(character => {
const characterRelation = new CharacterRelation(character, addedCharacter);
character.addCharacterRelation(characterRelation);
addedCharacter.addCharacterRelation(characterRelation);
})
}
removeScriptAccount(scriptAccount: ScriptAccount) { removeScriptAccount(scriptAccount: ScriptAccount) {
if(scriptAccount != undefined) { if(scriptAccount != undefined) {
this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount); this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount);

View File

@ -6,11 +6,16 @@ import {Gamesystem} from "../gamesystems/Gamesystem";
import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem";
import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem";
import {ProductGamesystem} from "../gamesystems/ProductGamesystem"; import {ProductGamesystem} from "../gamesystems/ProductGamesystem";
import {CharacterRelation} from "./CharacterRelation";
export class Character extends ModelComponent implements TemplateElement { export class Character extends ModelComponent implements TemplateElement {
characterSpecificTemplateSystems: Gamesystem<any, any>[] = [] characterSpecificTemplateSystems: Gamesystem<any, any>[] = []
characterRelations: CharacterRelation[] = []
characterRelationGamesystems: Gamesystem<any, any>[] = []
constructor(componentName: string, componentDescription: string) { constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.CHARACTER); super(componentName, componentDescription, ModelComponentType.CHARACTER);
} }
@ -36,8 +41,48 @@ export class Character extends ModelComponent implements TemplateElement {
} }
} }
addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem<any, any>, recursiveCall: boolean = false) {
if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) {
if(gamesystem instanceof SimpleTemplateGamesystem) {
this.characterRelationGamesystems.push(gamesystem);
gamesystem.addTemplateElement(this);
this.characterRelations.forEach(characterRelation => {
characterRelation.addCharacterRelationSystem(gamesystem)
})
} else if(gamesystem instanceof ProductTemplateSystem) {
this.characterRelationGamesystems.push(gamesystem);
gamesystem.addTemplateElement(this);
this.characterRelations.forEach(characterRelation => {
characterRelation.addCharacterRelationSystem(gamesystem)
})
if(!recursiveCall) {
gamesystem.innerGamesystems.forEach(innerGamesystem => this.addAsymetricCharacterRelationGamesystem(innerGamesystem, true))
}
}
if(gamesystem.parentGamesystem != undefined) {
this.addAsymetricCharacterRelationGamesystem(gamesystem.parentGamesystem, true)
}
} else {
console.log("Was already added")
console.log(this)
}
}
addCharacterRelation(characterRelation: CharacterRelation) {
this.characterRelations.push(characterRelation)
}
private isTemplateSystemCharacterSpecific(gamesystemName: string) { private isTemplateSystemCharacterSpecific(gamesystemName: string) {
return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined
} }
private isTemplateSystemCharacterRelationSpecific(gamesystemName: string) {
return this.characterRelationGamesystems.find(gamesystem =>
gamesystem.componentName === gamesystemName) != undefined;
}
} }

View File

@ -0,0 +1,38 @@
import {TemplateElement} from "../templates/TemplateElement";
import {Character} from "./Character";
import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem";
import {Gamesystem} from "../gamesystems/Gamesystem";
import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem";
import {TemplateType} from "../templates/TemplateType";
import {ProductTemplateCreator} from "../templates/productGamesystem/ProductTemplateCreator";
export class CharacterRelation implements TemplateElement{
firstCharacter: Character
secondCharacter: Character
characterRelationGamesystems: ProductTemplateSystem[] = []
constructor(firstCharacter: Character, secondCharacter: Character) {
this.firstCharacter = firstCharacter;
this.secondCharacter = secondCharacter;
}
addCharacterRelationSystem(gamesystem: Gamesystem<any, any>) {
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);
templateGamesystem.addTemplateElement(this);
} else {
console.log("Test")
}
}
private isGamesystemCharacterRelationSpecific(gamesystemName: string) {
return this.characterRelationGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined
}
}

View File

@ -8,6 +8,8 @@ export abstract class Gamesystem<S, T> extends ModelComponent{
states: S[] = []; states: S[] = [];
transitions: T[] = []; transitions: T[] = [];
parentGamesystem: ProductGamesystem | undefined parentGamesystem: ProductGamesystem | undefined
generateIsolatedStates: boolean = false
constructor(gamesystemName: string, gamesystemDescription: string) { constructor(gamesystemName: string, gamesystemDescription: string) {
super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM); super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM);
} }

View File

@ -11,6 +11,7 @@ import {ScriptAccountAction} from "./actions/ScriptAccountAction";
import {ProductSystemGenerator} from "./productSystemGenerator/ProductSystemGenerator"; import {ProductSystemGenerator} from "./productSystemGenerator/ProductSystemGenerator";
import {TemplateType} from "../templates/TemplateType"; import {TemplateType} from "../templates/TemplateType";
import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem";
import {IsolatedProductStateGenerator} from "./productSystemGenerator/IsolatedProductStateGenerator";
export class ProductGamesystem extends Gamesystem<ProductState, ProductTransition> { export class ProductGamesystem extends Gamesystem<ProductState, ProductTransition> {
@ -74,6 +75,11 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
generateFromChildsystems() { generateFromChildsystems() {
const productGenerator = new ProductSystemGenerator(this); const productGenerator = new ProductSystemGenerator(this);
productGenerator.generateFromChildsystems(); productGenerator.generateFromChildsystems();
if(this.generateIsolatedStates) {
const isolatedStatesGenerator = new IsolatedProductStateGenerator(this);
isolatedStatesGenerator.generateIsolatedProductStates();
}
} }
addChildGamesystem(gamesystem: Gamesystem<State<any>, Transition<any>>) { addChildGamesystem(gamesystem: Gamesystem<State<any>, Transition<any>>) {

View File

@ -0,0 +1,53 @@
import {ProductSystemGenerator} from "./ProductSystemGenerator";
import {ProductGenerationData} from "./ProductGenerationData";
import {ProductGeneratorResult} from "./ProductGeneratorResult";
import {ProductState} from "../states/ProductState";
export class IsolatedProductStateGenerator extends ProductSystemGenerator {
generateIsolatedProductStates() {
if(this.productGamesystem.innerGamesystems.length < 2) return;
const leftInitialData = this.prepareChildsystemForGeneration(this.productGamesystem.innerGamesystems[0])
const rightInitialData = this.prepareChildsystemForGeneration(this.productGamesystem.innerGamesystems[1])
const initialGenerationResult = this.generateBinaryIsolatedProductStates(leftInitialData, rightInitialData);
if(this.productGamesystem.innerGamesystems.length > 2) {
for(let i=2; i<this.productGamesystem.innerGamesystems.length; i++) {
const leftData = initialGenerationResult.productGenerationData;
const rightData = this.prepareChildsystemForGeneration(this.productGamesystem.innerGamesystems[i]);
const generationResult = this.generateBinaryIsolatedProductStates(leftData, rightData);
this.assignGeneratedStatesAndTransitions(generationResult)
}
} else {
this.assignGeneratedStatesAndTransitions(initialGenerationResult)
}
}
protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) {
this.productGamesystem.states = this.productGamesystem.states.concat(generationResult.states);
}
protected generateBinaryIsolatedProductStates(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult {
const generatedProductStates: ProductState[] = []
leftSystemData.states.forEach(leftState => {
if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) {
rightSystemData.states.forEach(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);
}
}
})
}
})
return new ProductGeneratorResult(generatedProductStates, []);
}
}

View File

@ -0,0 +1,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 {
const generatedProductStates: ProductState[] = []
leftSystemData.states.forEach(leftState => {
if(leftState.outgoingTransitions.length == 0 && leftState.incomingTransitions.length == 0) {
rightSystemData.states.forEach(rightState => {
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)) {
const generatedState = this.generateBinaryProductState(leftState, rightState, generatedProductStates);
}
}
})
}
})
return new ProductGeneratorResult(generatedProductStates, []);
}
}

View File

@ -0,0 +1,66 @@
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";
import {ProductGeneratorResult} from "./ProductGeneratorResult";
import {state, transition} from "@angular/animations";
export class IsolatedTemplateStateGenerator extends IsolatedProductStateGenerator {
templateElement: TemplateElement
constructor(productGamesystem: ProductTemplateSystem, templateElement: TemplateElement) {
super(productGamesystem);
this.templateElement = templateElement;
}
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)!;
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;
}
}
}

View File

@ -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
@ -59,12 +60,12 @@ export class ProductSystemGenerator {
if(startingState != undefined) { if(startingState != undefined) {
const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates); const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
if(endingState_right != undefined) { if(endingState_right != undefined) {
this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions); this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions, false);
} }
const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates); const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
if(endingState_left != undefined) { if(endingState_left != undefined) {
this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i], generatedProductTransitions) 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); const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
@ -79,7 +80,7 @@ export class ProductSystemGenerator {
const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates); const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
if(startingState != undefined && endingState != undefined) { if(startingState != undefined && endingState != undefined) {
this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions) this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions, true)
} }
} }
@ -91,7 +92,7 @@ export class ProductSystemGenerator {
const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates); const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
if(startingState != undefined && endingState != undefined) { if(startingState != undefined && endingState != undefined) {
this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions); this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions, false);
} }
@ -106,12 +107,13 @@ 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;
} }
protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[]) { protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[], leftSystem: boolean) {
const transition = new ProductTransition(startingState, endingState); const transition = new ProductTransition(startingState, endingState);
transition.scriptAccountActions = [... this.getTransitionActions(usedTransition)]; transition.scriptAccountActions = [... this.getTransitionActions(usedTransition, leftSystem)];
transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition)]; transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition, leftSystem)];
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)
@ -119,13 +121,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 = this.getTransitionConditions(leftTransition) const leftConditions = this.getTransitionConditions(leftTransition, true)
const rightConditions = this.getTransitionConditions(rightTransition) const rightConditions = this.getTransitionConditions(rightTransition, false)
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(this.getTransitionActions(leftTransition), this.getTransitionActions(rightTransition)); transition.scriptAccountActions = this.generateCombinedActions(this.getTransitionActions(leftTransition, true), this.getTransitionActions(rightTransition, false));
transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition), this.getTransitionConditions(rightTransition)); transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition, true), this.getTransitionConditions(rightTransition, false));
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)
@ -134,8 +136,8 @@ 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 leftConditions = this.getStateConditions(leftState) const leftConditions = this.getStateConditions(leftState, true)
const rightConditions = this.getStateConditions(rightState) const rightConditions = this.getStateConditions(rightState, false)
const combinedStateConditions: ScriptAccountCondition[] = leftConditions.concat(rightConditions) const combinedStateConditions: ScriptAccountCondition[] = leftConditions.concat(rightConditions)
for(let i=0; i<combinedStateConditions.length; i++) { for(let i=0; i<combinedStateConditions.length; i++) {
@ -231,15 +233,15 @@ export class ProductSystemGenerator {
return false; return false;
} }
protected getTransitionConditions(transition: Transition<any>) { protected getTransitionConditions(transition: Transition<any>, leftSystem: boolean) {
return transition.scriptAccountConditions; return transition.scriptAccountConditions;
} }
protected getTransitionActions(transition: Transition<any>) { protected getTransitionActions(transition: Transition<any>, leftSystem: boolean) {
return transition.scriptAccountActions; return transition.scriptAccountActions;
} }
protected getStateConditions(state: State<any>) { protected getStateConditions(state: State<any>, leftSystem: boolean) {
return state.conditions; return state.conditions;
} }

View File

@ -0,0 +1,34 @@
import {TemplateProductSystemGenerator} from "./TemplateProductSystemGenerator";
import {ProductGenerationData} from "./ProductGenerationData";
import {ProductGeneratorResult} from "./ProductGeneratorResult";
import {ProductState} from "../states/ProductState";
import {ProductTransition} from "../transitions/ProductTransition";
import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
export class SymmetricProductTemplateGenerator extends TemplateProductSystemGenerator {
protected generateFromBinaryChildsystems(leftSystemData: ProductGenerationData, rightSystemData: ProductGenerationData): ProductGeneratorResult {
const generatedProductStates: ProductState[] = []
const generatedProductTransitions: ProductTransition[] = []
leftSystemData.states.forEach(leftState => {
rightSystemData.states.forEach(rightState => {
if(leftState.equals(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 && leftState.outgoingTransitions[i].endingState.equals(rightState.outgoingTransitions[j].endingState)) {
const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
if(endingState_left_right != undefined) {
this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j], generatedProductTransitions);
}
}
}
}
}
})
})
return new ProductGeneratorResult(generatedProductStates, generatedProductTransitions);
}
}

View File

@ -10,6 +10,9 @@ import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleT
import {state, transition} from "@angular/animations"; import {state, transition} from "@angular/animations";
import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState"; import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState";
import {Character} from "../../characters/Character";
import {CharacterRelation} from "../../characters/CharacterRelation";
import {ProductGenerationData} from "./ProductGenerationData";
export class TemplateProductSystemGenerator extends ProductSystemGenerator { export class TemplateProductSystemGenerator extends ProductSystemGenerator {
@ -27,28 +30,39 @@ export class TemplateProductSystemGenerator extends ProductSystemGenerator {
productTemplateSystem.stateMap.set(this.templateElement, generationResult.states) productTemplateSystem.stateMap.set(this.templateElement, generationResult.states)
} }
protected getTransitionConditions(transition: Transition<any>) { protected getTransitionConditions(transition: Transition<any>, leftSystem: boolean) {
if(transition instanceof SimpleTemplateTransition) { const templateElement = this.determineTemplateElement(leftSystem)!;
return transition.conditionMap.get(this.templateElement)! if(transition instanceof SimpleTemplateTransition && transition.conditionMap.has(templateElement)) {
} else { return transition.conditionMap.get(templateElement)!
}
return transition.scriptAccountConditions; return transition.scriptAccountConditions;
} }
}
protected getTransitionActions(transition: Transition<any>) { protected getTransitionActions(transition: Transition<any>, leftSystem: boolean) {
if(transition instanceof SimpleTemplateTransition) { const templateElement = this.determineTemplateElement(leftSystem)!;
return transition.actionMap.get(this.templateElement)!
if(transition instanceof SimpleTemplateTransition && transition.actionMap.has(templateElement)) {
return transition.actionMap.get(templateElement)!
} else { } else {
return transition.scriptAccountActions; return transition.scriptAccountActions;
} }
} }
protected getStateConditions(state: State<any>): ScriptAccountCondition[] { protected getStateConditions(state: State<any>, leftSystem: boolean): ScriptAccountCondition[] {
if(state instanceof SimpleTemplateState) { const templateElement = this.determineTemplateElement(leftSystem)!
return state.conditionMap.get(this.templateElement)! if(state instanceof SimpleTemplateState && state.conditionMap.has(templateElement)) {
return state.conditionMap.get(templateElement)!
} else { } else {
return state.conditions 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;
}
}
} }

View File

@ -1,3 +1,4 @@
export enum TemplateType { export enum TemplateType {
CHARACTER CHARACTER,
CHARACTER_RELATION
} }

View File

@ -4,6 +4,8 @@ export class TemplateTypeUtilities {
static fromString(string: string) { static fromString(string: string) {
if(string === 'character') { if(string === 'character') {
return TemplateType.CHARACTER return TemplateType.CHARACTER
} else if(string === 'character_relation') {
return TemplateType.CHARACTER_RELATION
} }
} }
} }

View File

@ -7,12 +7,20 @@ 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"; import {TemplateProductSystemGenerator} from "../../gamesystems/productSystemGenerator/TemplateProductSystemGenerator";
import {
SymmetricProductTemplateGenerator
} from "../../gamesystems/productSystemGenerator/SymmetricProductTemplateGenerator";
import {IsolatedTemplateStateGenerator} from "../../gamesystems/productSystemGenerator/IsolatedTemplateStateGenerator";
import {
IsolatedSymmetricTemplateStateGenerator
} from "../../gamesystems/productSystemGenerator/IsolatedSymmetricTemplateStateGenerator";
export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{
stateMap: Map<TemplateElement, ProductState[]> = new Map(); stateMap: Map<TemplateElement, ProductState[]> = new Map();
transitionMap: Map<TemplateElement, ProductTransition[]> = new Map<TemplateElement, ProductTransition[]>() transitionMap: Map<TemplateElement, ProductTransition[]> = new Map<TemplateElement, ProductTransition[]>()
templateType: TemplateType templateType: TemplateType
symmetric: boolean = false
constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) {
@ -21,8 +29,25 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template
} }
addTemplateElement(templateElement: TemplateElement): void { addTemplateElement(templateElement: TemplateElement): void {
if(this.symmetric) {
const symmetricGenerator = new SymmetricProductTemplateGenerator(this, templateElement);
symmetricGenerator.generateFromChildsystems()
if(this.generateIsolatedStates) {
const isolatedTemplateStateGenerator = new IsolatedSymmetricTemplateStateGenerator(this, templateElement);
isolatedTemplateStateGenerator.generateIsolatedProductStates();
}
} else {
const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement);
productTemplateGenerator.generateFromChildsystems() productTemplateGenerator.generateFromChildsystems()
if(this.generateIsolatedStates) {
const isolatedTemplateStateGenerator = new IsolatedTemplateStateGenerator(this, templateElement);
isolatedTemplateStateGenerator.generateIsolatedProductStates();
}
}
} }
} }

View File

@ -10,6 +10,7 @@ import {TemplateType} from "../TemplateType";
export class SimpleTemplateGamesystem extends SimpleGamesystem implements TemplateGamesystem { export class SimpleTemplateGamesystem extends SimpleGamesystem implements TemplateGamesystem {
templateType: TemplateType templateType: TemplateType
symmetric: boolean = false
constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) {
super(gamesystemName, gamesystemDescription); super(gamesystemName, gamesystemDescription);

View File

@ -5,11 +5,16 @@ import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccount
export class SimpleTemplateState extends SimpleState { export class SimpleTemplateState extends SimpleState {
conditionMap: Map<TemplateElement, ScriptAccountCondition[]> = new Map(); conditionMap: Map<TemplateElement, ScriptAccountCondition[]> = new Map();
initialMap: Map<TemplateElement, boolean> = new Map<TemplateElement, boolean>();
addTemplateElement(templateElement: TemplateElement) { addTemplateElement(templateElement: TemplateElement) {
if(!this.conditionMap.has(templateElement)) { if(!this.conditionMap.has(templateElement)) {
this.conditionMap.set(templateElement, this.conditions) this.conditionMap.set(templateElement, this.conditions)
} }
if(!this.initialMap.has(templateElement)) {
this.initialMap.set(templateElement, this.initial);
}
} }
removeTemplateElement(templateElement: TemplateElement) { removeTemplateElement(templateElement: TemplateElement) {

View File

@ -6,16 +6,21 @@ import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountCon
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/SimpleTemplateState"; import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/SimpleTemplateState";
import {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition"; import {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition";
import {CharacterRelation} from "../../game-model/characters/CharacterRelation";
import {load} from "@angular-devkit/build-angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks";
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
export class CharacterParser { export class CharacterParser {
characterSpecificGamesystems: SimpleTemplateGamesystem[] characterSpecificGamesystems: SimpleTemplateGamesystem[]
characterRelationSpecificGamesystems: SimpleTemplateGamesystem[]
scriptAccountConditionParser: ScriptAccountConditionParser scriptAccountConditionParser: ScriptAccountConditionParser
scriptAccountActionParser: ScriptAccountActionParser scriptAccountActionParser: ScriptAccountActionParser
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) { constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], characterRelationSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
this.characterSpecificGamesystems = characterSpecificGamesystems; this.characterSpecificGamesystems = characterSpecificGamesystems;
this.characterRelationSpecificGamesystems = characterRelationSpecificGamesystems;
this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts); this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts);
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts) this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
} }
@ -23,29 +28,39 @@ export class CharacterParser {
public parseCharacters(characters: StoreComponent[]): Character[] { public parseCharacters(characters: StoreComponent[]): Character[] {
const loadedCharacters: Character[] = [] const loadedCharacters: Character[] = []
characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString)))) characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString), loadedCharacters)))
return loadedCharacters; return loadedCharacters;
} }
private parseSingleCharacter(characterData: any): Character { private parseSingleCharacter(characterData: any, loadedCharacters: Character[]): Character {
const character = new Character(characterData.componentName, characterData.componentDescription); const character = new Character(characterData.componentName, characterData.componentDescription);
const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems);
loadedCharacters.forEach(loadedCharacter => {
const characterRelation = new CharacterRelation(loadedCharacter, character);
loadedCharacter.addCharacterRelation(characterRelation)
character.addCharacterRelation(characterRelation)
})
const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems, this.characterSpecificGamesystems);
templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system)) templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system))
const characterRelationGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterRelationGamesystems, this.characterRelationSpecificGamesystems)
characterRelationGamesystems.forEach(gamesystem => character.addAsymetricCharacterRelationGamesystem(gamesystem))
return character; return character;
} }
private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem[] { private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem[] {
const result: SimpleTemplateGamesystem[] = [] const result: SimpleTemplateGamesystem[] = []
for(let i=0; i<characterSpecificGamesystems.length; i++) { for(let i=0; i<characterSpecificGamesystems.length; i++) {
const characterSpecificGamesystem = characterSpecificGamesystems[i]; const characterSpecificGamesystem = characterSpecificGamesystems[i];
result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem)!) result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem, templateGamesystems)!)
} }
return result; return result;
} }
private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any): SimpleTemplateGamesystem | undefined{ private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem | undefined{
const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName) const referencedGamesystem = this.findCharacterSpecificGamesystem(templateGamesystems, characterSpecificGamesystem.componentName)
if(referencedGamesystem != undefined) { if(referencedGamesystem != undefined) {
for(let i=0; i<characterSpecificGamesystem.states.length; i++) { for(let i=0; i<characterSpecificGamesystem.states.length; i++) {
@ -54,6 +69,7 @@ export class CharacterParser {
const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap); const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap);
state.conditionMap.set(character, conditions) state.conditionMap.set(character, conditions)
state.initialMap.set(character, stateReference.initialMap)
} }
for(let i=0; i<characterSpecificGamesystem.transitions.length; i++) { for(let i=0; i<characterSpecificGamesystem.transitions.length; i++) {
@ -66,15 +82,12 @@ export class CharacterParser {
transition!.actionMap.set(character, actions); transition!.actionMap.set(character, actions);
transition!.conditionMap.set(character, condititions); transition!.conditionMap.set(character, condititions);
} }
} else {
console.log(this.characterSpecificGamesystems)
console.log("Cannot find system: ", characterSpecificGamesystem.componentName)
} }
return referencedGamesystem; return referencedGamesystem;
} }
private findCharacterSpecificGamesystem(componentName: string): SimpleTemplateGamesystem | undefined{ private findCharacterSpecificGamesystem(gamesystems: SimpleTemplateGamesystem[], componentName: string): SimpleTemplateGamesystem | undefined{
return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName) return gamesystems.find(gamesystem => gamesystem.componentName === componentName)
} }
private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) { private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) {

View File

@ -45,6 +45,7 @@ export class GamesystemParser {
let simpleGamesystem let simpleGamesystem
if(gamesystemData.templateType != undefined) { if(gamesystemData.templateType != undefined) {
simpleGamesystem = new SimpleTemplateGamesystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType) simpleGamesystem = new SimpleTemplateGamesystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType)
simpleGamesystem.symmetric = gamesystemData.symmetric
} else { } else {
simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
} }
@ -56,6 +57,7 @@ export class GamesystemParser {
const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts)
simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions, gamesystemData.templateType) simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions, gamesystemData.templateType)
simpleGamesystem.generateIsolatedStates = gamesystemData.generateIsolatedStates;
return simpleGamesystem return simpleGamesystem
} }
@ -66,8 +68,11 @@ export class GamesystemParser {
productGamesystem = new ProductGamesystem(gamesystemData.componentName, gamesystemData.componentDescription); productGamesystem = new ProductGamesystem(gamesystemData.componentName, gamesystemData.componentDescription);
} else { } else {
productGamesystem = new ProductTemplateSystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType) productGamesystem = new ProductTemplateSystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType)
productGamesystem.symmetric = gamesystemData.symmetric
} }
productGamesystem.generateIsolatedStates = gamesystemData.generateIsolatedStates
const childsystemNames: string[] = [] const childsystemNames: string[] = []
for(let i=0; i<gamesystemData.childsystems.length; i++) { for(let i=0; i<gamesystemData.childsystems.length; i++) {
childsystemNames.push(gamesystemData.childsystems[i].componentName) childsystemNames.push(gamesystemData.childsystems[i].componentName)

View File

@ -7,7 +7,7 @@ import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
export class CharacterSerializer { export class CharacterSerializer {
private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions'] private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions', 'characterRelations']
public static serializeCharacters(characters: Character[]): StoreComponent[] { public static serializeCharacters(characters: Character[]): StoreComponent[] {
const storedCharacters: StoreComponent[] = [] const storedCharacters: StoreComponent[] = []
@ -33,7 +33,10 @@ export class CharacterSerializer {
return value.componentName return value.componentName
} }
if(key === 'conditionMap' || key === 'actionMap') { if(key === 'conditionMap' || key === 'actionMap' || key === 'initialMap') {
if(key === 'initialMap') {
console.log(value)
}
if(value.get(character) == undefined) { if(value.get(character) == undefined) {
return [] return []
} }

View File

@ -8,7 +8,7 @@ import {ProductTemplateSystem} from "../game-model/templates/productGamesystem/P
export class GamesystemSerializer { export class GamesystemSerializer {
private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap", "actionMap"] private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap", "actionMap", "initialMap"]
public static serializeGamesystems(gamesystems: Gamesystem<any, any>[]): StoreComponent[] { public static serializeGamesystems(gamesystems: Gamesystem<any, any>[]): StoreComponent[] {
let storedGamesystems: StoreComponent[] = [] let storedGamesystems: StoreComponent[] = []
@ -66,13 +66,16 @@ export class GamesystemSerializer {
'componentName': productGamesystem.componentName, 'componentName': productGamesystem.componentName,
'componentDescription': productGamesystem.componentDescription, 'componentDescription': productGamesystem.componentDescription,
'childsystems': innerGamesystemJsonArray, 'childsystems': innerGamesystemJsonArray,
'templateType': productGamesystem.templateType 'templateType': productGamesystem.templateType,
'symmetric': productGamesystem.symmetric,
'generateIsolatedStates':productGamesystem.generateIsolatedStates
} }
} else { } else {
jsonString = { jsonString = {
'componentName': productGamesystem.componentName, 'componentName': productGamesystem.componentName,
'componentDescription': productGamesystem.componentDescription, 'componentDescription': productGamesystem.componentDescription,
'childsystems': innerGamesystemJsonArray, 'childsystems': innerGamesystemJsonArray,
'generateIsolatedStates':productGamesystem.generateIsolatedStates
} }
} }

View File

@ -1,50 +1,70 @@
{ {
"componentName": "Astrid Hofferson", "componentName": "Astrid Hofferson",
"componentDescription": "", "componentDescription": "",
"characterSpecificTemplateSystems": [ "characterSpecificTemplateSystems": [],
"characterRelationGamesystems": [
{ {
"componentName": "TemplateGamesystem", "componentName": "Characterbeziehungssystem",
"states": [ "states": [
{ {
"stateLabel": "A", "stateLabel": "Feind",
"conditionMap": [ "conditionMap": [],
{ "initialMap": true
"scriptAccount": "Luftfeuchtigkeit",
"minValue": 0,
"maxValue": "10"
}
]
}, },
{ {
"stateLabel": "B", "stateLabel": "Freund",
"conditionMap": [ "conditionMap": [],
"initialMap": false
},
{ {
"scriptAccount": "New ScriptAccount", "stateLabel": "Fester Freund",
"minValue": 0, "conditionMap": [],
"maxValue": 100 "initialMap": false
} },
] {
"stateLabel": "Eltern",
"conditionMap": [],
"initialMap": false
},
{
"stateLabel": "Geschwister",
"conditionMap": [],
"initialMap": false
},
{
"stateLabel": "Großeltern",
"conditionMap": [],
"initialMap": false
} }
], ],
"transitions": [ "transitions": [
{ {
"startingState": "A", "startingState": "Feind",
"endingState": "B", "endingState": "Freund",
"conditionMap": [ "conditionMap": [],
"actionMap": []
},
{ {
"scriptAccount": "Temperature", "startingState": "Freund",
"minValue": 0, "endingState": "Feind",
"maxValue": 10 "conditionMap": [],
"actionMap": []
},
{
"startingState": "Freund",
"endingState": "Fester Freund",
"conditionMap": [],
"actionMap": []
},
{
"startingState": "Fester Freund",
"endingState": "Feind",
"conditionMap": [],
"actionMap": []
} }
], ],
"actionMap": [ "generateIsolatedStates": true,
{ "symmetric": true
"changingValue": 10,
"scriptAccount": "Luftfeuchtigkeit"
}
]
}
]
} }
] ]
} }

View File

@ -1,60 +1,70 @@
{ {
"componentName": "Hicks Haddock", "componentName": "Hicks Haddock",
"componentDescription": "", "componentDescription": "",
"characterSpecificTemplateSystems": [ "characterSpecificTemplateSystems": [],
"characterRelationGamesystems": [
{ {
"componentName": "TemplateGamesystem", "componentName": "Characterbeziehungssystem",
"states": [ "states": [
{ {
"stateLabel": "A", "stateLabel": "Feind",
"conditionMap": [ "conditionMap": [],
{ "initialMap": false
"scriptAccount": "Luftfeuchtigkeit",
"minValue": 0,
"maxValue": "10"
}
]
}, },
{ {
"stateLabel": "B", "stateLabel": "Freund",
"conditionMap": [ "conditionMap": [],
"initialMap": false
},
{ {
"scriptAccount": "New ScriptAccount", "stateLabel": "Fester Freund",
"minValue": 0, "conditionMap": [],
"maxValue": 100 "initialMap": true
} },
] {
"stateLabel": "Eltern",
"conditionMap": [],
"initialMap": false
},
{
"stateLabel": "Geschwister",
"conditionMap": [],
"initialMap": false
},
{
"stateLabel": "Großeltern",
"conditionMap": [],
"initialMap": false
} }
], ],
"transitions": [ "transitions": [
{ {
"startingState": "A", "startingState": "Feind",
"endingState": "B", "endingState": "Freund",
"conditionMap": [], "conditionMap": [],
"actionMap": [] "actionMap": []
}
]
}, },
{ {
"componentName": "Letters", "startingState": "Freund",
"states": [ "endingState": "Feind",
{ "conditionMap": [],
"stateLabel": "A", "actionMap": []
"conditionMap": []
}, },
{ {
"stateLabel": "B", "startingState": "Freund",
"conditionMap": [] "endingState": "Fester Freund",
"conditionMap": [],
"actionMap": []
},
{
"startingState": "Fester Freund",
"endingState": "Feind",
"conditionMap": [],
"actionMap": []
} }
], ],
"transitions": [ "generateIsolatedStates": true,
{ "symmetric": true
"startingState": "A",
"endingState": "B",
"conditionMap": [],
"actionMap": []
}
]
} }
] ]
} }

View File

@ -0,0 +1,71 @@
{
"componentName": "Characterbeziehungssystem",
"componentDescription": "",
"states": [
{
"initial": true,
"conditions": [],
"stateLabel": "Feind",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "Freund",
"stateDescription": ""
},
{
"initial": false,
"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": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Feind",
"endingState": "Freund"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Freund",
"endingState": "Feind"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Freund",
"endingState": "Fester Freund"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Fester Freund",
"endingState": "Feind"
}
],
"generateIsolatedStates": true,
"symmetric": true,
"templateType": 1
}

View File

@ -1,6 +0,0 @@
{
"componentName": "NormalGamesystem",
"componentDescription": "",
"states": [],
"transitions": []
}

View File

@ -0,0 +1,14 @@
{
"componentName": "Letter",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [],
"stateLabel": "A",
"stateDescription": ""
}
],
"transitions": [],
"generateIsolatedStates": false
}

View File

@ -0,0 +1,14 @@
{
"componentName": "Number",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [],
"stateLabel": "1",
"stateDescription": ""
}
],
"transitions": [],
"generateIsolatedStates": false
}

View File

@ -0,0 +1,13 @@
{
"componentName": "ProductGamesystem",
"componentDescription": "",
"childsystems": [
{
"componentName": "Letter"
},
{
"componentName": "Number"
}
],
"generateIsolatedStates": true
}

View File

@ -1,27 +0,0 @@
{
"componentName": "Letters",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [],
"stateLabel": "A",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "B",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "A",
"endingState": "B"
}
],
"templateType": 0
}

View File

@ -1,26 +0,0 @@
{
"componentName": "Numbers",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [],
"stateLabel": "1",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "2",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "1",
"endingState": "2"
}
]
}

View File

@ -1,13 +0,0 @@
{
"componentName": "Producttest",
"componentDescription": "",
"childsystems": [
{
"componentName": "Letters"
},
{
"componentName": "Numbers"
}
],
"templateType": 0
}

View File

@ -1,50 +0,0 @@
{
"componentName": "TemplateGamesystem",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [
{
"scriptAccount": "Luftfeuchtigkeit",
"minValue": 0,
"maxValue": "10"
}
],
"stateLabel": "A",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "New ScriptAccount",
"minValue": 0,
"maxValue": 100
}
],
"stateLabel": "B",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [
{
"changingValue": 10,
"scriptAccount": "Luftfeuchtigkeit"
}
],
"scriptAccountConditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": 10
}
],
"startingState": "A",
"endingState": "B"
}
],
"templateType": 0
}

View File

@ -1,37 +0,0 @@
{
"componentName": "Testsystem",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [],
"stateLabel": "A",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "B",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [
{
"changingValue": 5,
"scriptAccount": "New ScriptAccount"
}
],
"scriptAccountConditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "10"
}
],
"startingState": "A",
"endingState": "B"
}
]
}

View File

@ -1,80 +0,0 @@
{
"componentName": "Season",
"componentDescription": "Ein simples Gamesystem zur Modellierung verschiedener Jahreszeiten und deren Übergänge",
"states": [
{
"initial": true,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "10"
}
],
"stateLabel": "Frühling",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "10",
"maxValue": "30"
}
],
"stateLabel": "Sommer",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "10",
"maxValue": "20"
}
],
"stateLabel": "Herbst",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "-10",
"maxValue": "10"
}
],
"stateLabel": "Winter",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Frühling",
"endingState": "Sommer"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Sommer",
"endingState": "Herbst"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Herbst",
"endingState": "Winter"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Winter",
"endingState": "Frühling"
}
]
}

View File

@ -1,80 +0,0 @@
{
"componentName": "Weather",
"componentDescription": "A small Gamesystem about local weather events",
"states": [
{
"initial": true,
"conditions": [],
"stateLabel": "Sonne",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "30"
}
],
"stateLabel": "Regen",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "Wolke",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "-5",
"maxValue": 0
}
],
"stateLabel": "Schnee",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Sonne",
"endingState": "Wolke"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Wolke",
"endingState": "Sonne"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Wolke",
"endingState": "Regen"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Regen",
"endingState": "Wolke"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Wolke",
"endingState": "Schnee"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Schnee",
"endingState": "Wolke"
}
]
}

View File

@ -1,12 +0,0 @@
{
"componentName": "Weathersystem",
"componentDescription": "Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt.",
"childsystems": [
{
"componentName": "Season"
},
{
"componentName": "Weather"
}
]
}

View File

@ -1,6 +0,0 @@
{
"componentName": "New ScriptAccount",
"componentDescription": "",
"minValue": 0,
"maxValue": 100
}

View File

@ -1,6 +0,0 @@
{
"componentName": "Temperature",
"componentDescription": "",
"minValue": -30,
"maxValue": 50
}

View File

@ -1,5 +1,5 @@
{ {
"componentName": "Luftfeuchtigkeit", "componentName": "Test",
"componentDescription": "", "componentDescription": "",
"minValue": 0, "minValue": 0,
"maxValue": 100 "maxValue": 100