123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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<Weapon> =
- new EventEmitter<Weapon>();
- 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';
- }
- }
|