|
@@ -1,10 +1,166 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
+import { Component, EventEmitter, Output } from '@angular/core';
|
|
|
+import { NgxSmartModalService } from 'ngx-smart-modal';
|
|
|
+import { Damage } from 'src/interfaces/damage';
|
|
|
+import { Spell } from 'src/interfaces/spell';
|
|
|
|
|
|
@Component({
|
|
|
- selector: 'app-spell-modal',
|
|
|
+ selector: 'spell-modal',
|
|
|
templateUrl: './spell-modal.component.html',
|
|
|
- styleUrls: ['./spell-modal.component.scss']
|
|
|
+ styleUrls: ['./spell-modal.component.scss'],
|
|
|
})
|
|
|
export class SpellModalComponent {
|
|
|
+ public constructor(public ngxSmartModalService: NgxSmartModalService) {}
|
|
|
+ @Output() public spellCreated: EventEmitter<Spell> =
|
|
|
+ new EventEmitter<Spell>();
|
|
|
|
|
|
+ public newSpellName: string = '';
|
|
|
+ public newSpellLevel: number = 0;
|
|
|
+ public newSpellCost: string = '';
|
|
|
+ public newSpellCanRitual: boolean = false;
|
|
|
+ public newSpellNeedsConcentration: boolean = false;
|
|
|
+ public newSpellNeedsVerbal: boolean = false;
|
|
|
+ public newSpellNeedsSomatic: boolean = false;
|
|
|
+ public newSpellNeedsMaterial: boolean = false;
|
|
|
+ public newSpellSchool: string | undefined;
|
|
|
+ public newSpellDescription: string | undefined;
|
|
|
+ public newSpellNeedsSavingThrow: boolean = false;
|
|
|
+ public newSpellSavingThrowAttribute: string | undefined;
|
|
|
+ public newSpellAttackBonus: string = '';
|
|
|
+ public newSpellDamage: Damage[] = [
|
|
|
+ { diceNumber: '', diceType: '', damageType: '' },
|
|
|
+ ];
|
|
|
+ public newSpellIsRanged: boolean = false;
|
|
|
+ public newSpellRange: string = '5ft';
|
|
|
+ public newSpellHasAreaOfEffect: boolean = false;
|
|
|
+ public newSpellRadius: string | undefined;
|
|
|
+ public newSpellAreaOfEffectType: string | undefined;
|
|
|
+
|
|
|
+ // Options for the select boxes
|
|
|
+ public areaTypes: any[] = [
|
|
|
+ { display: 'Kegel', value: 'cone' },
|
|
|
+ { display: 'Kugel', value: 'sphere' },
|
|
|
+ { display: 'Kreis', value: 'circle' },
|
|
|
+ { display: 'Linie', value: 'line' },
|
|
|
+ { display: 'Quadrat', value: 'square' },
|
|
|
+ { display: 'Würfel', value: 'cube' },
|
|
|
+ ];
|
|
|
+
|
|
|
+ public schools: any[] = [
|
|
|
+ { display: 'Verwandlung', value: 'transmutation' },
|
|
|
+ { display: 'Verzauberung', value: 'enchantment' },
|
|
|
+ { display: 'Illusion', value: 'illusion' },
|
|
|
+ { display: 'Nekromantie', value: 'necromancy' },
|
|
|
+ { display: 'Beschwörung', value: 'conjuration' },
|
|
|
+ { display: 'Hervorrufung', value: 'evocation' },
|
|
|
+ { display: 'Bannmagie', value: 'abjuration' },
|
|
|
+ { display: 'Wahrsagerei', value: 'divination' },
|
|
|
+ ];
|
|
|
+
|
|
|
+ public savingThrowAttributes: any[] = [
|
|
|
+ { display: 'Stärke', value: 'strength' },
|
|
|
+ { display: 'Geschicklichkeit', value: 'dexterity' },
|
|
|
+ { display: 'Konstitution', value: 'constitution' },
|
|
|
+ { display: 'Intelligenz', value: 'intelligence' },
|
|
|
+ { display: 'Weisheit', value: 'wisdom' },
|
|
|
+ { display: 'Charisma', value: 'charisma' },
|
|
|
+ ];
|
|
|
+
|
|
|
+ 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 createSpell(): void {
|
|
|
+ let newspell: Spell = {
|
|
|
+ name: this.newSpellName,
|
|
|
+ damage: this.newSpellDamage,
|
|
|
+ level: this.newSpellLevel,
|
|
|
+ cost: this.newSpellCost,
|
|
|
+ canRitual: this.newSpellCanRitual,
|
|
|
+ needsConcentration: this.newSpellNeedsConcentration,
|
|
|
+ needsVerbal: this.newSpellNeedsVerbal,
|
|
|
+ needsSomatic: this.newSpellNeedsSomatic,
|
|
|
+ needsMaterial: this.newSpellNeedsMaterial,
|
|
|
+ needsSavingThrow: this.newSpellNeedsSavingThrow,
|
|
|
+ isRanged: this.newSpellIsRanged,
|
|
|
+ range: this.newSpellRange,
|
|
|
+ hasAreaOfEffect: this.newSpellHasAreaOfEffect,
|
|
|
+ };
|
|
|
+ if (this.newSpellDescription) {
|
|
|
+ newspell.description = this.newSpellDescription;
|
|
|
+ }
|
|
|
+ if (this.newSpellSchool) {
|
|
|
+ newspell.school = this.newSpellSchool;
|
|
|
+ }
|
|
|
+ if (this.newSpellSavingThrowAttribute) {
|
|
|
+ newspell.savingThrowAttribute = this.newSpellSavingThrowAttribute;
|
|
|
+ }
|
|
|
+ if (this.newSpellAttackBonus) {
|
|
|
+ newspell.attackBonus = this.newSpellAttackBonus;
|
|
|
+ }
|
|
|
+ if (this.newSpellHasAreaOfEffect) {
|
|
|
+ newspell.radius = this.newSpellRadius;
|
|
|
+ }
|
|
|
+ if (this.newSpellHasAreaOfEffect) {
|
|
|
+ newspell.areaOfEffectType = this.newSpellAreaOfEffectType;
|
|
|
+ }
|
|
|
+ this.spellCreated.emit(newspell);
|
|
|
+ this.ngxSmartModalService.closeLatestModal();
|
|
|
+ }
|
|
|
+
|
|
|
+ public addDamage(): void {
|
|
|
+ this.newSpellDamage.push({ diceNumber: '', diceType: '', damageType: '' });
|
|
|
+ }
|
|
|
+
|
|
|
+ public removeDamage(index: number): void {
|
|
|
+ this.newSpellDamage.splice(index, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public removeData(): void {
|
|
|
+ this.newSpellName = '';
|
|
|
+ this.newSpellLevel = 0;
|
|
|
+ this.newSpellCost = '';
|
|
|
+ this.newSpellCanRitual = false;
|
|
|
+ this.newSpellNeedsConcentration = false;
|
|
|
+ this.newSpellNeedsVerbal = false;
|
|
|
+ this.newSpellNeedsSomatic = false;
|
|
|
+ this.newSpellNeedsMaterial = false;
|
|
|
+ this.newSpellSchool = undefined;
|
|
|
+ this.newSpellDescription = undefined;
|
|
|
+ this.newSpellNeedsSavingThrow = false;
|
|
|
+ this.newSpellSavingThrowAttribute = undefined;
|
|
|
+ this.newSpellAttackBonus = '';
|
|
|
+ this.newSpellDamage = [{ diceNumber: '', diceType: '', damageType: '' }];
|
|
|
+ this.newSpellIsRanged = false;
|
|
|
+ this.newSpellRange = '5ft';
|
|
|
+ this.newSpellHasAreaOfEffect = false;
|
|
|
+ this.newSpellRadius = undefined;
|
|
|
+ this.newSpellAreaOfEffectType = undefined;
|
|
|
+ }
|
|
|
}
|