diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 8289e18..a514b75 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -110,6 +110,9 @@ import {
import {
CharacterInteractionEditorComponent
} from "./editor/character-editor/character-interaction-editor/character-interaction-editor.component";
+import {
+ GamesystemConditionEditorComponent
+} from "./editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component";
// AoT requires an exported function for factories
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
@@ -145,7 +148,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
CharacteristicSelectorComponent,
RequieredInheritancesEditorComponent,
RequieredInheritancesCreatorComponent,
- CharacterInteractionEditorComponent
+ CharacterInteractionEditorComponent,
+ GamesystemConditionEditorComponent
],
imports: [
BrowserModule,
diff --git a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html
index 534e938..8ceb068 100644
--- a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html
+++ b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html
@@ -107,7 +107,8 @@
Inventory Conditions
- Gamesystem Conditions
+
diff --git a/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.html b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.html
new file mode 100644
index 0000000..8762b28
--- /dev/null
+++ b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.html
@@ -0,0 +1,77 @@
+
+
+ Dependency |
+
+ @if(condition === editedCondition) {
+
+ Character Dependency
+
+ None
+ Source
+ Target
+
+
+ } @else {
+ {{condition.characterDependency}}
+ }
+ |
+
+
+
+ Gamesystem |
+
+ @if(condition === editedCondition) {
+
+ Character Dependency
+
+ {{gamesystem.componentName}}
+
+
+ } @else {
+ @if(condition.targetGamesystem != undefined) {
+ {{condition.targetGamesystem.componentName}}
+ } @else {
+ UNKNOWN GAMESYSTEM
+ }
+ }
+ |
+
+
+
+ State |
+
+ @if(condition === editedCondition && editedCondition!.targetGamesystem != undefined) {
+
+
+ {{state.computeStateLabel()}}
+
+
+ } @else {
+ @if(condition.requieredState != undefined) {
+ {{condition.requieredState.computeStateLabel()}}
+ } @else {
+ UNKNOWN STATE
+ }
+ }
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
diff --git a/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.scss b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.scss
new file mode 100644
index 0000000..906202f
--- /dev/null
+++ b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.scss
@@ -0,0 +1,3 @@
+.mat-column-edit, .mat-column-delete {
+ width: 32px;
+}
diff --git a/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.spec.ts b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.spec.ts
new file mode 100644
index 0000000..260e62d
--- /dev/null
+++ b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { GamesystemConditionEditorComponent } from './gamesystem-condition-editor.component';
+
+describe('GamesystemConditionEditorComponent', () => {
+ let component: GamesystemConditionEditorComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [GamesystemConditionEditorComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(GamesystemConditionEditorComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.ts b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.ts
new file mode 100644
index 0000000..2d521d4
--- /dev/null
+++ b/src/app/editor/interaction-editor/conditions/gamesystem-condition-editor/gamesystem-condition-editor.component.ts
@@ -0,0 +1,68 @@
+import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
+import {GamesystemCondition} from "../../../../project/game-model/interactions/condition/GamesystemCondition";
+import {MatSnackBar} from "@angular/material/snack-bar";
+import {MatTableDataSource} from "@angular/material/table";
+import {CharacterDependency} from "../../../../project/game-model/interactions/CharacterDependency";
+import {Gamesystem} from "../../../../project/game-model/gamesystems/Gamesystem";
+
+@Component({
+ selector: 'app-gamesystem-condition-editor',
+ templateUrl: './gamesystem-condition-editor.component.html',
+ styleUrl: './gamesystem-condition-editor.component.scss'
+})
+export class GamesystemConditionEditorComponent implements OnInit{
+
+ @Input() gamesystemConditions: GamesystemCondition[] = []
+ @Input() gamesystems: Gamesystem[] = []
+ @Output("onConditionUpdate") gamesytemConditionChangeEmitter: EventEmitter = new EventEmitter();
+ @Output("onConditionDelete") gamesystemConditionDeleteEmitter: EventEmitter = new EventEmitter();
+ editedCondition: GamesystemCondition | undefined
+ addedCondition: GamesystemCondition | undefined
+
+ datasource: MatTableDataSource = new MatTableDataSource();
+ displayedColumns: string[] = ["characterDependency", "targetGamesystem", "requieredState", "edit", "delete"]
+
+ constructor(private snackbar: MatSnackBar) {
+ }
+
+ ngOnInit() {
+ this.datasource.data = this.gamesystemConditions;
+ }
+
+ editCondition(condition: GamesystemCondition) {
+ this.editedCondition = condition;
+ }
+
+ finishEditingCondition() {
+ if(this.editedCondition == undefined) {
+ return;
+ }
+
+ if(this.editedCondition!.validate()) {
+ if(this.editedCondition === this.addedCondition) {
+ this.gamesytemConditionChangeEmitter.emit(this.editedCondition);
+ this.addedCondition = undefined
+ }
+ this.editedCondition = undefined;
+ } else {
+ this.snackbar.open("Invalid Condition", "", {duration: 2000});
+ }
+ }
+
+ deleteCondition(condition: GamesystemCondition) {
+ this.gamesystemConditions = this.gamesystemConditions.filter(c => c !== condition);
+ this.datasource.data = this.gamesystemConditions;
+ this.gamesystemConditionDeleteEmitter.emit(condition);
+ }
+
+ addCondition() {
+ const condition = new GamesystemCondition(CharacterDependency.NONE, undefined, undefined);
+ this.gamesystemConditions.push(condition);
+ this.editedCondition = condition;
+ this.addedCondition = condition;
+
+ this.datasource.data = this.gamesystemConditions;
+ }
+
+ protected readonly CharacterDependency = CharacterDependency;
+}
diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts
index ea5d397..715c76a 100644
--- a/src/app/project/game-model/GameModel.ts
+++ b/src/app/project/game-model/GameModel.ts
@@ -235,6 +235,21 @@ export class GameModel {
return result;
}
+ get gamesystemsAsList() {
+ let gamesystemQueue: Gamesystem[] = this.gamesystems.concat();
+ const result: Gamesystem[] = []
+
+ while(gamesystemQueue.length > 0) {
+ const currentGamesystem = gamesystemQueue.shift()!;
+
+ if(currentGamesystem instanceof ProductGamesystem) {
+ gamesystemQueue = gamesystemQueue.concat(currentGamesystem.innerGamesystems);
+ }
+ result.push(currentGamesystem);
+ }
+ return result;
+ }
+
addCharacter(character: Character) {
if(this.characters.find(c => c.componentName === character.componentName) === undefined) {
this.characters.push(character)
diff --git a/src/app/project/game-model/gamesystems/states/ProductState.ts b/src/app/project/game-model/gamesystems/states/ProductState.ts
index 8a4c504..bafd59a 100644
--- a/src/app/project/game-model/gamesystems/states/ProductState.ts
+++ b/src/app/project/game-model/gamesystems/states/ProductState.ts
@@ -2,6 +2,7 @@ import {ProductTransition} from "../transitions/ProductTransition";
import {State} from "./State";
import {SimpleState} from "./SimpleState";
import {Transition} from "../transitions/Transition";
+import {state} from "@angular/animations";
export class ProductState extends State {
innerStates: State[] = [];
@@ -50,4 +51,17 @@ export class ProductState extends State {
return false;
}
+ computeStateLabel(): string {
+ let stateLabel = "("
+ for(let i=0; i {
return this.stateLabel === (state as SimpleState).stateLabel;
}
+ computeStateLabel(): string {
+ return this.stateLabel
+ }
+
+
}
diff --git a/src/app/project/game-model/gamesystems/states/State.ts b/src/app/project/game-model/gamesystems/states/State.ts
index d1848f5..f83006c 100644
--- a/src/app/project/game-model/gamesystems/states/State.ts
+++ b/src/app/project/game-model/gamesystems/states/State.ts
@@ -47,4 +47,6 @@ export abstract class State> {
}
abstract equals(state: State>): boolean;
+
+ abstract computeStateLabel(): string
}
diff --git a/src/app/project/game-model/interactions/condition/GamesystemCondition.ts b/src/app/project/game-model/interactions/condition/GamesystemCondition.ts
index f5cfae0..5711149 100644
--- a/src/app/project/game-model/interactions/condition/GamesystemCondition.ts
+++ b/src/app/project/game-model/interactions/condition/GamesystemCondition.ts
@@ -4,13 +4,17 @@ import {Condition} from "./Condition";
import {CharacterDependency} from "../CharacterDependency";
export class GamesystemCondition extends Condition {
- targetGamesystem: Gamesystem
- requieredState: State;
+ targetGamesystem: Gamesystem | undefined
+ requieredState: State | undefined;
- constructor(characterDependency: CharacterDependency, targetGamesystem: Gamesystem, requieredState: State) {
+ constructor(characterDependency: CharacterDependency, targetGamesystem: Gamesystem | undefined, requieredState: State | undefined) {
super(characterDependency);
this.targetGamesystem = targetGamesystem;
this.requieredState = requieredState;
}
+
+ validate(): boolean {
+ return this.targetGamesystem != undefined && this.requieredState != undefined;
+ }
}