+ // since the player won, we can give them an item if they've earned it
+ if(monster && monster.lootTable.length > 0) {
+ const item = weighted(monster.lootTable, (i) => i.dropRate.toNumber());
+
+ if(item) {
+ // we can give the player this item, so lets place it in the "world-drop-table".
+ // if a player doesn't pick it up, it will remain in the world drop table for
+ // 24 hours.. after that it's gone forever.
+ // if the player does pick it up then it's moved to their inventory
+ const worldDrop = await prisma.worldDrop.create({
+ data: {
+ itemId: item.itemId,
+ droppedById: player.id
+ }
+ });
+
+ output.reward['worldDrop'] = {
+ id: worldDrop.id,
+ name: item.item.name
+ };
+ }
+ }
+