weapon-modal.component.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import { Component, EventEmitter, Output } from '@angular/core';
  2. import { NgxSmartModalService } from 'ngx-smart-modal';
  3. import { Damage } from 'src/interfaces/damage';
  4. import { Weapon } from 'src/interfaces/weapon';
  5. @Component({
  6. selector: 'weapon-modal',
  7. templateUrl: './weapon-modal.component.html',
  8. styleUrls: ['./weapon-modal.component.scss'],
  9. })
  10. export class WeaponModalComponent {
  11. public constructor(public ngxSmartModalService: NgxSmartModalService) {}
  12. @Output() public weaponCreated: EventEmitter<Weapon> =
  13. new EventEmitter<Weapon>();
  14. public active: number = 1;
  15. public newWeaponName: string = '';
  16. public newWeaponRange: string = '5 ft.';
  17. public newWeaponAttackBonus: string = '';
  18. public newWeaponDamage: Damage[] = [
  19. { diceNumber: '', diceType: '', damageType: '' },
  20. ];
  21. public newWeaponProficient: boolean = false;
  22. public newWeaponAttribute: string = '';
  23. public newWeaponIsVersatile: boolean = false;
  24. public newWeaponIsTwoHanded: boolean = false;
  25. public newWeaponIsFinesse: boolean = false;
  26. public newWeaponIsRanged: boolean = false;
  27. public newWeaponVersatileDamage: Damage[] = [
  28. { diceNumber: '', diceType: '', damageType: '' },
  29. ];
  30. public newWeaponWeight: string = 'normal';
  31. // Options for the select boxes
  32. public weights: string[] = ['leicht', 'normal', 'schwer'];
  33. public damageTypes: any[] = [
  34. { display: 'Wucht', value: 'bludgeoning' },
  35. { display: 'Stich', value: 'piercing' },
  36. { display: 'Hieb', value: 'slashing' },
  37. { display: 'Feuer', value: 'fire' },
  38. { display: 'Kälte', value: 'cold' },
  39. { display: 'Blitz', value: 'lightning' },
  40. { display: 'Gift', value: 'poison' },
  41. { display: 'Säure', value: 'acid' },
  42. { display: 'Nekrotisch', value: 'necrotic' },
  43. { display: 'Psychisch', value: 'psychic' },
  44. { display: 'Heilig', value: 'holy' },
  45. { display: 'Göttlich', value: 'divine' },
  46. { display: 'Kraft', value: 'force' },
  47. ];
  48. public dice: string[] = ['d4', 'd6', 'd8', 'd10', 'd12', 'd20', 'd100'];
  49. public numbers: string[] = [
  50. '1',
  51. '2',
  52. '3',
  53. '4',
  54. '5',
  55. '6',
  56. '7',
  57. '8',
  58. '9',
  59. '10',
  60. ];
  61. //
  62. public createWeapon(): void {
  63. const newWeapon: Weapon = {
  64. name: this.newWeaponName,
  65. damage: this.newWeaponDamage,
  66. attackBonus: this.newWeaponAttackBonus,
  67. range: this.newWeaponRange,
  68. isFinesse: this.newWeaponIsFinesse,
  69. proficient: this.newWeaponProficient,
  70. isTwoHanded: this.newWeaponIsTwoHanded,
  71. isVersatile: this.newWeaponIsVersatile,
  72. isRanged: this.newWeaponIsRanged,
  73. versatileDamage: this.newWeaponVersatileDamage,
  74. weight: this.newWeaponWeight,
  75. };
  76. this.weaponCreated.emit(newWeapon);
  77. this.ngxSmartModalService.closeLatestModal();
  78. }
  79. public addDamage(): void {
  80. this.newWeaponDamage.push({ diceNumber: '', diceType: '', damageType: '' });
  81. this.newWeaponVersatileDamage.push({
  82. diceNumber: '',
  83. diceType: '',
  84. damageType: '',
  85. });
  86. }
  87. public removeDamage(index: number): void {
  88. this.newWeaponDamage.splice(index, 1);
  89. this.newWeaponVersatileDamage.splice(index, 1);
  90. }
  91. public removeData(): void {
  92. this.newWeaponName = '';
  93. this.newWeaponRange = '5 ft.';
  94. this.newWeaponAttackBonus = '';
  95. this.newWeaponDamage = [{ diceNumber: '', diceType: '', damageType: '' }];
  96. this.newWeaponProficient = false;
  97. this.newWeaponAttribute = '';
  98. this.newWeaponIsVersatile = false;
  99. this.newWeaponIsTwoHanded = false;
  100. this.newWeaponIsFinesse = false;
  101. this.newWeaponIsRanged = false;
  102. this.newWeaponVersatileDamage = [
  103. { diceNumber: '', diceType: '', damageType: '' },
  104. ];
  105. this.newWeaponWeight = 'normal';
  106. }
  107. }