|
@@ -0,0 +1,105 @@
|
|
|
|
+import { Component, Output, EventEmitter, Input } from '@angular/core';
|
|
|
|
+import { NgxSmartModalService } from 'ngx-smart-modal';
|
|
|
|
+import { Ability } from 'src/interfaces/ability';
|
|
|
|
+import { Damage } from 'src/interfaces/damage';
|
|
|
|
+import { Heal } from 'src/interfaces/heal';
|
|
|
|
+
|
|
|
|
+@Component({
|
|
|
|
+ selector: 'ability-modal',
|
|
|
|
+ templateUrl: './ability-modal.component.html',
|
|
|
|
+ styleUrls: ['./ability-modal.component.scss'],
|
|
|
|
+})
|
|
|
|
+export class AbilityModalComponent {
|
|
|
|
+ public constructor(public ngxSmartModalService: NgxSmartModalService) {}
|
|
|
|
+
|
|
|
|
+ @Output() public abilityCreated: EventEmitter<Ability> =
|
|
|
|
+ new EventEmitter<Ability>();
|
|
|
|
+
|
|
|
|
+ @Output() public abilityUpdated: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
+
|
|
|
|
+ @Output() public abilityDelete: EventEmitter<number> =
|
|
|
|
+ new EventEmitter<number>();
|
|
|
|
+
|
|
|
|
+ @Input() public isToUpdate: boolean = false;
|
|
|
|
+ @Input() public abilityToUpdate: Ability | undefined;
|
|
|
|
+
|
|
|
|
+ public newAbilityName: string = '';
|
|
|
|
+ public newAbilityCharges: number = 0;
|
|
|
|
+ public newAbilityCurrentlyUsedCharges: number = 0;
|
|
|
|
+ public newAbilityCost: string = 'none';
|
|
|
|
+ public newAbilityShortDescription: string = '';
|
|
|
|
+ public newAbilityLongDescription: string = '';
|
|
|
|
+
|
|
|
|
+ public costs: any[] = [
|
|
|
|
+ { display: 'keine', value: 'none' },
|
|
|
|
+ { display: 'Aktion', value: 'action' },
|
|
|
|
+ { display: 'Bonusaktion', value: 'bonus' },
|
|
|
|
+ { display: 'Reaktion', value: 'reaction' },
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public charges: any[] = [
|
|
|
|
+ { display: 'unbegrenzt', value: 0 },
|
|
|
|
+ { display: '1', value: 1 },
|
|
|
|
+ { display: '2', value: 2 },
|
|
|
|
+ { display: '3', value: 3 },
|
|
|
|
+ { display: '4', value: 4 },
|
|
|
|
+ { display: '5', value: 5 },
|
|
|
|
+ { display: '6', value: 6 },
|
|
|
|
+ { display: '7', value: 7 },
|
|
|
|
+ { display: '8', value: 8 },
|
|
|
|
+ { display: '9', value: 9 },
|
|
|
|
+ { display: '10', value: 10 },
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public createAbility(): void {
|
|
|
|
+ const newAbility: Ability = {
|
|
|
|
+ name: this.newAbilityName,
|
|
|
|
+ shortDescription: this.newAbilityShortDescription,
|
|
|
|
+ longDescription: this.newAbilityLongDescription,
|
|
|
|
+ cost: this.newAbilityCost,
|
|
|
|
+ charges: this.newAbilityCharges,
|
|
|
|
+ currentlyUsedCharges: 0,
|
|
|
|
+ };
|
|
|
|
+ this.abilityCreated.emit(newAbility);
|
|
|
|
+ this.ngxSmartModalService.closeLatestModal();
|
|
|
|
+ this.resetModalData();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public checkIfUpdate(): void {
|
|
|
|
+ if (this.isToUpdate) {
|
|
|
|
+ this.newAbilityName = this.abilityToUpdate?.name || '';
|
|
|
|
+ this.newAbilityCharges = this.abilityToUpdate?.charges || 0;
|
|
|
|
+ this.newAbilityCurrentlyUsedCharges =
|
|
|
|
+ this.abilityToUpdate?.currentlyUsedCharges || 0;
|
|
|
|
+ this.newAbilityCost = this.abilityToUpdate?.cost || 'none';
|
|
|
|
+ this.newAbilityShortDescription =
|
|
|
|
+ this.abilityToUpdate?.shortDescription || '';
|
|
|
|
+ this.newAbilityLongDescription =
|
|
|
|
+ this.abilityToUpdate?.longDescription || '';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public updateAbility(): void {
|
|
|
|
+ const updatedAbility: Ability = {
|
|
|
|
+ name: this.newAbilityName,
|
|
|
|
+ shortDescription: this.newAbilityShortDescription,
|
|
|
|
+ longDescription: this.newAbilityLongDescription,
|
|
|
|
+ cost: this.newAbilityCost,
|
|
|
|
+ charges: this.newAbilityCharges,
|
|
|
|
+ currentlyUsedCharges: this.newAbilityCurrentlyUsedCharges,
|
|
|
|
+ };
|
|
|
|
+ this.abilityUpdated.emit(updatedAbility);
|
|
|
|
+ this.ngxSmartModalService.closeLatestModal();
|
|
|
|
+ this.resetModalData();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private resetModalData(): void {
|
|
|
|
+ this.newAbilityName = '';
|
|
|
|
+ this.newAbilityShortDescription = '';
|
|
|
|
+ this.newAbilityLongDescription = '';
|
|
|
|
+ this.newAbilityCost = 'none';
|
|
|
|
+ this.newAbilityCharges = 0;
|
|
|
|
+ this.isToUpdate = false;
|
|
|
|
+ this.abilityToUpdate = undefined;
|
|
|
|
+ }
|
|
|
|
+}
|