fix: count current dungeon run
authorxangelo <me@xangelo.ca>
Fri, 29 Sep 2023 18:32:18 +0000 (14:32 -0400)
committerxangelo <me@xangelo.ca>
Fri, 29 Sep 2023 18:32:18 +0000 (14:32 -0400)
Dungeon completion was triggered after the count of number of runs
instead of before allowing users to get 1 extra run in.

src/server/locations/dungeon.ts

index 26f74605c064696664983bde8f34e6ee1f525b40..2b450968049eabe314f3b822c00e65517499fd50 100644 (file)
@@ -161,6 +161,7 @@ router.post('/city/dungeon/:dungeon_id/complete', authEndpoint, async (req, res)
     });
   }
 
+  await completeDungeon(req.player.id);
 
   // if this is not the first completion, lets give them diminishing returns
   const completionsToday = await getEventHistoryToday(req.player.id, 'DUNGEON_COMPLETE');
@@ -179,7 +180,6 @@ router.post('/city/dungeon/:dungeon_id/complete', authEndpoint, async (req, res)
   }
 
   // delete the tracking for this dungeon-run
-  await completeDungeon(req.player.id);
   await updatePlayer(req.player);
 
   res.send(dungeonRewards(dungeon, rewards, completionsToday.length));