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 8ceb068..6678c34 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,7 @@
Inventory Conditions
-
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
index 2d521d4..92c0e18 100644
--- 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
@@ -1,9 +1,10 @@
-import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
+import {Component, Input, OnInit} 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";
+import {AbstractInteraction} from "../../../../project/game-model/interactions/AbstractInteraction";
@Component({
selector: 'app-gamesystem-condition-editor',
@@ -12,10 +13,8 @@ import {Gamesystem} from "../../../../project/game-model/gamesystems/Gamesystem"
})
export class GamesystemConditionEditorComponent implements OnInit{
- @Input() gamesystemConditions: GamesystemCondition[] = []
+ @Input() intgeraction: AbstractInteraction | undefined
@Input() gamesystems: Gamesystem[] = []
- @Output("onConditionUpdate") gamesytemConditionChangeEmitter: EventEmitter = new EventEmitter();
- @Output("onConditionDelete") gamesystemConditionDeleteEmitter: EventEmitter = new EventEmitter();
editedCondition: GamesystemCondition | undefined
addedCondition: GamesystemCondition | undefined
@@ -26,7 +25,7 @@ export class GamesystemConditionEditorComponent implements OnInit{
}
ngOnInit() {
- this.datasource.data = this.gamesystemConditions;
+ this.datasource.data = this.intgeraction!.gamesystemConditions
}
editCondition(condition: GamesystemCondition) {
@@ -40,7 +39,7 @@ export class GamesystemConditionEditorComponent implements OnInit{
if(this.editedCondition!.validate()) {
if(this.editedCondition === this.addedCondition) {
- this.gamesytemConditionChangeEmitter.emit(this.editedCondition);
+ this.intgeraction!.addConditon(this.addedCondition);
this.addedCondition = undefined
}
this.editedCondition = undefined;
@@ -49,19 +48,21 @@ export class GamesystemConditionEditorComponent implements OnInit{
}
}
- deleteCondition(condition: GamesystemCondition) {
- this.gamesystemConditions = this.gamesystemConditions.filter(c => c !== condition);
- this.datasource.data = this.gamesystemConditions;
- this.gamesystemConditionDeleteEmitter.emit(condition);
+ deleteCondition(deletedCondition: GamesystemCondition) {
+ this.intgeraction!.removeCondition(deletedCondition);
+ this.datasource.data = this.datasource.data.filter(condition => condition !== deletedCondition);
}
addCondition() {
const condition = new GamesystemCondition(CharacterDependency.NONE, undefined, undefined);
- this.gamesystemConditions.push(condition);
+ const displayedConditions = this.datasource.data;
+ displayedConditions.push(condition);
+
+
this.editedCondition = condition;
this.addedCondition = condition;
- this.datasource.data = this.gamesystemConditions;
+ this.datasource.data = displayedConditions;
}
protected readonly CharacterDependency = CharacterDependency;
diff --git a/src/app/project/game-model/interactions/AbstractInteraction.ts b/src/app/project/game-model/interactions/AbstractInteraction.ts
index c1843b9..1821f69 100644
--- a/src/app/project/game-model/interactions/AbstractInteraction.ts
+++ b/src/app/project/game-model/interactions/AbstractInteraction.ts
@@ -5,6 +5,7 @@ import {InventoryCondition} from "./condition/InventoryCondition";
import {GamesystemCondition} from "./condition/GamesystemCondition";
export abstract class AbstractInteraction {
+
sourceCharacter: Character
targetCharacter: Character | undefined
@@ -30,7 +31,15 @@ export abstract class AbstractInteraction {
return this.conditions.filter(condition => condition instanceof InventoryCondition)
}
- get gamesystemConditions() {
- return this.conditions.filter(condition => condition instanceof GamesystemCondition)
+ get gamesystemConditions(): GamesystemCondition[] {
+ return this.conditions.filter(condition => condition instanceof GamesystemCondition).map(condition => condition as GamesystemCondition)
+ }
+
+ addConditon(addedCondition: Condition) {
+ this.conditions.push(addedCondition);
+ }
+
+ removeCondition(removedCondition: Condition) {
+ this.conditions = this.conditions.filter(condition => condition !== removedCondition);
}
}