import { Component, EventEmitter, Output } from '@angular/core'; import { NgxSmartModalService } from 'ngx-smart-modal'; import { Damage } from 'src/interfaces/damage'; import { Weapon } from 'src/interfaces/weapon'; @Component({ selector: 'weapon-modal', templateUrl: './weapon-modal.component.html', styleUrls: ['./weapon-modal.component.scss'], }) export class WeaponModalComponent { public constructor(public ngxSmartModalService: NgxSmartModalService) {} @Output() public weaponCreated: EventEmitter = new EventEmitter(); public active: number = 1; public newWeaponName: string = ''; public newWeaponRange: string = '5 ft.'; public newWeaponAttackBonus: string = ''; public newWeaponDamage: Damage[] = [ { diceNumber: '', diceType: '', damageType: '' }, ]; public newWeaponProficient: boolean = false; public newWeaponAttribute: string = ''; public newWeaponIsVersatile: boolean = false; public newWeaponIsTwoHanded: boolean = false; public newWeaponIsFinesse: boolean = false; public newWeaponIsRanged: boolean = false; public newWeaponVersatileDamage: Damage[] = [ { diceNumber: '', diceType: '', damageType: '' }, ]; public newWeaponWeight: string = 'normal'; // Options for the select boxes public weights: string[] = ['leicht', 'normal', 'schwer']; public damageTypes: any[] = [ { display: 'Wucht', value: 'bludgeoning' }, { display: 'Stich', value: 'piercing' }, { display: 'Hieb', value: 'slashing' }, { display: 'Feuer', value: 'fire' }, { display: 'Kälte', value: 'cold' }, { display: 'Blitz', value: 'lightning' }, { display: 'Gift', value: 'poison' }, { display: 'Säure', value: 'acid' }, { display: 'Nekrotisch', value: 'necrotic' }, { display: 'Psychisch', value: 'psychic' }, { display: 'Heilig', value: 'holy' }, { display: 'Göttlich', value: 'divine' }, { display: 'Kraft', value: 'force' }, ]; public dice: string[] = ['d4', 'd6', 'd8', 'd10', 'd12', 'd20', 'd100']; public numbers: string[] = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', ]; // public createWeapon(): void { const newWeapon: Weapon = { name: this.newWeaponName, damage: this.newWeaponDamage, attackBonus: this.newWeaponAttackBonus, range: this.newWeaponRange, isFinesse: this.newWeaponIsFinesse, proficient: this.newWeaponProficient, isTwoHanded: this.newWeaponIsTwoHanded, isVersatile: this.newWeaponIsVersatile, isRanged: this.newWeaponIsRanged, versatileDamage: this.newWeaponVersatileDamage, weight: this.newWeaponWeight, }; this.weaponCreated.emit(newWeapon); this.ngxSmartModalService.closeLatestModal(); } public addDamage(): void { this.newWeaponDamage.push({ diceNumber: '', diceType: '', damageType: '' }); this.newWeaponVersatileDamage.push({ diceNumber: '', diceType: '', damageType: '', }); } public removeDamage(index: number): void { this.newWeaponDamage.splice(index, 1); this.newWeaponVersatileDamage.splice(index, 1); } public removeData(): void { this.newWeaponName = ''; this.newWeaponRange = '5 ft.'; this.newWeaponAttackBonus = ''; this.newWeaponDamage = [{ diceNumber: '', diceType: '', damageType: '' }]; this.newWeaponProficient = false; this.newWeaponAttribute = ''; this.newWeaponIsVersatile = false; this.newWeaponIsTwoHanded = false; this.newWeaponIsFinesse = false; this.newWeaponIsRanged = false; this.newWeaponVersatileDamage = [ { diceNumber: '', diceType: '', damageType: '' }, ]; this.newWeaponWeight = 'normal'; } }