const playerFinalHeal = Math.floor(boost.hp + hpHealAfterMasteries);
roundData.roundDetails.push(`You targeted the monsters ${data.target.toUpperCase()} with ${attackType} damage!`);
- if(data.target === 'arms') {
- if(monster.armsAp > 0) {
- monster.armsAp -= playerFinalDamage;
-
- roundData.roundDetails.push(`You dealt ${playerFinalDamage} damage to their armour`);
- if(monster.armsAp < 0) {
-
- roundData.roundDetails.push(`You destroyed the ${monster.name}'s armour!'`);
- roundData.roundDetails.push(`You dealt ${monster.armsAp * -1} damage to their HP`);
- monster.hp += monster.armsAp;
- monster.armsAp = 0;
- }
- }
- else {
- roundData.roundDetails.push(`You hit the ${monster.name} for ${playerFinalDamage} damage.`);
- monster.hp -= playerFinalDamage;
- }
- }
- else if (data.target === 'head') {
- if(monster.helmAp > 0) {
- monster.helmAp -= playerFinalDamage;
-
- roundData.roundDetails.push(`You dealt ${playerFinalDamage} damage to their armour`);
- if(monster.helmAp < 0) {
-
- roundData.roundDetails.push(`You destroyed the ${monster.name}'s armour!'`);
- roundData.roundDetails.push(`You dealt ${monster.armsAp * 1} damage to their HP`);
- monster.hp += monster.helmAp;
- monster.helmAp = 0;
- }
- }
- else {
- roundData.roundDetails.push(`You hit the ${monster.name} for ${playerFinalDamage} damage.`);
- monster.hp -= playerFinalDamage;
- }
+ let armourKey: string;
+ switch(data.target) {
+ case 'arms':
+ armourKey = 'armsAp';
+ break;
+ case 'head':
+ armourKey = 'helmAp';
+ break;
+ case 'legs':
+ armourKey = 'legsAp';
+ break;
+ case 'body':
+ armourKey = 'chestAp';
+ break;
}
- else if(data.target === 'legs') {
- if(monster.legsAp > 0) {
- monster.legsAp -= playerFinalDamage;
- roundData.roundDetails.push(`You dealt ${playerFinalDamage} damage to their armour`);
- if(monster.legsAp < 0) {
+ if(monster[armourKey] && monster[armourKey] > 0) {
+ monster[armourKey] -= playerFinalDamage;
- roundData.roundDetails.push(`You destroyed the ${monster.name}'s armour!'`);
- roundData.roundDetails.push(`You dealt ${monster.legsAp * 1} damage to their HP`);
- monster.hp += monster.legsAp;
- monster.legsAp = 0;
- }
- }
- else {
- roundData.roundDetails.push(`You hit the ${monster.name} for ${playerFinalDamage} damage.`);
- monster.hp -= playerFinalDamage;
+ roundData.roundDetails.push(`You dealt ${playerFinalDamage} damage to their armour`);
+ if(monster[armourKey] < 0) {
+ roundData.roundDetails.push(`You destroyed the ${monster.name}'s armour!'`);
+ roundData.roundDetails.push(`You dealt ${monster[armourKey] * -1} damage to their HP`);
+ monster.hp += monster[armourKey];
+ monster[armourKey] = 0;
}
}
else {
- if(monster.chestAp > 0) {
- monster.chestAp -= playerFinalDamage;
-
- roundData.roundDetails.push(`You dealt ${playerFinalDamage} damage to their armour`);
-
- if(monster.chestAp < 0) {
- roundData.roundDetails.push(`You destroyed the ${monster.name}'s armour!'`);
- roundData.roundDetails.push(`You dealt ${monster.chestAp * 1} damage to their HP`);
- monster.hp += monster.chestAp;
- monster.chestAp = 0;
- }
- }
- else {
- roundData.roundDetails.push(`You hit the ${monster.name} for ${playerFinalDamage} damage.`);
- monster.hp -= playerFinalDamage;
- }
+ roundData.roundDetails.push(`You hit the ${monster.name} for ${playerFinalDamage} damage.`);
+ monster.hp -= playerFinalDamage;
}
if(monster.hp <= 0) {