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 f0dfcb8..30c8f4d 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 @@ -101,7 +101,8 @@ - + diff --git a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts index ba5a976..4385a80 100644 --- a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts +++ b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts @@ -8,6 +8,7 @@ import {animate, state, style, transition, trigger} from "@angular/animations"; import {Interaction} from "../../../project/game-model/interactions/Interaction"; import {Condition} from "../../../project/game-model/interactions/condition/Condition"; import {MatSnackBar} from "@angular/material/snack-bar"; +import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; @Component({ selector: 'app-character-interaction-editor', @@ -75,4 +76,13 @@ export class CharacterInteractionEditorComponent implements OnInit{ editInteraction(interaction: AbstractInteraction) { this.editedElement = interaction; } + + onAddCondition(interaction: AbstractInteraction, condition: ScriptAccountCondition) { + interaction!.addConditon(condition); + } + + + onDeleteCondition(interaction: AbstractInteraction, condition: ScriptAccountCondition) { + interaction!.removeCondition(condition); + } } diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts index 4eaeff9..88736e2 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts @@ -39,13 +39,7 @@ export class ScriptaccountConditionEditorComponent implements OnInit{ finishEditing() { if(this.addedCondition != undefined) { - const createdCondition = ScriptAccountCondition.constructScriptAccountCondition(this.addedCondition.scriptAccount, this.addedCondition.minValue, this.addedCondition.maxValue); - if(createdCondition != undefined) { - console.log(createdCondition) - this.onCreateCondition.emit(createdCondition); - console.log(this.conditions) - this.dataSource.data = this.conditions; - } + this.onCreateCondition.emit(this.addedCondition); this.addedCondition = undefined; } this.editedCondition = undefined; @@ -55,13 +49,8 @@ export class ScriptaccountConditionEditorComponent implements OnInit{ this.editedCondition = condition; } - deleteCondition(condition: ScriptAccountCondition) { - if(this.addedCondition === condition) { - this.addedCondition = undefined; - this.dataSource.data = this.conditions.concat(); - } else { - this.onDeleteCondition.emit(condition); - this.dataSource.data = this.conditions.concat(); - } + deleteCondition(deletedCondition: ScriptAccountCondition) { + this.onDeleteCondition.emit(deletedCondition); + this.dataSource.data = this.dataSource.data.filter(condition => condition !== deletedCondition); } }