refactor-scriptaccount-action-editor #52

Merged
sebastian merged 4 commits from refactor-scriptaccount-action-editor into character-interactions 2024-06-15 14:04:53 +02:00
4 changed files with 25 additions and 2 deletions
Showing only changes of commit 5d4c9a6e58 - Show all commits

View File

@ -117,13 +117,16 @@
</mat-tab-group>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel *ngIf="!isInteractionSequence(element)">
<mat-expansion-panel-header>
<mat-panel-title>Actions</mat-panel-title>
</mat-expansion-panel-header>
<mat-tab-group>
<mat-tab label="ScriptAccount Actions">
<app-scriptaccount-action-editor [scriptAccounts]="gameModel!.scriptAccounts"></app-scriptaccount-action-editor>
<app-scriptaccount-action-editor [scriptAccounts]="gameModel!.scriptAccounts" [actions]="element.scriptAccountActions"
(onAddAction)="onAddAction(element, $event)" (onRemoveAction)="onRemoveAction(element, $event)"
[enableEditing]="true"
></app-scriptaccount-action-editor>
</mat-tab>
<mat-tab label="Inventory Actions">
<p>Inventory Actions</p>

View File

@ -9,6 +9,7 @@ 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";
import {ScriptAccountAction} from "../../../project/game-model/gamesystems/actions/ScriptAccountAction";
@Component({
selector: 'app-character-interaction-editor',
@ -85,4 +86,15 @@ export class CharacterInteractionEditorComponent implements OnInit{
onDeleteCondition(interaction: AbstractInteraction, condition: ScriptAccountCondition) {
interaction!.removeCondition(condition);
}
onAddAction(interaction: AbstractInteraction, action: ScriptAccountAction) {
if(interaction instanceof Interaction) {
interaction.addAction(action);
}
}
onRemoveAction(interaction: AbstractInteraction, action: ScriptAccountAction) {
if(interaction instanceof Interaction) {
interaction.removeAction(action);
}
}
}

View File

@ -3,6 +3,7 @@ import {Condition} from "./condition/Condition";
import {ScriptAccountCondition} from "../gamesystems/conditions/ScriptAccountCondition";
import {InventoryCondition} from "./condition/InventoryCondition";
import {GamesystemCondition} from "./condition/GamesystemCondition";
import {Action} from "./actions/Action";
export abstract class AbstractInteraction {

View File

@ -35,4 +35,11 @@ export class Interaction extends AbstractInteraction{
}
addAction(action: Action) {
this.actions.push(action);
}
removeAction(deletedAction: Action) {
this.actions = this.actions.filter(action => action !== deletedAction);
}
}