|
@@ -5,6 +5,7 @@ import { Spell } from 'src/interfaces/spell';
|
|
|
import { Damage } from 'src/interfaces/damage';
|
|
|
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
|
|
import { NgxSmartModalService, NgxSmartModalComponent } from 'ngx-smart-modal';
|
|
|
+import { WeaponTableComponent } from './weapon-table/weapon-table.component';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-weapons-container',
|
|
@@ -17,6 +18,9 @@ export class WeaponsContainerComponent {
|
|
|
public ngxSmartModalService: NgxSmartModalService
|
|
|
) {}
|
|
|
|
|
|
+ @ViewChild(WeaponTableComponent) weaponTable!: WeaponTableComponent;
|
|
|
+ // @ViewChild(SpellTableComponent) spellTable!: SpellTableComponent;
|
|
|
+
|
|
|
public active: number = 1;
|
|
|
|
|
|
public newWeaponName: string = '';
|
|
@@ -24,7 +28,9 @@ export class WeaponsContainerComponent {
|
|
|
public newWeaponRange: string = '';
|
|
|
public newWeaponAttackBonus: string = '';
|
|
|
|
|
|
- public newWeaponDamage: Damage[] = [{ damage: '', damageType: '' }];
|
|
|
+ public newWeaponDamage: Damage[] = [
|
|
|
+ { diceNumber: '', diceType: '', damageType: '' },
|
|
|
+ ];
|
|
|
|
|
|
public newWeaponProficient: boolean = false;
|
|
|
public newWeaponAttribute: string = '';
|
|
@@ -32,46 +38,25 @@ export class WeaponsContainerComponent {
|
|
|
public newWeaponIsTwoHanded: boolean = false;
|
|
|
public newWeaponIsFinesse: boolean = false;
|
|
|
public newWeaponIsRanged: boolean = false;
|
|
|
- public newWeaponVersatileDamage: Damage[] = [{ damage: '', damageType: '' }];
|
|
|
-
|
|
|
- // public weaponAttributes: string[] = [
|
|
|
- // 'Strength',
|
|
|
- // 'Dexterity',
|
|
|
- // 'Constitution',
|
|
|
- // 'Intelligence',
|
|
|
- // 'Wisdom',
|
|
|
- // 'Charisma',
|
|
|
- // ];
|
|
|
-
|
|
|
- public damageTypes: string[] = [
|
|
|
- 'Wucht',
|
|
|
- 'Stich',
|
|
|
- 'Hieb',
|
|
|
- 'Feuer',
|
|
|
- 'Kälte',
|
|
|
- 'Blitz',
|
|
|
- 'Gift',
|
|
|
- 'Säure',
|
|
|
- 'Nekrotisch',
|
|
|
- 'Psychisch',
|
|
|
- 'Heilig',
|
|
|
- 'Göttlich',
|
|
|
- 'Kraft',
|
|
|
+ public newWeaponVersatileDamage: Damage[] = [
|
|
|
+ { diceNumber: '', diceType: '', damageType: '' },
|
|
|
];
|
|
|
|
|
|
- public weapons: Weapon[] = [
|
|
|
- {
|
|
|
- name: 'Dagger',
|
|
|
- damage: [{ damage: '1d4', damageType: 'Stich' }],
|
|
|
- attackBonus: '+5',
|
|
|
- range: '20/60',
|
|
|
- isFinesse: true,
|
|
|
- proficient: true,
|
|
|
- isTwoHanded: false,
|
|
|
- isVersatile: false,
|
|
|
- isRanged: false,
|
|
|
- },
|
|
|
- ];
|
|
|
+ // public damageTypes: string[] = [
|
|
|
+ // 'Wucht',
|
|
|
+ // 'Stich',
|
|
|
+ // 'Hieb',
|
|
|
+ // 'Feuer',
|
|
|
+ // 'Kälte',
|
|
|
+ // 'Blitz',
|
|
|
+ // 'Gift',
|
|
|
+ // 'Säure',
|
|
|
+ // 'Nekrotisch',
|
|
|
+ // 'Psychisch',
|
|
|
+ // 'Heilig',
|
|
|
+ // 'Göttlich',
|
|
|
+ // 'Kraft',
|
|
|
+ // ];
|
|
|
|
|
|
public newSpellName: string = '';
|
|
|
public newSpellAttackBonus: string = '';
|
|
@@ -81,81 +66,51 @@ export class WeaponsContainerComponent {
|
|
|
public newSpellProficient: boolean = false;
|
|
|
public newSpellAttribute: string = '';
|
|
|
|
|
|
- public spells: Spell[] = [
|
|
|
- {
|
|
|
- name: 'Fireball',
|
|
|
- damage: '8d6',
|
|
|
- attackBonus: '0',
|
|
|
- range: '150',
|
|
|
- type: 'Fire',
|
|
|
- attribute: 'Dexterity',
|
|
|
- level: 3,
|
|
|
- },
|
|
|
- ];
|
|
|
+ public spells!: Spell[];
|
|
|
|
|
|
public ngOnInit(): void {
|
|
|
- this.weapons = this.dataAccessor.getWeapons();
|
|
|
this.spells = this.dataAccessor.getSpells();
|
|
|
}
|
|
|
|
|
|
- public dropWeapons(event: CdkDragDrop<string[]>): void {
|
|
|
- moveItemInArray(this.weapons, event.previousIndex, event.currentIndex);
|
|
|
- this.updateWeapons();
|
|
|
- }
|
|
|
-
|
|
|
public dropSpells(event: CdkDragDrop<string[]>): void {
|
|
|
moveItemInArray(this.spells, event.previousIndex, event.currentIndex);
|
|
|
this.updateSpells();
|
|
|
}
|
|
|
|
|
|
- public updateWeapons(): void {
|
|
|
- this.dataAccessor.setWeapons(this.weapons);
|
|
|
- }
|
|
|
-
|
|
|
public updateSpells(): void {
|
|
|
this.dataAccessor.setSpells(this.spells);
|
|
|
}
|
|
|
|
|
|
- public openWeaponModal(): void {
|
|
|
- this.ngxSmartModalService.getModal('weaponModal').open();
|
|
|
+ public addSpell(): void {
|
|
|
+ // this.spells.push({
|
|
|
+ // name: this.newSpellName,
|
|
|
+ // damage: this.newSpellDamage,
|
|
|
+ // attackBonus: this.newSpellAttackBonus,
|
|
|
+ // range: this.newSpellRange,
|
|
|
+ // type: this.newSpellType,
|
|
|
+ // level: 0,
|
|
|
+ // attribute: this.newSpellAttribute,
|
|
|
+ // });
|
|
|
+ this.ngxSmartModalService.getModal('spellModal').close();
|
|
|
}
|
|
|
|
|
|
- public addWeapon(): void {
|
|
|
- const newWeapon: Weapon = {
|
|
|
- name: this.newWeaponName,
|
|
|
- damage: this.newWeaponDamage,
|
|
|
- attackBonus: this.newWeaponAttackBonus,
|
|
|
- range: this.newWeaponRange,
|
|
|
- proficient: this.newWeaponProficient,
|
|
|
- isTwoHanded: this.newWeaponIsTwoHanded,
|
|
|
- isVersatile: this.newWeaponIsVersatile,
|
|
|
- isFinesse: this.newWeaponIsFinesse,
|
|
|
- isRanged: this.newWeaponIsRanged,
|
|
|
- versatileDamage: this.newWeaponIsVersatile
|
|
|
- ? this.newWeaponVersatileDamage
|
|
|
- : undefined,
|
|
|
- };
|
|
|
-
|
|
|
- console.log('test if versatileDamage is present?', newWeapon);
|
|
|
-
|
|
|
- this.weapons.push(newWeapon);
|
|
|
- this.ngxSmartModalService.getModal('weaponModal').close();
|
|
|
- }
|
|
|
+ // spells
|
|
|
|
|
|
public openSpellModal(): void {
|
|
|
this.ngxSmartModalService.getModal('spellModal').open();
|
|
|
}
|
|
|
|
|
|
- public addSpell(): void {
|
|
|
- this.spells.push({
|
|
|
- name: this.newSpellName,
|
|
|
- damage: this.newSpellDamage,
|
|
|
- attackBonus: this.newSpellAttackBonus,
|
|
|
- range: this.newSpellRange,
|
|
|
- type: this.newSpellType,
|
|
|
- level: 0,
|
|
|
- attribute: this.newSpellAttribute,
|
|
|
- });
|
|
|
- this.ngxSmartModalService.getModal('spellModal').close();
|
|
|
+ // public addNewlyCreatedSpell(spell: Spell): void {
|
|
|
+ // this.spellTable.addWeapon(spell);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // weapons
|
|
|
+ public openWeaponModal(): void {
|
|
|
+ console.log('openWeaponModal()');
|
|
|
+ this.ngxSmartModalService.getModal('weaponModal').open();
|
|
|
+ }
|
|
|
+
|
|
|
+ public addNewlyCreatedWeapon(weapon: Weapon): void {
|
|
|
+ this.weaponTable.addWeapon(weapon);
|
|
|
}
|
|
|
}
|