From: xangelo Date: Thu, 5 Dec 2024 15:02:08 +0000 (-0500) Subject: fix(fight): equipment exp gains were causing errors if nothing was equipped X-Git-Tag: v0.4.4~14 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=9d106886113169e54544cf0abab6a06c18d35409;p=risinglegends.git fix(fight): equipment exp gains were causing errors if nothing was equipped --- diff --git a/src/server/fight.ts b/src/server/fight.ts index e27a87d..af8c644 100644 --- a/src/server/fight.ts +++ b/src/server/fight.ts @@ -173,16 +173,18 @@ export async function fightRound( } }); - const equipmentExpGains = ( - await increaseExp(player.id, increaseExpToEquipment) - ).filter((obj) => { - return levelFromExp(obj.previous_exp) < levelFromExp(obj.new_exp); - }); - // check if any of the equipment levelled up - if (equipmentExpGains.length) { - // increment random stats - await increaseEquipmentLevel(player.id, equipmentExpGains); - } + if(Object.keys(increaseExpToEquipment).length) { + const equipmentExpGains = ( + await increaseExp(player.id, increaseExpToEquipment) + ).filter((obj) => { + return levelFromExp(obj.previous_exp) < levelFromExp(obj.new_exp); + }); + // check if any of the equipment levelled up + if (equipmentExpGains.length) { + // increment random stats + await increaseEquipmentLevel(player.id, equipmentExpGains); + } +} // @TODO implement flee based on dex + vigor if (data.action === "flee") {