From 3bbc650af7a22d7e417e00b2a5409051fe7580cd Mon Sep 17 00:00:00 2001 From: xangelo Date: Tue, 6 Jun 2023 09:58:45 -0400 Subject: [PATCH] move flee to correct spot The flee implementation was happening too early in the fight process so it wasn't able to take into account player/equipment stats or monster stats. --- src/server/api.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/server/api.ts b/src/server/api.ts index 5f9693e..482a817 100644 --- a/src/server/api.ts +++ b/src/server/api.ts @@ -290,14 +290,6 @@ io.on('connection', async socket => { levelIncrease: false } }; - if(data.action === 'flee') { - roundData.roundDetails.push(`You managed to escape from the ${monster.name}!`) - roundData.winner = 'monster'; - await clearFight(player.id); - - socket.emit('fight-over', {roundData, monsters: []}); - return; - } const equippedItems = await getEquippedItems(player.id); // we only use this if the player successfully defeated the monster @@ -346,6 +338,18 @@ io.on('connection', async socket => { boost.damage += item.boost_damage; }); + // if you flee'd, then we want to check your dex vs. the monsters + // but we want to give you the item/weapon boosts you need + // if not then you're going to get hit. + if(data.action === 'flee') { + roundData.roundDetails.push(`You managed to escape from the ${monster.name}!`) + roundData.winner = 'monster'; + await clearFight(player.id); + + socket.emit('fight-over', {roundData, monsters: []}); + return; + } + const primaryStat = data.action === 'attack' ? player.strength : player.constitution; const boostStat = data.action === 'attack' ? boost.strength : boost.constitution; const attackType = data.action === 'attack' ? 'physical' : 'magical'; -- 2.25.1