|
@@ -1,5 +1,5 @@
|
|
|
-import { Component, EventEmitter, Output } from '@angular/core';
|
|
|
|
|
-import { NgxSmartModalService } from 'ngx-smart-modal';
|
|
|
|
|
|
|
+import { Component, Input } from '@angular/core';
|
|
|
|
|
+import { ModalService } from 'src/services/modal/modal.service';
|
|
|
import { Damage } from 'src/interfaces/damage';
|
|
import { Damage } from 'src/interfaces/damage';
|
|
|
import { Heal } from 'src/interfaces/heal';
|
|
import { Heal } from 'src/interfaces/heal';
|
|
|
import { Spell } from 'src/interfaces/spell';
|
|
import { Spell } from 'src/interfaces/spell';
|
|
@@ -10,49 +10,37 @@ import { Spell } from 'src/interfaces/spell';
|
|
|
styleUrls: ['./spell-modal.component.scss'],
|
|
styleUrls: ['./spell-modal.component.scss'],
|
|
|
})
|
|
})
|
|
|
export class SpellModalComponent {
|
|
export class SpellModalComponent {
|
|
|
- public constructor(public ngxSmartModalService: NgxSmartModalService) {}
|
|
|
|
|
- @Output() public spellCreated: EventEmitter<Spell> =
|
|
|
|
|
- new EventEmitter<Spell>();
|
|
|
|
|
- @Output() public spellUpdated: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
-
|
|
|
|
|
- @Output() public spellDeleted: EventEmitter<number> =
|
|
|
|
|
- new EventEmitter<number>();
|
|
|
|
|
-
|
|
|
|
|
- public active: number = 1;
|
|
|
|
|
-
|
|
|
|
|
- public newSpellName: string = '';
|
|
|
|
|
- public newSpellLevel: number = 0;
|
|
|
|
|
- public newSpellCost: string = 'action';
|
|
|
|
|
- public newSpellCanRitual: boolean = false;
|
|
|
|
|
- public newSpellNeedsConcentration: boolean = false;
|
|
|
|
|
- public newSpellNeedsVerbal: boolean = false;
|
|
|
|
|
- public newSpellNeedsSomatic: boolean = false;
|
|
|
|
|
- public newSpellNeedsMaterial: boolean = false;
|
|
|
|
|
- public newSpellSchool: string = '';
|
|
|
|
|
- public newSpellDescription: string = '';
|
|
|
|
|
- public newSpellDoesDamage: boolean = true;
|
|
|
|
|
- public newSpellDoesHeal: boolean = false;
|
|
|
|
|
- public newSpellNeedsAttackRoll: boolean = false;
|
|
|
|
|
- public newSpellNeedsSavingThrow: boolean = false;
|
|
|
|
|
- public newSpellSavingThrowAttribute: string | undefined;
|
|
|
|
|
- public newSpellNeedsAttackThrow: boolean = false;
|
|
|
|
|
- public newSpellHeal: Heal = {
|
|
|
|
|
|
|
+ public constructor(private modalAccessor: ModalService) {}
|
|
|
|
|
+ @Input() public spell: any;
|
|
|
|
|
+ @Input() public isUpdate: boolean = false;
|
|
|
|
|
+
|
|
|
|
|
+ public name: string = '';
|
|
|
|
|
+ public level: number = 0;
|
|
|
|
|
+ public cost: string = 'action';
|
|
|
|
|
+ public canRitual: boolean = false;
|
|
|
|
|
+ public needsConcentration: boolean = false;
|
|
|
|
|
+ public needsVerbal: boolean = false;
|
|
|
|
|
+ public needsSomatic: boolean = false;
|
|
|
|
|
+ public needsMaterial: boolean = false;
|
|
|
|
|
+ public school: string = '';
|
|
|
|
|
+ public description: string = '';
|
|
|
|
|
+ public doesDamage: boolean = false;
|
|
|
|
|
+ public doesHeal: boolean = false;
|
|
|
|
|
+ public needsAttackRoll: boolean = false;
|
|
|
|
|
+ public needsSavingThrow: boolean = false;
|
|
|
|
|
+ public savingThrowAttribute: string = '';
|
|
|
|
|
+ public heal: Heal = {
|
|
|
diceNumber: '',
|
|
diceNumber: '',
|
|
|
diceType: '',
|
|
diceType: '',
|
|
|
additionalHeal: 0,
|
|
additionalHeal: 0,
|
|
|
};
|
|
};
|
|
|
- public newSpellAttackBonus: string = '';
|
|
|
|
|
- public newSpellDamage: Damage[] = [
|
|
|
|
|
- { diceNumber: '', diceType: '', damageType: '' },
|
|
|
|
|
- ];
|
|
|
|
|
- public newSpellIsRanged: boolean = false;
|
|
|
|
|
- public newSpellRange: number = 5;
|
|
|
|
|
- public newSpellHasAreaOfEffect: boolean = false;
|
|
|
|
|
- public newSpellRadius: number | undefined;
|
|
|
|
|
- public newSpellAreaOfEffectType: string | undefined;
|
|
|
|
|
-
|
|
|
|
|
- public isUpdate: boolean = false;
|
|
|
|
|
- public indexForUpdate: number | undefined;
|
|
|
|
|
|
|
+ public attackBonus: string = '';
|
|
|
|
|
+ public damage: Damage[] = [{ diceNumber: '', diceType: '', damageType: '' }];
|
|
|
|
|
+ public isRanged: boolean = false;
|
|
|
|
|
+ public range: number = 5;
|
|
|
|
|
+ public hasAreaOfEffect: boolean = false;
|
|
|
|
|
+ public radius: number = 0;
|
|
|
|
|
+ public areaOfEffectType: string = '';
|
|
|
|
|
|
|
|
// Options for the select boxes
|
|
// Options for the select boxes
|
|
|
public areaTypes: any[] = [
|
|
public areaTypes: any[] = [
|
|
@@ -121,162 +109,116 @@ export class SpellModalComponent {
|
|
|
{ display: 'Reaktion', value: 'reaction' },
|
|
{ display: 'Reaktion', value: 'reaction' },
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- 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,
|
|
|
|
|
- needsAttackRoll: this.newSpellNeedsAttackRoll,
|
|
|
|
|
- needsSavingThrow: this.newSpellNeedsSavingThrow,
|
|
|
|
|
- isRanged: this.newSpellIsRanged,
|
|
|
|
|
- range: this.newSpellRange,
|
|
|
|
|
- hasAreaOfEffect: this.newSpellHasAreaOfEffect,
|
|
|
|
|
- doesDamage: this.newSpellDoesDamage,
|
|
|
|
|
- doesHeal: this.newSpellDoesHeal,
|
|
|
|
|
- description: this.newSpellDescription,
|
|
|
|
|
- school: this.newSpellSchool,
|
|
|
|
|
- };
|
|
|
|
|
- if (this.newSpellDescription) {
|
|
|
|
|
- newspell.description = this.newSpellDescription;
|
|
|
|
|
|
|
+ public ngOnInit(): void {
|
|
|
|
|
+ if (this.isUpdate) {
|
|
|
|
|
+ this.loadspell();
|
|
|
}
|
|
}
|
|
|
- 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: '' });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // RESPONSES
|
|
|
|
|
|
|
|
- public removeDamage(index: number): void {
|
|
|
|
|
- this.newSpellDamage.splice(index, 1);
|
|
|
|
|
|
|
+ public cancel(): void {
|
|
|
|
|
+ this.modalAccessor.handleModalClosing('cancel', undefined);
|
|
|
|
|
+ this.resetSpell();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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 = '';
|
|
|
|
|
- this.newSpellDescription = '';
|
|
|
|
|
- this.newSpellNeedsAttackRoll = false;
|
|
|
|
|
- this.newSpellNeedsSavingThrow = false;
|
|
|
|
|
- this.newSpellSavingThrowAttribute = undefined;
|
|
|
|
|
- this.newSpellDoesDamage = false;
|
|
|
|
|
- this.newSpellDoesHeal = false;
|
|
|
|
|
- this.newSpellHeal = { diceNumber: '', diceType: '' };
|
|
|
|
|
- this.newSpellAttackBonus = '';
|
|
|
|
|
- this.newSpellDamage = [{ diceNumber: '', diceType: '', damageType: '' }];
|
|
|
|
|
- this.newSpellIsRanged = false;
|
|
|
|
|
- this.newSpellRange = 5;
|
|
|
|
|
- this.newSpellHasAreaOfEffect = false;
|
|
|
|
|
- this.newSpellRadius = undefined;
|
|
|
|
|
- this.newSpellAreaOfEffectType = undefined;
|
|
|
|
|
- this.isUpdate = false;
|
|
|
|
|
- this.ngxSmartModalService.resetModalData('spellModal');
|
|
|
|
|
|
|
+ public add(): void {
|
|
|
|
|
+ this.modalAccessor.handleModalClosing('add', this.createSpell());
|
|
|
|
|
+ this.resetSpell();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // update
|
|
|
|
|
-
|
|
|
|
|
- public checkIfUpdate(): void {
|
|
|
|
|
- if (this.ngxSmartModalService.getModalData('spellModal')) {
|
|
|
|
|
- this.isUpdate = true;
|
|
|
|
|
- const data: any = this.ngxSmartModalService.getModalData('spellModal');
|
|
|
|
|
- const spell = data.spell;
|
|
|
|
|
- this.newSpellName = spell.name;
|
|
|
|
|
- this.newSpellLevel = spell.level;
|
|
|
|
|
- this.newSpellCost = spell.cost;
|
|
|
|
|
- this.newSpellCanRitual = spell.canRitual;
|
|
|
|
|
- this.newSpellNeedsConcentration = spell.needsConcentration;
|
|
|
|
|
- this.newSpellNeedsVerbal = spell.needsVerbal;
|
|
|
|
|
- this.newSpellNeedsSomatic = spell.needsSomatic;
|
|
|
|
|
- this.newSpellNeedsMaterial = spell.needsMaterial;
|
|
|
|
|
- this.newSpellSchool = spell.school;
|
|
|
|
|
- this.newSpellDescription = spell.description;
|
|
|
|
|
- this.newSpellDoesDamage = spell.doesDamage;
|
|
|
|
|
- this.newSpellNeedsSavingThrow = spell.needsSavingThrow;
|
|
|
|
|
- this.newSpellSavingThrowAttribute = spell.savingThrowAttribute;
|
|
|
|
|
- this.newSpellDamage = spell.damage;
|
|
|
|
|
- this.newSpellIsRanged = spell.isRanged;
|
|
|
|
|
- this.newSpellRange = spell.range;
|
|
|
|
|
- this.newSpellHasAreaOfEffect = spell.hasAreaOfEffect;
|
|
|
|
|
- this.newSpellRadius = spell.radius;
|
|
|
|
|
- this.newSpellAreaOfEffectType = spell.areaOfEffectType;
|
|
|
|
|
|
|
+ public update(): void {
|
|
|
|
|
+ this.modalAccessor.handleModalClosing('update', this.createSpell());
|
|
|
|
|
+ this.resetSpell();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- this.indexForUpdate = data.index;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private loadspell(): void {
|
|
|
|
|
+ console.log(this.spell.school);
|
|
|
|
|
+ this.name = this.spell.name;
|
|
|
|
|
+ this.level = this.spell.level;
|
|
|
|
|
+ this.cost = this.spell.cost;
|
|
|
|
|
+ this.canRitual = this.spell.canRitual;
|
|
|
|
|
+ this.needsConcentration = this.spell.needsConcentration;
|
|
|
|
|
+ this.needsVerbal = this.spell.needsVerbal;
|
|
|
|
|
+ this.needsSomatic = this.spell.needsSomatic;
|
|
|
|
|
+ this.needsMaterial = this.spell.needsMaterial;
|
|
|
|
|
+ this.school = this.spell.school;
|
|
|
|
|
+ this.description = this.spell.description;
|
|
|
|
|
+ this.doesDamage = this.spell.doesDamage;
|
|
|
|
|
+ this.needsSavingThrow = this.spell.needsSavingThrow;
|
|
|
|
|
+ this.savingThrowAttribute = this.spell.savingThrowAttribute;
|
|
|
|
|
+ this.damage = this.spell.damage;
|
|
|
|
|
+ this.isRanged = this.spell.isRanged;
|
|
|
|
|
+ this.range = this.spell.range;
|
|
|
|
|
+ this.hasAreaOfEffect = this.spell.hasAreaOfEffect;
|
|
|
|
|
+ this.radius = this.spell.radius;
|
|
|
|
|
+ this.areaOfEffectType = this.spell.areaOfEffectType;
|
|
|
|
|
+ this.needsAttackRoll = this.spell.needsAttackRoll;
|
|
|
|
|
+ this.attackBonus = this.spell.attackBonus;
|
|
|
|
|
+ this.doesHeal = this.spell.doesHeal;
|
|
|
|
|
+ this.heal = this.spell.heal;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // überarbeiten
|
|
|
|
|
- public updateSpell(): void {
|
|
|
|
|
- const newspell: Spell = {
|
|
|
|
|
- name: this.newSpellName,
|
|
|
|
|
- damage: this.newSpellDamage,
|
|
|
|
|
- level: this.newSpellLevel,
|
|
|
|
|
- cost: this.newSpellCost,
|
|
|
|
|
- canRitual: this.newSpellCanRitual,
|
|
|
|
|
- school: this.newSpellSchool,
|
|
|
|
|
- description: this.newSpellDescription,
|
|
|
|
|
- needsConcentration: this.newSpellNeedsConcentration,
|
|
|
|
|
- needsVerbal: this.newSpellNeedsVerbal,
|
|
|
|
|
- needsSomatic: this.newSpellNeedsSomatic,
|
|
|
|
|
- needsMaterial: this.newSpellNeedsMaterial,
|
|
|
|
|
- needsAttackRoll: this.newSpellNeedsAttackRoll,
|
|
|
|
|
- needsSavingThrow: this.newSpellNeedsSavingThrow,
|
|
|
|
|
- isRanged: this.newSpellIsRanged,
|
|
|
|
|
- range: this.newSpellRange,
|
|
|
|
|
- hasAreaOfEffect: this.newSpellHasAreaOfEffect,
|
|
|
|
|
- doesDamage: this.newSpellDoesDamage,
|
|
|
|
|
- doesHeal: this.newSpellDoesHeal,
|
|
|
|
|
|
|
+ private createSpell(): Spell {
|
|
|
|
|
+ const spell: Spell = {
|
|
|
|
|
+ name: this.name,
|
|
|
|
|
+ damage: this.damage,
|
|
|
|
|
+ heal: this.heal,
|
|
|
|
|
+ level: this.level,
|
|
|
|
|
+ cost: this.cost,
|
|
|
|
|
+ canRitual: this.canRitual,
|
|
|
|
|
+ school: this.school,
|
|
|
|
|
+ description: this.description,
|
|
|
|
|
+ needsConcentration: this.needsConcentration,
|
|
|
|
|
+ needsVerbal: this.needsVerbal,
|
|
|
|
|
+ needsSomatic: this.needsSomatic,
|
|
|
|
|
+ needsMaterial: this.needsMaterial,
|
|
|
|
|
+ needsAttackRoll: this.needsAttackRoll,
|
|
|
|
|
+ needsSavingThrow: this.needsSavingThrow,
|
|
|
|
|
+ savingThrowAttribute: this.savingThrowAttribute,
|
|
|
|
|
+ isRanged: this.isRanged,
|
|
|
|
|
+ range: this.range,
|
|
|
|
|
+ radius: this.radius,
|
|
|
|
|
+ hasAreaOfEffect: this.hasAreaOfEffect,
|
|
|
|
|
+ areaOfEffectType: this.areaOfEffectType,
|
|
|
|
|
+ doesDamage: this.doesDamage,
|
|
|
|
|
+ doesHeal: this.doesHeal,
|
|
|
};
|
|
};
|
|
|
- if (this.newSpellNeedsSavingThrow) {
|
|
|
|
|
- newspell.savingThrowAttribute = this.newSpellSavingThrowAttribute;
|
|
|
|
|
- }
|
|
|
|
|
- if (this.newSpellHasAreaOfEffect) {
|
|
|
|
|
- newspell.radius = this.newSpellRadius;
|
|
|
|
|
- newspell.areaOfEffectType = this.newSpellAreaOfEffectType;
|
|
|
|
|
- }
|
|
|
|
|
- if (this.newSpellDoesHeal) {
|
|
|
|
|
- newspell.healAmount = this.newSpellHeal;
|
|
|
|
|
- }
|
|
|
|
|
- this.spellUpdated.emit({ spell: newspell, index: this.indexForUpdate });
|
|
|
|
|
- this.ngxSmartModalService.closeLatestModal();
|
|
|
|
|
- this.removeData();
|
|
|
|
|
|
|
+ console.log('New Spell from modal: ', spell);
|
|
|
|
|
+ return spell;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private resetSpell(): void {
|
|
|
|
|
+ this.name = '';
|
|
|
|
|
+ this.level = 0;
|
|
|
|
|
+ this.cost = 'action';
|
|
|
|
|
+ this.canRitual = false;
|
|
|
|
|
+ this.needsConcentration = false;
|
|
|
|
|
+ this.needsVerbal = false;
|
|
|
|
|
+ this.needsSomatic = false;
|
|
|
|
|
+ this.needsMaterial = false;
|
|
|
|
|
+ this.school = '';
|
|
|
|
|
+ this.description = '';
|
|
|
|
|
+ this.doesDamage = true;
|
|
|
|
|
+ this.needsSavingThrow = false;
|
|
|
|
|
+ this.savingThrowAttribute = '';
|
|
|
|
|
+ this.damage = [{ diceNumber: '', diceType: '', damageType: '' }];
|
|
|
|
|
+ this.isRanged = false;
|
|
|
|
|
+ this.range = 5;
|
|
|
|
|
+ this.hasAreaOfEffect = false;
|
|
|
|
|
+ this.radius = 0;
|
|
|
|
|
+ this.areaOfEffectType = '';
|
|
|
|
|
+ this.needsAttackRoll = false;
|
|
|
|
|
+ this.attackBonus = '';
|
|
|
|
|
+ this.doesHeal = false;
|
|
|
|
|
+ this.heal = { diceNumber: '', diceType: '', additionalHeal: 0 };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public deleteSpell(): void {
|
|
|
|
|
- this.spellDeleted.emit(this.indexForUpdate);
|
|
|
|
|
- console.log('deleteSpell()', this.indexForUpdate);
|
|
|
|
|
- this.ngxSmartModalService.closeLatestModal();
|
|
|
|
|
- this.removeData();
|
|
|
|
|
|
|
+ public addDamage(): void {
|
|
|
|
|
+ this.damage.push({ diceNumber: '', diceType: '', damageType: '' });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public dismiss(): void {
|
|
|
|
|
- this.ngxSmartModalService.closeLatestModal();
|
|
|
|
|
- this.removeData();
|
|
|
|
|
|
|
+ public removeDamage(index: number): void {
|
|
|
|
|
+ this.damage.splice(index, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|