Short Sword,WEAPON,ANY_HAND,Wanderer,"bladed,one_handed_mastery",5,1,0,0,0,0,0,0,0,0,3,50
Morningstar,WEAPON,TWO_HANDED,Wanderer,"blunt,two_handed_mastery",15,1,5,0,0,0,0,0,0,0,7,70
Firebolt,SPELL,ANY_HAND,Wanderer,destruction_magic,10,1,0,0,0,0,0,0,0,0,5,0
-Icebolt,SPELL,ANY_HAND,Wanderer,destruction_magic,10,1,0,0,0,0,0,0,0,0,5,0
\ No newline at end of file
+Icebolt,SPELL,ANY_HAND,Wanderer,destruction_magic,10,1,0,0,0,0,0,0,0,0,5,0
+Restore Health,SPELL,ANY_HAND,Wanderer,restoration_magic,10,1,0,0,0,0,0,0,0,0,5,0
\ No newline at end of file
dexterity: 0,
intelligence: 0,
damage: 0,
+ hp: 0,
};
const equipment: Map<EquipmentSlot, EquippedItemDetails> = new Map<EquipmentSlot, EquippedItemDetails>();
const weapons: EquippedItemDetails[] = [];
+ let anyDamageSpells: boolean = false;
equippedItems.forEach(item => {
if(item.type === 'ARMOUR') {
equipment.set(item.equipment_slot, item);
weapons.push(item);
}
else if(item.type === 'SPELL') {
+ if(item.affectedSkills.includes('destruction_magic')) {
+ anyDamageSpells = true;
+ }
weapons.push(item);
}
boost.constitution += item.boosts.constitution;
boost.dexterity += item.boosts.dexterity;
boost.intelligence += item.boosts.intelligence;
- boost.damage += item.boosts.damage;
+
+ if(item.type === 'SPELL' && item.affectedSkills.includes('restoration_magic')) {
+ boost.hp += item.boosts.damage;
+ }
+ else {
+ boost.damage += item.boosts.damage;
+ }
});
// if you flee'd, then we want to check your dex vs. the monsters
const playerDamage = Math.floor(((primaryStat + boostStat) * 1.3) + boost.damage);
const skillsUsed: Record<SkillID | any, number> = {};
+ let hpHealAfterMasteries: number = -1;
let playerDamageAfterMasteries: number = 0;
// apply masteries!
weapons.forEach(item => {
item.affectedSkills.forEach(id => {
- playerDamageAfterMasteries += playerDamage * Skills.get(id).effect(playerSkills.get(id));
+ if(id === 'restoration_magic') {
+ if(hpHealAfterMasteries < 0) {
+ hpHealAfterMasteries = 0;
+ }
+ hpHealAfterMasteries += Skills.get(id).effect(playerSkills.get(id));
+ }
+ else {
+ playerDamageAfterMasteries += playerDamage * Skills.get(id).effect(playerSkills.get(id));
+ }
+
if(!skillsUsed[id]) {
skillsUsed[id] = 0;
}
await updatePlayerSkills(player.id, skillsUsed);
- const playerFinalDamage = Math.floor(playerDamage + playerDamageAfterMasteries);
+ const playerFinalDamage = (attackType === 'magical' && !anyDamageSpells) ? 0 : Math.floor(playerDamage + playerDamageAfterMasteries);
+ const playerFinalHeal = Math.floor(boost.hp + hpHealAfterMasteries);
roundData.roundDetails.push(`You targeted the monsters ${data.target.toUpperCase()} with ${attackType} damage!`);
if(data.target === 'arms') {
player.hp -= monster.strength;
}
+ if(playerFinalHeal > 0) {
+ player.hp += playerFinalHeal;
+ if(player.hp > maxHp(player.constitution, player.level)) {
+ player.hp = maxHp(player.constitution, player.level);
+ }
+ roundData.roundDetails.push(`You healed for ${playerFinalHeal} HP`);
+ }
+
// update the players inventory for this item!
if(player.hp <= 0) {