|
@@ -13,24 +13,30 @@ export class WeaponModalComponent {
|
|
|
|
|
|
@Output() public weaponCreated: EventEmitter<Weapon> =
|
|
@Output() public weaponCreated: EventEmitter<Weapon> =
|
|
new EventEmitter<Weapon>();
|
|
new EventEmitter<Weapon>();
|
|
- public active: number = 1;
|
|
|
|
|
|
+
|
|
|
|
+ @Output() public weaponUpdated: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
+
|
|
|
|
+ @Output() public weaponDelete: EventEmitter<number> =
|
|
|
|
+ new EventEmitter<number>();
|
|
|
|
|
|
public newWeaponName: string = '';
|
|
public newWeaponName: string = '';
|
|
public newWeaponRange: string = '5 ft.';
|
|
public newWeaponRange: string = '5 ft.';
|
|
- public newWeaponAttackBonus: string = '';
|
|
|
|
|
|
+ public newWeaponAttackBonus: string = '+0';
|
|
public newWeaponDamage: Damage[] = [
|
|
public newWeaponDamage: Damage[] = [
|
|
{ diceNumber: '', diceType: '', damageType: '' },
|
|
{ diceNumber: '', diceType: '', damageType: '' },
|
|
];
|
|
];
|
|
public newWeaponProficient: boolean = false;
|
|
public newWeaponProficient: boolean = false;
|
|
- public newWeaponAttribute: string = '';
|
|
|
|
public newWeaponIsVersatile: boolean = false;
|
|
public newWeaponIsVersatile: boolean = false;
|
|
public newWeaponIsTwoHanded: boolean = false;
|
|
public newWeaponIsTwoHanded: boolean = false;
|
|
public newWeaponIsFinesse: boolean = false;
|
|
public newWeaponIsFinesse: boolean = false;
|
|
public newWeaponIsRanged: boolean = false;
|
|
public newWeaponIsRanged: boolean = false;
|
|
- public newWeaponVersatileDamage: Damage[] = [
|
|
|
|
- { diceNumber: '', diceType: '', damageType: '' },
|
|
|
|
- ];
|
|
|
|
|
|
+ public newWeaponVersatileDamage: string = '';
|
|
public newWeaponWeight: string = 'normal';
|
|
public newWeaponWeight: string = 'normal';
|
|
|
|
+ public newWeaponIsMagical: boolean = false;
|
|
|
|
+ public newWeaponMagicBonus: number = 0;
|
|
|
|
+
|
|
|
|
+ public indexForUpdate: number | undefined;
|
|
|
|
+ public isUpdate: boolean = false;
|
|
|
|
|
|
// Options for the select boxes
|
|
// Options for the select boxes
|
|
public weights: string[] = ['leicht', 'normal', 'schwer'];
|
|
public weights: string[] = ['leicht', 'normal', 'schwer'];
|
|
@@ -65,6 +71,43 @@ export class WeaponModalComponent {
|
|
'9',
|
|
'9',
|
|
'10',
|
|
'10',
|
|
];
|
|
];
|
|
|
|
+
|
|
|
|
+ public attackBonuses: string[] = [
|
|
|
|
+ '-5',
|
|
|
|
+ '-4',
|
|
|
|
+ '-3',
|
|
|
|
+ '-2',
|
|
|
|
+ '-1',
|
|
|
|
+ '+0',
|
|
|
|
+ '+1',
|
|
|
|
+ '+2',
|
|
|
|
+ '+3',
|
|
|
|
+ '+4',
|
|
|
|
+ '+5',
|
|
|
|
+ '+6',
|
|
|
|
+ '+7',
|
|
|
|
+ '+8',
|
|
|
|
+ '+9',
|
|
|
|
+ '+10',
|
|
|
|
+ '+11',
|
|
|
|
+ '+12',
|
|
|
|
+ '+13',
|
|
|
|
+ '+14',
|
|
|
|
+ '+15',
|
|
|
|
+ '+16',
|
|
|
|
+ '+17',
|
|
|
|
+ '+18',
|
|
|
|
+ '+19',
|
|
|
|
+ '+20',
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public magicBonuses: any[] = [
|
|
|
|
+ { display: '+1', value: 1 },
|
|
|
|
+ { display: '+2', value: 2 },
|
|
|
|
+ { display: '+3', value: 3 },
|
|
|
|
+ { display: '+4', value: 4 },
|
|
|
|
+ { display: '+5', value: 5 },
|
|
|
|
+ ];
|
|
//
|
|
//
|
|
|
|
|
|
public createWeapon(): void {
|
|
public createWeapon(): void {
|
|
@@ -80,6 +123,8 @@ export class WeaponModalComponent {
|
|
isRanged: this.newWeaponIsRanged,
|
|
isRanged: this.newWeaponIsRanged,
|
|
versatileDamage: this.newWeaponVersatileDamage,
|
|
versatileDamage: this.newWeaponVersatileDamage,
|
|
weight: this.newWeaponWeight,
|
|
weight: this.newWeaponWeight,
|
|
|
|
+ isMagical: this.newWeaponIsMagical,
|
|
|
|
+ magicBonus: this.newWeaponMagicBonus,
|
|
};
|
|
};
|
|
this.weaponCreated.emit(newWeapon);
|
|
this.weaponCreated.emit(newWeapon);
|
|
this.ngxSmartModalService.closeLatestModal();
|
|
this.ngxSmartModalService.closeLatestModal();
|
|
@@ -87,32 +132,80 @@ export class WeaponModalComponent {
|
|
|
|
|
|
public addDamage(): void {
|
|
public addDamage(): void {
|
|
this.newWeaponDamage.push({ diceNumber: '', diceType: '', damageType: '' });
|
|
this.newWeaponDamage.push({ diceNumber: '', diceType: '', damageType: '' });
|
|
- this.newWeaponVersatileDamage.push({
|
|
|
|
- diceNumber: '',
|
|
|
|
- diceType: '',
|
|
|
|
- damageType: '',
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public removeDamage(index: number): void {
|
|
public removeDamage(index: number): void {
|
|
this.newWeaponDamage.splice(index, 1);
|
|
this.newWeaponDamage.splice(index, 1);
|
|
- this.newWeaponVersatileDamage.splice(index, 1);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public removeData(): void {
|
|
public removeData(): void {
|
|
this.newWeaponName = '';
|
|
this.newWeaponName = '';
|
|
this.newWeaponRange = '5 ft.';
|
|
this.newWeaponRange = '5 ft.';
|
|
- this.newWeaponAttackBonus = '';
|
|
|
|
|
|
+ this.newWeaponAttackBonus = '+0';
|
|
this.newWeaponDamage = [{ diceNumber: '', diceType: '', damageType: '' }];
|
|
this.newWeaponDamage = [{ diceNumber: '', diceType: '', damageType: '' }];
|
|
this.newWeaponProficient = false;
|
|
this.newWeaponProficient = false;
|
|
- this.newWeaponAttribute = '';
|
|
|
|
this.newWeaponIsVersatile = false;
|
|
this.newWeaponIsVersatile = false;
|
|
this.newWeaponIsTwoHanded = false;
|
|
this.newWeaponIsTwoHanded = false;
|
|
this.newWeaponIsFinesse = false;
|
|
this.newWeaponIsFinesse = false;
|
|
this.newWeaponIsRanged = false;
|
|
this.newWeaponIsRanged = false;
|
|
- this.newWeaponVersatileDamage = [
|
|
|
|
- { diceNumber: '', diceType: '', damageType: '' },
|
|
|
|
- ];
|
|
|
|
|
|
+ this.newWeaponVersatileDamage = '';
|
|
this.newWeaponWeight = 'normal';
|
|
this.newWeaponWeight = 'normal';
|
|
|
|
+ this.newWeaponIsMagical = false;
|
|
|
|
+ this.newWeaponMagicBonus = 0;
|
|
|
|
+ this.isUpdate = false;
|
|
|
|
+ this.ngxSmartModalService.resetModalData('weaponModal');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // update
|
|
|
|
+
|
|
|
|
+ public checkIfUpdate(): void {
|
|
|
|
+ console.log('checkIfUpdate()');
|
|
|
|
+ if (this.ngxSmartModalService.getModalData('weaponModal')) {
|
|
|
|
+ this.isUpdate = true;
|
|
|
|
+ const data: any = this.ngxSmartModalService.getModalData('weaponModal');
|
|
|
|
+ const weapon = data.weapon;
|
|
|
|
+ this.newWeaponName = weapon.name;
|
|
|
|
+ this.newWeaponRange = weapon.range;
|
|
|
|
+ this.newWeaponAttackBonus = weapon.attackBonus;
|
|
|
|
+ this.newWeaponDamage = weapon.damage;
|
|
|
|
+ this.newWeaponProficient = weapon.proficient;
|
|
|
|
+ this.newWeaponIsVersatile = weapon.isVersatile;
|
|
|
|
+ this.newWeaponIsTwoHanded = weapon.isTwoHanded;
|
|
|
|
+ this.newWeaponIsFinesse = weapon.isFinesse;
|
|
|
|
+ this.newWeaponIsRanged = weapon.isRanged;
|
|
|
|
+ this.newWeaponVersatileDamage = weapon.versatileDamage;
|
|
|
|
+ this.newWeaponWeight = weapon.weight;
|
|
|
|
+ this.newWeaponIsMagical = weapon.isMagical;
|
|
|
|
+ this.newWeaponMagicBonus = weapon.magicBonus;
|
|
|
|
+
|
|
|
|
+ this.indexForUpdate = data.index;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public updateWeapon(): void {
|
|
|
|
+ const newWeapon: Weapon = {
|
|
|
|
+ name: this.newWeaponName,
|
|
|
|
+ damage: this.newWeaponDamage,
|
|
|
|
+ attackBonus: this.newWeaponAttackBonus,
|
|
|
|
+ range: this.newWeaponRange,
|
|
|
|
+ isFinesse: this.newWeaponIsFinesse,
|
|
|
|
+ proficient: this.newWeaponProficient,
|
|
|
|
+ isTwoHanded: this.newWeaponIsTwoHanded,
|
|
|
|
+ isVersatile: this.newWeaponIsVersatile,
|
|
|
|
+ isRanged: this.newWeaponIsRanged,
|
|
|
|
+ versatileDamage: this.newWeaponVersatileDamage,
|
|
|
|
+ weight: this.newWeaponWeight,
|
|
|
|
+ isMagical: this.newWeaponIsMagical,
|
|
|
|
+ magicBonus: this.newWeaponMagicBonus,
|
|
|
|
+ };
|
|
|
|
+ this.weaponUpdated.emit({ weapon: newWeapon, index: this.indexForUpdate });
|
|
|
|
+ this.ngxSmartModalService.closeLatestModal();
|
|
|
|
+ this.removeData();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public deleteWeapon(): void {
|
|
|
|
+ this.weaponDelete.emit(this.indexForUpdate);
|
|
|
|
+ this.ngxSmartModalService.closeLatestModal();
|
|
|
|
+ this.removeData();
|
|
}
|
|
}
|
|
}
|
|
}
|