Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
getRecipeRequirements: Include mastery requirement; getMiningGemsTable: Expand to include superior gems
(getTreesTable: Expand requirements column to include shop purchases; getMiningOresTable: Include rock/type columns, amend requirements text for consistency)
(getRecipeRequirements: Include mastery requirement; getMiningGemsTable: Expand to include superior gems)
Line 126: Line 126:
if recipe.level ~= nil then
if recipe.level ~= nil then
table.insert(reqText, Icons._SkillReq(skillName, recipe.level, false))
table.insert(reqText, Icons._SkillReq(skillName, recipe.level, false))
end
if recipe.totalMasteryRequired ~= nil then
table.insert(reqText, Shared.formatnum(recipe.totalMasteryRequired) .. ' ' .. Icons.Icon({skillName, type='skill', notext=true}) .. ' ' .. Icons.Icon({'Mastery'}))
end
end
if recipe.shopItemPurchased ~= nil then
if recipe.shopItemPurchased ~= nil then
Line 253: Line 256:
end
end


-- TODO TotH has random superior gems also
function p._getMiningGemsTable(gemType)
function p.getMiningGemsTable(frame)
if type(gemType) ~= 'string' then
local result = '{|class="wikitable sortable stickyHeader"'
gemType = 'Normal'
result = result..'\r\n|- class="headerRow-0"'
end
result = result..'\r\n!colspan=2|Gem!!Gem Chance!!Gem Price'
local validTypes = {
 
["Normal"] = 'randomGems',
["Superior"] = 'randomSuperiorGems'
}
local gemDataKey = validTypes[gemType]
if gemDataKey == nil then
return 'ERROR: No such gem type "' .. gemType .. '"[[Category:Pages with script errors]]'
end
local gemData = GameData.rawData[gemDataKey]
local totalWeight = 0
local totalWeight = 0
for i, gemData in ipairs(GameData.rawData.randomGems) do
for i, gem in ipairs(gemData) do
totalWeight = totalWeight + gemData.weight
totalWeight = totalWeight + gem.weight
end
end
local resultPart = {}
table.insert(resultPart, '{|class="wikitable sortable stickyHeader"')
table.insert(resultPart, '\n|- class="headerRow-0"')
table.insert(resultPart, '\n!colspan=2|Gem!!Gem Chance!!Gem Price')


for i, gemData in ipairs(GameData.rawData.randomGems) do
for i, gem in ipairs(gemData) do
local gem = Items.getItemByID(gemData.itemID)
local gemItem = Items.getItemByID(gem.itemID)
result = result..'\r\n|-\r\n|style="min-width:25px"|'
local gemPct = gem.weight / totalWeight * 100
result = result..Icons.Icon({gem.name, type='item', size='50', notext=true})
table.insert(resultPart, '\n|-\n|class="table-img"| ')
result = result..'||'..Icons.Icon({gem.name, type='item', noicon=true})
table.insert(resultPart, Icons.Icon({gemItem.name, type='item', size='50', notext=true}))
result = result..'||style="text-align:right"|'..string.format("%.1f%%", gemData.weight / totalWeight * 100)
table.insert(resultPart, '\n| ' .. Icons.Icon({gemItem.name, type='item', noicon=true}))
result = result..'||data-sort-value="'..gem.sellsFor..'"|'..Icons.GP(gem.sellsFor)
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. gemPct .. '" | ' .. string.format("%.1f%%", gemPct))
table.insert(resultPart, '\n|data-sort-value="' .. gemItem.sellsFor .. '"| ' .. Icons.GP(gemItem.sellsFor))
end
end


result = result..'\r\n|}'
table.insert(resultPart, '\n|}')
return result
return table.concat(resultPart)
end
 
function p.getMiningGemsTable(frame)
local gemType = frame.args ~= nil and frame.args[1] or frame
return p._getMiningGemsTable(gemType)
end
end


Line 356: Line 378:
end
end


-- TODO Expose list of NPCs somewhere when applicable (e.g. for Thieving Shorts)
function p._getThievingGeneralRareTable(npcID)
function p._getThievingGeneralRareTable(npcID)
local rareTxt = '{|class="wikitable sortable"'
local rareTxt = '{|class="wikitable sortable"'