|
@@ -1,12 +1,19 @@
|
|
import { Component, inject } from '@angular/core';
|
|
import { Component, inject } from '@angular/core';
|
|
import { TranslatorService } from 'src/services/translator/translator.service';
|
|
import { TranslatorService } from 'src/services/translator/translator.service';
|
|
-
|
|
|
|
|
|
+import { ModalService } from 'src/services/modal/modal.service';
|
|
|
|
+import { DataService } from 'src/services/data/data.service';
|
|
|
|
+import { Spell } from 'src/interfaces/spell';
|
|
|
|
+import { CustomSpellsModalComponent } from './custom-spells-modal/custom-spells-modal.component';
|
|
|
|
+import { SpellsService } from 'src/services/spells/spells.service';
|
|
|
|
+import { FullSpellcardComponent } from 'src/app/shared-components/full-spellcard/full-spellcard.component';
|
|
|
|
+import { SpellModalComponent } from '../spell-modal/spell-modal.component';
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-journal-spellbook',
|
|
selector: 'app-journal-spellbook',
|
|
templateUrl: './journal-spellbook.component.html',
|
|
templateUrl: './journal-spellbook.component.html',
|
|
styleUrls: ['./journal-spellbook.component.scss'],
|
|
styleUrls: ['./journal-spellbook.component.scss'],
|
|
})
|
|
})
|
|
export class JournalSpellbookComponent {
|
|
export class JournalSpellbookComponent {
|
|
|
|
+ public filterAll = false;
|
|
public filterArtificer = false;
|
|
public filterArtificer = false;
|
|
public filterBard = false;
|
|
public filterBard = false;
|
|
public filterCleric = false;
|
|
public filterCleric = false;
|
|
@@ -16,50 +23,124 @@ export class JournalSpellbookComponent {
|
|
private filterSorcerer = false;
|
|
private filterSorcerer = false;
|
|
private filterWarlock = false;
|
|
private filterWarlock = false;
|
|
private filterWizard = false;
|
|
private filterWizard = false;
|
|
|
|
+ private previousClasses: string[] = [];
|
|
|
|
+
|
|
|
|
+ public currentLevel: number = 0;
|
|
|
|
+ public filteredSpells: Spell[] = [];
|
|
|
|
|
|
|
|
+ // Services
|
|
public translator = inject(TranslatorService);
|
|
public translator = inject(TranslatorService);
|
|
|
|
+ public modalAccessor = inject(ModalService);
|
|
|
|
+ public dataAccessor = inject(DataService);
|
|
|
|
+ private spellsService = inject(SpellsService);
|
|
|
|
|
|
- // public classNames = [
|
|
|
|
- // 'artificer',
|
|
|
|
- // 'bard',
|
|
|
|
- // 'cleric',
|
|
|
|
- // 'druid',
|
|
|
|
- // 'paladin',
|
|
|
|
- // 'ranger',
|
|
|
|
- // 'sorcerer',
|
|
|
|
- // 'warlock',
|
|
|
|
- // 'wizard',
|
|
|
|
- // ];
|
|
|
|
|
|
+ public ngAfterViewInit(): void {
|
|
|
|
+ const className: string = this.dataAccessor.characterData.class;
|
|
|
|
+ this.toggleClassFilter(className);
|
|
|
|
+ this.refreshFilteredSpells();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // SPELLS FILTER
|
|
|
|
|
|
/**
|
|
/**
|
|
* Toggles the selection of a given class icon. It also updates the filtered spells.
|
|
* Toggles the selection of a given class icon. It also updates the filtered spells.
|
|
|
|
+ * When the all classes button was (de-)selects all classes.
|
|
* @param className The provided class which icon will be toggled.
|
|
* @param className The provided class which icon will be toggled.
|
|
*/
|
|
*/
|
|
public toggleClassSelection(className: string) {
|
|
public toggleClassSelection(className: string) {
|
|
- const element = document.getElementById(className);
|
|
|
|
- element!.classList.toggle('icon-active');
|
|
|
|
|
|
+ if (className === 'all') {
|
|
|
|
+ if (this.filterAll) {
|
|
|
|
+ this.setAllClassesInactive();
|
|
|
|
+ this.restorePreviousClasses();
|
|
|
|
+ this.refreshFilteredSpells();
|
|
|
|
+ } else {
|
|
|
|
+ this.previousClasses = this.getActiveClasses();
|
|
|
|
+ this.setAllClassesActive();
|
|
|
|
+ this.refreshFilteredSpells();
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
this.toggleClassFilter(className);
|
|
this.toggleClassFilter(className);
|
|
|
|
+ // Hier kann man noch darauf warten, ob vielleicht mehrere Klassen kurz nacheinander ausgewählt werden
|
|
this.refreshFilteredSpells();
|
|
this.refreshFilteredSpells();
|
|
}
|
|
}
|
|
|
|
|
|
- private refreshFilteredSpells() {
|
|
|
|
- console.log('Refresh filtered spells');
|
|
|
|
- console.log('Artificer: ' + this.filterArtificer);
|
|
|
|
-
|
|
|
|
- // console.log('Bard: ' + this.filterBard);
|
|
|
|
- console.log('Cleric: ' + this.filterCleric);
|
|
|
|
- // console.log('Druid: ' + this.filterDruid);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Retrieves the filtered spells from the SpellsService.
|
|
|
|
+ */
|
|
|
|
+ public refreshFilteredSpells(isDelayed: boolean = false) {
|
|
|
|
+ if (isDelayed) {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.filteredSpells = this.spellsService.getSpellsByClasslistAndLevel(
|
|
|
|
+ this.getActiveClasses(),
|
|
|
|
+ this.currentLevel,
|
|
|
|
+ );
|
|
|
|
+ }, 150);
|
|
|
|
+ } else {
|
|
|
|
+ this.filteredSpells = this.spellsService.getSpellsByClasslistAndLevel(
|
|
|
|
+ this.getActiveClasses(),
|
|
|
|
+ this.currentLevel,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- // Utils
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Toggles if a given class is used to filter the spells.
|
|
* Toggles if a given class is used to filter the spells.
|
|
* @param className The class which icon will be toggled.
|
|
* @param className The class which icon will be toggled.
|
|
*/
|
|
*/
|
|
private toggleClassFilter(className: string) {
|
|
private toggleClassFilter(className: string) {
|
|
- const isActive: boolean = this.getClassFilter(className);
|
|
|
|
|
|
+ console.log('Toggle class filter: ' + className);
|
|
|
|
+
|
|
|
|
+ this.filterAll = false;
|
|
|
|
+ document.getElementById('all')!.classList.remove('icon-active');
|
|
|
|
+ const isActive: boolean = this.getClassVariabel(className);
|
|
this.setClassFilter(className, !isActive);
|
|
this.setClassFilter(className, !isActive);
|
|
|
|
+ if (isActive) {
|
|
|
|
+ document.getElementById(className)!.classList.remove('icon-active');
|
|
|
|
+ } else {
|
|
|
|
+ document.getElementById(className)!.classList.add('icon-active');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets a value to the corresponding variable to a classname.
|
|
|
|
+ * Active classes will be used to filter the spells.
|
|
|
|
+ * @param className The class which variable is looked for.
|
|
|
|
+ * @param value The value to be set.
|
|
|
|
+ */
|
|
|
|
+ private setClassFilter(className: string, value: boolean) {
|
|
|
|
+ switch (className) {
|
|
|
|
+ case 'all':
|
|
|
|
+ this.filterAll = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'artificer':
|
|
|
|
+ this.filterArtificer = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'bard':
|
|
|
|
+ this.filterBard = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'cleric':
|
|
|
|
+ this.filterCleric = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'druid':
|
|
|
|
+ this.filterDruid = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'paladin':
|
|
|
|
+ this.filterPaladin = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'ranger':
|
|
|
|
+ this.filterRanger = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'sorcerer':
|
|
|
|
+ this.filterSorcerer = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'warlock':
|
|
|
|
+ this.filterWarlock = value;
|
|
|
|
+ break;
|
|
|
|
+ case 'wizard':
|
|
|
|
+ this.filterWizard = value;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -67,8 +148,10 @@ export class JournalSpellbookComponent {
|
|
* @param className The class which varibale is looked for.
|
|
* @param className The class which varibale is looked for.
|
|
* @returns Returns the given class filter variable.
|
|
* @returns Returns the given class filter variable.
|
|
*/
|
|
*/
|
|
- private getClassFilter(className: string): boolean {
|
|
|
|
|
|
+ private getClassVariabel(className: string): boolean {
|
|
switch (className) {
|
|
switch (className) {
|
|
|
|
+ case 'all':
|
|
|
|
+ return this.filterAll;
|
|
case 'artificer':
|
|
case 'artificer':
|
|
return this.filterArtificer;
|
|
return this.filterArtificer;
|
|
case 'bard':
|
|
case 'bard':
|
|
@@ -93,40 +176,340 @@ export class JournalSpellbookComponent {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets a value to the corresponding variable to a classname.
|
|
|
|
- * Active classes will be used to filter the spells.
|
|
|
|
- * @param className The class which variable is looked for.
|
|
|
|
- * @param value The value to be set.
|
|
|
|
|
|
+ * Returns all active classes.
|
|
|
|
+ * @returns Returns all active classes.
|
|
*/
|
|
*/
|
|
- private setClassFilter(className: string, value: boolean) {
|
|
|
|
- switch (className) {
|
|
|
|
- case 'artificer':
|
|
|
|
- this.filterArtificer = value;
|
|
|
|
|
|
+ private getActiveClasses(): string[] {
|
|
|
|
+ const activeClasses: string[] = [];
|
|
|
|
+ if (this.filterArtificer) {
|
|
|
|
+ activeClasses.push('artificer');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterBard) {
|
|
|
|
+ activeClasses.push('bard');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterCleric) {
|
|
|
|
+ activeClasses.push('cleric');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterDruid) {
|
|
|
|
+ activeClasses.push('druid');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterPaladin) {
|
|
|
|
+ activeClasses.push('paladin');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterRanger) {
|
|
|
|
+ activeClasses.push('ranger');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterSorcerer) {
|
|
|
|
+ activeClasses.push('sorcerer');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterWarlock) {
|
|
|
|
+ activeClasses.push('warlock');
|
|
|
|
+ }
|
|
|
|
+ if (this.filterWizard) {
|
|
|
|
+ activeClasses.push('wizard');
|
|
|
|
+ }
|
|
|
|
+ return activeClasses;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets all class filters to true and activates all class icons.
|
|
|
|
+ * This is used when the all classes button is selected
|
|
|
|
+ */
|
|
|
|
+ private setAllClassesActive(): void {
|
|
|
|
+ this.filterAll = true;
|
|
|
|
+ this.filterArtificer = true;
|
|
|
|
+ this.filterBard = true;
|
|
|
|
+ this.filterCleric = true;
|
|
|
|
+ this.filterDruid = true;
|
|
|
|
+ this.filterPaladin = true;
|
|
|
|
+ this.filterRanger = true;
|
|
|
|
+ this.filterSorcerer = true;
|
|
|
|
+ this.filterWarlock = true;
|
|
|
|
+ this.filterWizard = true;
|
|
|
|
+ document.getElementById('all')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('artificer')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('bard')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('cleric')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('druid')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('paladin')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('ranger')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('sorcerer')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('warlock')!.classList.add('icon-active');
|
|
|
|
+ document.getElementById('wizard')!.classList.add('icon-active');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets all class filters to false and unselects all class buttons.
|
|
|
|
+ * This is used when the all classes button is deselected.
|
|
|
|
+ */
|
|
|
|
+ private setAllClassesInactive(): void {
|
|
|
|
+ this.filterAll = false;
|
|
|
|
+ this.filterArtificer = false;
|
|
|
|
+ this.filterBard = false;
|
|
|
|
+ this.filterCleric = false;
|
|
|
|
+ this.filterDruid = false;
|
|
|
|
+ this.filterPaladin = false;
|
|
|
|
+ this.filterRanger = false;
|
|
|
|
+ this.filterSorcerer = false;
|
|
|
|
+ this.filterWarlock = false;
|
|
|
|
+ this.filterWizard = false;
|
|
|
|
+ document.getElementById('all')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('artificer')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('bard')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('cleric')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('druid')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('paladin')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('ranger')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('sorcerer')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('warlock')!.classList.remove('icon-active');
|
|
|
|
+ document.getElementById('wizard')!.classList.remove('icon-active');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Activates all classes that were active before the all classes button was selected.
|
|
|
|
+ */
|
|
|
|
+ private restorePreviousClasses(): void {
|
|
|
|
+ this.previousClasses.forEach((className) => {
|
|
|
|
+ const element = document.getElementById(className);
|
|
|
|
+ element!.classList.toggle('icon-active');
|
|
|
|
+ this.toggleClassFilter(className);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // CUSTOM SPELLS
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * In this modal new spells can be created. This can be completely new spells or
|
|
|
|
+ * modified official spells. If successful, the spell is added to the spell list,
|
|
|
|
+ * sent to the daService and sent to the spellsService which in return sends it to the dataBase
|
|
|
|
+ * @param copyOfficalSpell
|
|
|
|
+ * @param spell
|
|
|
|
+ */
|
|
|
|
+ public openSpellCreationModal(
|
|
|
|
+ copyOfficalSpell: boolean,
|
|
|
|
+ spell?: Spell,
|
|
|
|
+ ): void {
|
|
|
|
+ this.modalAccessor.openModal(SpellModalComponent, {
|
|
|
|
+ spell: copyOfficalSpell ? spell : undefined,
|
|
|
|
+ level: this.currentLevel,
|
|
|
|
+ id: this.dataAccessor.customSpellId,
|
|
|
|
+ copyOfficalSpell: copyOfficalSpell,
|
|
|
|
+ classes: [this.dataAccessor.characterData.class],
|
|
|
|
+ });
|
|
|
|
+ const resultSubscription = this.modalAccessor.result$.subscribe(
|
|
|
|
+ (result) => {
|
|
|
|
+ if (result.state === 'add') {
|
|
|
|
+ console.log('Add spell, caught in spellbook component');
|
|
|
|
+ this.dataAccessor.addCustomSpell(result.data);
|
|
|
|
+ this.refreshFilteredSpells();
|
|
|
|
+ }
|
|
|
|
+ resultSubscription.unsubscribe();
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Opens the modal to manage custom spells. Here, custom spells can be deleted.
|
|
|
|
+ */
|
|
|
|
+ public openManageCustomSpellsModal(): void {
|
|
|
|
+ this.modalAccessor.openModal(CustomSpellsModalComponent, {
|
|
|
|
+ spells: this.dataAccessor.customSpells,
|
|
|
|
+ });
|
|
|
|
+ const resultSubscription = this.modalAccessor.result$.subscribe(
|
|
|
|
+ (result) => {
|
|
|
|
+ if (result.state === 'delete') {
|
|
|
|
+ result.data.forEach((spell: Spell) => {
|
|
|
|
+ // TODO: Implement deletion of custom spells
|
|
|
|
+ // this.deleteCustomSpell(spell);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ resultSubscription.unsubscribe();
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // SPELLCARDS
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Opens the full spellcard modal for a given spell. The spellcard can be used to add the spell to the prepared spells and/or to the favorites.
|
|
|
|
+ * @param spell The spell for which the full spellcard should be opened.
|
|
|
|
+ */
|
|
|
|
+ public showFullSpellcard(spell: Spell): void {
|
|
|
|
+ const favorites = this.dataAccessor.favoriteSpells;
|
|
|
|
+ const alreadyInFavorites = favorites.some(
|
|
|
|
+ (currentSpell) => currentSpell.id === spell.id,
|
|
|
|
+ );
|
|
|
|
+ const alreadyPrepared = this.dataAccessor
|
|
|
|
+ .getAllPreparedSpells()
|
|
|
|
+ .some((currentSpell) => currentSpell.id === spell.id);
|
|
|
|
+ this.modalAccessor.openModal(FullSpellcardComponent, {
|
|
|
|
+ spell: spell,
|
|
|
|
+ origin: 'spellbook',
|
|
|
|
+ alreadyPrepared: alreadyPrepared,
|
|
|
|
+ alreadyInFavorites: alreadyInFavorites,
|
|
|
|
+ });
|
|
|
|
+ const actionSubscription = this.modalAccessor.action$.subscribe(
|
|
|
|
+ (message) => {
|
|
|
|
+ if (message.action === 'addToFavorites') {
|
|
|
|
+ this.dataAccessor.addFavoriteSpell(spell);
|
|
|
|
+ } else if (message.action === 'removeFromFavorites') {
|
|
|
|
+ this.dataAccessor.removeFavoriteSpell(spell);
|
|
|
|
+ } else if (message.action === 'addToPrepared') {
|
|
|
|
+ this.addSpellToPrepared(spell);
|
|
|
|
+ } else if (message.action === 'removeFromPrepared') {
|
|
|
|
+ this.removeSpellFromPrepared(spell);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ const resultSubscription = this.modalAccessor.result$.subscribe(
|
|
|
|
+ (result) => {
|
|
|
|
+ resultSubscription.unsubscribe();
|
|
|
|
+ actionSubscription.unsubscribe();
|
|
|
|
+
|
|
|
|
+ if (result.state === 'copy') {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.openSpellCreationModal(true, spell);
|
|
|
|
+ }, 100);
|
|
|
|
+ } else if (result.state === 'update') {
|
|
|
|
+ console.log('Update spell, caught in spellbook component');
|
|
|
|
+ // TODO: Implement Modification of spells
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.openSpellModificationModal(spell);
|
|
|
|
+ }, 100);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Opens a modal to modify an existing spell. The spell is then updated in the dataAccessor and favorites.
|
|
|
|
+ * @param spell The Spell that is to be modified.
|
|
|
|
+ */
|
|
|
|
+ public openSpellModificationModal(spell: Spell): void {
|
|
|
|
+ this.modalAccessor.openModal(SpellModalComponent, {
|
|
|
|
+ spell: spell,
|
|
|
|
+ isModification: true,
|
|
|
|
+ });
|
|
|
|
+ const resultSubscription = this.modalAccessor.result$.subscribe(
|
|
|
|
+ (result) => {
|
|
|
|
+ if (result.state === 'update') {
|
|
|
|
+ this.dataAccessor.updateCustomSpell(result.data);
|
|
|
|
+ }
|
|
|
|
+ resultSubscription.unsubscribe();
|
|
|
|
+ this.refreshFilteredSpells();
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Adds a given spell to the list of prepared spells. The spell will be added to the corresponding spellArray.
|
|
|
|
+ * Moreover it will also be added to the database in the dataAccessor.
|
|
|
|
+ * @param spell The spell that will be added to its corresponding spellArray.
|
|
|
|
+ */
|
|
|
|
+ private addSpellToPrepared(spell: Spell): void {
|
|
|
|
+ switch (spell.level) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.dataAccessor.addSpellToLevel0(spell);
|
|
break;
|
|
break;
|
|
- case 'bard':
|
|
|
|
- this.filterBard = value;
|
|
|
|
|
|
+ case 1:
|
|
|
|
+ this.dataAccessor.addSpellToLevel1(spell);
|
|
break;
|
|
break;
|
|
- case 'cleric':
|
|
|
|
- this.filterCleric = value;
|
|
|
|
|
|
+ case 2:
|
|
|
|
+ this.dataAccessor.addSpellToLevel2(spell);
|
|
break;
|
|
break;
|
|
- case 'druid':
|
|
|
|
- this.filterDruid = value;
|
|
|
|
|
|
+ case 3:
|
|
|
|
+ this.dataAccessor.addSpellToLevel3(spell);
|
|
break;
|
|
break;
|
|
- case 'paladin':
|
|
|
|
- this.filterPaladin = value;
|
|
|
|
|
|
+ case 4:
|
|
|
|
+ this.dataAccessor.addSpellToLevel4(spell);
|
|
break;
|
|
break;
|
|
- case 'ranger':
|
|
|
|
- this.filterRanger = value;
|
|
|
|
|
|
+ case 5:
|
|
|
|
+ this.dataAccessor.addSpellToLevel5(spell);
|
|
break;
|
|
break;
|
|
- case 'sorcerer':
|
|
|
|
- this.filterSorcerer = value;
|
|
|
|
|
|
+ case 6:
|
|
|
|
+ this.dataAccessor.addSpellToLevel6(spell);
|
|
break;
|
|
break;
|
|
- case 'warlock':
|
|
|
|
- this.filterWarlock = value;
|
|
|
|
|
|
+ case 7:
|
|
|
|
+ this.dataAccessor.addSpellToLevel7(spell);
|
|
break;
|
|
break;
|
|
- case 'wizard':
|
|
|
|
- this.filterWizard = value;
|
|
|
|
|
|
+ case 8:
|
|
|
|
+ this.dataAccessor.addSpellToLevel8(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 9:
|
|
|
|
+ this.dataAccessor.addSpellToLevel9(spell);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Removes a given spell from the list of prepared spells. The spell will be removed from the corresponding spellArray.
|
|
|
|
+ * Moreover it will also be removed from the database in the dataAccessor.
|
|
|
|
+ * @param spell The spell that will be removed from its corresponding spellArray.
|
|
|
|
+ */
|
|
|
|
+ private removeSpellFromPrepared(spell: Spell): void {
|
|
|
|
+ switch (spell.level) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel0(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel1(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel2(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel3(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel4(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 5:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel5(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 6:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel6(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 7:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel7(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 8:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel8(spell);
|
|
|
|
+ break;
|
|
|
|
+ case 9:
|
|
|
|
+ this.dataAccessor.removeSpellFromLevel9(spell);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns a list of prepared spells for a given level.
|
|
|
|
+ * @param level The level of the list of prepared spells.
|
|
|
|
+ * @returns Returns the complete list of prepared spells for the given level.
|
|
|
|
+ */
|
|
|
|
+ private getPreparedSpellList(level: number): Spell[] {
|
|
|
|
+ switch (level) {
|
|
|
|
+ case 0:
|
|
|
|
+ return this.dataAccessor.spellLevel0;
|
|
|
|
+ case 1:
|
|
|
|
+ return this.dataAccessor.spellLevel1;
|
|
|
|
+ case 2:
|
|
|
|
+ return this.dataAccessor.spellLevel2;
|
|
|
|
+ case 3:
|
|
|
|
+ return this.dataAccessor.spellLevel3;
|
|
|
|
+ case 4:
|
|
|
|
+ return this.dataAccessor.spellLevel4;
|
|
|
|
+ case 5:
|
|
|
|
+ return this.dataAccessor.spellLevel5;
|
|
|
|
+ case 6:
|
|
|
|
+ return this.dataAccessor.spellLevel6;
|
|
|
|
+ case 7:
|
|
|
|
+ return this.dataAccessor.spellLevel7;
|
|
|
|
+ case 8:
|
|
|
|
+ return this.dataAccessor.spellLevel8;
|
|
|
|
+ case 9:
|
|
|
|
+ return this.dataAccessor.spellLevel9;
|
|
|
|
+ default:
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|