Viewing old revision of Module:Game
You are viewing an old revision of this page from 2/26/2026, 3:46:07 PM.
View latest versionconst VENDOR_SELL_MODIFIER = 0.38;
const Utils = require("Utils");
function getSellPrice(buyPrice) {
return buyPrice ? Math.floor(Math.max(buyPrice * VENDOR_SELL_MODIFIER, 1)) : "N/A";
}
async function calculateCreepDrops(creep, itemGuid, options = {}) {
if (
!creep ||
!itemGuid ||
!creep.loot ||
!Array.isArray(creep.loot.items)
) {
return null;
}
const lootEntry = creep.loot.items.find(
entry => entry?.guid === itemGuid
);
if (!lootEntry) return null;
// 🔎 Resolve item across all categories
const item = await Utils.resolveItemByGuid(itemGuid, options);
if (!item) return null;
// Only allow Trade items for Trade Item page logic
if (item.category !== "Trade") return null;
const dropChance = Number(lootEntry.dropChance) || 0;
const quantity = Number(lootEntry.dropQuantity) || 1;
return {
creepId: creep.id ?? null,
creepName: creep.name ?? null,
itemGuid,
itemName: item.name ?? lootEntry.name ?? null,
dropChance,
quantity,
effectiveDrop: dropChance * quantity
};
}
exports = {
getSellPrice,
calculateCreepDrops
}