17,101
edits
m (Fixed shop link) |
(Update for v1.3) |
||
Line 7: | Line 7: | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Common = require('Module:Common') | local Common = require('Module:Common') | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local SkillData = GameData.skillData | local SkillData = GameData.skillData | ||
local Modifiers = require('Module:Modifiers') | |||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
Line 82: | Line 82: | ||
end | end | ||
end) | end) | ||
local lootValue, plusOneMinimumRefinementValue, doubleConsumableRefinementValue = {}, {}, {} | |||
for i, row in ipairs(lootTable) do | for i, row in ipairs(lootTable) do | ||
local thisItem = Items.getItemByID(row.itemID) | local thisItem = Items.getItemByID(row.itemID) | ||
Line 98: | Line 99: | ||
end | end | ||
table.insert(result, Shared.formatnum(row.maxQuantity)) | table.insert(result, Shared.formatnum(row.maxQuantity)) | ||
-- Adding price | |||
local dropChance = row.weight / totalWt | |||
-- Adding price columnsR | |||
if thisItem == nil then | if thisItem == nil then | ||
table.insert(result, '||data-sort-value="0"|???') | table.insert(result, '||data-sort-value="0"|???') | ||
else | else | ||
table.insert(result, '||' .. Items.getValueText(thisItem, row.minQuantity, row.maxQuantity)) | |||
if | |||
-- Add to total loot value | |||
local sellAmount = thisItem.sellsFor or 0 | |||
local sellCurrency = thisItem.sellsForCurrency or 'melvorD:GP' | |||
if sellAmount ~= nil and sellCurrency ~= nil then | |||
if lootValue[sellCurrency] == nil then | |||
lootValue[sellCurrency] = 0 | |||
plusOneMinimumRefinementValue[sellCurrency] = 0 | |||
doubleConsumableRefinementValue[sellCurrency] = 0 | |||
end | |||
local artefactAvgValue = dropChance * sellAmount * ((row.minQuantity + row.maxQuantity) / 2) | |||
lootValue[sellCurrency] = lootValue[sellCurrency] + artefactAvgValue | |||
plusOneMinimumRefinementValue[sellCurrency] = plusOneMinimumRefinementValue[sellCurrency] + artefactAvgValue + (dropChance * sellAmount) | |||
-- Checking if item is a consumable, then adding its value a second time | |||
local doubleExtraVal = (Items._canItemUseSlot(thisItem, 'Consumable') and artefactAvgValue) or 0 | |||
doubleConsumableRefinementValue[sellCurrency] = doubleConsumableRefinementValue[sellCurrency] + artefactAvgValue + doubleExtraVal | |||
end | end | ||
end | end | ||
if dropChance < 100 then | if dropChance < 100 then | ||
--Show fraction as long as it isn't going to be 1/1 | --Show fraction as long as it isn't going to be 1/1 | ||
Line 123: | Line 136: | ||
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f' | local fmt = (dropChance < 0.10 and '%.2g') or '%.2f' | ||
table.insert(result, 'style="text-align:right"|'..string.format(fmt, dropChance * 100)..'%') | table.insert(result, 'style="text-align:right"|'..string.format(fmt, dropChance * 100)..'%') | ||
-- | end | ||
local function lootValueText(lootValue) | |||
local returnPart = {} | |||
for _, currencyDefn in ipairs(GameData.rawData.currencies) do | |||
-- Guarantee order by iterating through currency game data definition | |||
local currID = currencyDefn.id | |||
local val = Shared.round(lootValue[currID], 2, 2) | |||
if val ~= nil then | |||
table.insert(returnPart, Icons._Currency(currID, val)) | |||
end | |||
end | |||
return table.concat(returnPart, ', ') | |||
end | end | ||
table.insert(result, '\r\n|}') | table.insert(result, '\r\n|}') | ||
table.insert(result, '\r\nThe average value of one action is '.. | local lootText = lootValueText(lootValue) | ||
table.insert(result, 'increasing to '.. | local plusOneLootText = lootValueText(plusOneMinimumRefinementValue) | ||
if | local doubleLootText = lootValueText(doubleConsumableRefinementValue) | ||
table.insert(result, '\r\n\r\nThe average value of one action with the x2 Consumables refinement is '.. | table.insert(result, '\r\nThe average value of one action is ' .. lootText .. ', ') | ||
table.insert(result, 'increasing to ' .. plusOneLootText .. ' when the +1 Minimum Items refinement is active.') | |||
if doubleLootText ~= lootText then | |||
table.insert(result, '\r\n\r\nThe average value of one action with the x2 Consumables refinement is ' .. doubleLootText .. '.') | |||
end | end | ||
Line 225: | Line 246: | ||
end | end | ||
if reward.modifiers ~= nil then | if reward.modifiers ~= nil then | ||
table.insert(rewardTable, Modifiers.getModifiersText(reward.modifiers, true)) | |||
end | end | ||
if equipment ~= nil then | if equipment ~= nil then |