Module:Skills/Archaeology: Difference between revisions

Update for v1.3
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 Constants = require('Module:Constants')
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 columns
 
local itemPrice = 0
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
itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
table.insert(result, '||' .. Items.getValueText(thisItem, row.minQuantity, row.maxQuantity))
if itemPrice == 0 or row.maxQuantity == row.minQuantity then
 
table.insert(result, '||'..Icons.GP(itemPrice * row.minQuantity))
-- Add to total loot value
else
local sellAmount = thisItem.sellsFor or 0
table.insert(result, '||'..Icons.GP(itemPrice * row.minQuantity, itemPrice * row.maxQuantity))
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
-- Getting the drop chance
 
local dropChance = (row.weight / totalWt)
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)..'%')
-- Setting average gp values with various parameters
end
local artefactAvgValue = dropChance * thisItem.sellsFor * ((row.minQuantity + row.maxQuantity) / 2)
 
lootValue = lootValue + artefactAvgValue
local function lootValueText(lootValue)
plusOneMinimumRefinementValue = plusOneMinimumRefinementValue + (dropChance * thisItem.sellsFor)  
local returnPart = {}
-- Checking if item is a consumable, then adding its value a second time
for _, currencyDefn in ipairs(GameData.rawData.currencies) do
        if Items._canItemUseSlot(thisItem, 'Consumable') then
-- Guarantee order by iterating through currency game data definition
            doubleConsumableRefinementValue = doubleConsumableRefinementValue + artefactAvgValue
local currID = currencyDefn.id
        end
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 '..Icons.GP(Shared.round(lootValue, 2, 0))..', ')
local lootText = lootValueText(lootValue)
table.insert(result, 'increasing to '..Icons.GP(Shared.round(lootValue + plusOneMinimumRefinementValue, 2, 0))..' when the +1 Minimum Items refinement is active.')
local plusOneLootText = lootValueText(plusOneMinimumRefinementValue)
if doubleConsumableRefinementValue > 0 then
local doubleLootText = lootValueText(doubleConsumableRefinementValue)
table.insert(result, '\r\n\r\nThe average value of one action with the x2 Consumables refinement is '..Icons.GP(Shared.round(lootValue + doubleConsumableRefinementValue, 2, 0))..'.')
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
for modifier, value in pairs(reward.modifiers) do
table.insert(rewardTable, Modifiers.getModifiersText(reward.modifiers, true))
table.insert(rewardTable, Constants._getModifierText(modifier, value, true))
end
end
end
if equipment ~= nil then
if equipment ~= nil then