Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
getTreesTable: Expand requirements column to include shop purchases; getMiningOresTable: Include rock/type columns, amend requirements text for consistency
(Nevermind, the first pass was better)
(getTreesTable: Expand requirements column to include shop purchases; getMiningOresTable: Include rock/type columns, amend requirements text for consistency)
Line 120: Line 120:


return p.getToolTable('Rod', '_Rod$', modifiers, 'melvorD:Fishing')
return p.getToolTable('Rod', '_Rod$', modifiers, 'melvorD:Fishing')
end
function p.getRecipeRequirements(skillName, recipe)
local reqText = {}
if recipe.level ~= nil then
table.insert(reqText, Icons._SkillReq(skillName, recipe.level, false))
end
if recipe.shopItemPurchased ~= nil then
local purchReq = Shop.getPurchaseByID(recipe.shopItemPurchased)
if purchReq ~= nil then
table.insert(reqText, Shop._getPurchaseIcon({purchReq}))
end
end
return table.concat(reqText, '<br/>')
end
end


function p.getTreesTable(frame)
function p.getTreesTable(frame)
local result = '{| class="wikitable sortable"'
local resultPart = {}
result = result..'\r\n|- class="headerRow-0"'
table.insert(resultPart, '{| class="wikitable sortable"')
result = result..'\r\n!colspan="2"|Tree!!colspan="2"|Logs!!'..Icons.Icon({'Woodcutting', type='skill', notext=true})..' Level'
table.insert(resultPart, '\n|- class="headerRow-0"')
result = result..'!!XP!!Cut Time!!XP/s!!GP/s'
table.insert(resultPart, '\n!colspan="2"|Tree!!colspan="2"|Logs!!Requirements')
table.insert(resultPart, '!!XP!!Cut Time!!XP/s!!GP/s')


for i, tree in ipairs(SkillData.Woodcutting.trees) do
for i, tree in ipairs(SkillData.Woodcutting.trees) do
local log = Items.getItemByID(tree.productId)
local log = Items.getItemByID(tree.productId)
result = result..'\r\n|-'
table.insert(resultPart, '\n|-')
result = result..'\r\n|style="min-width:25px" data-sort-value="'..tree.name..'"|'..Icons.Icon({log.name, img=tree.name, type='tree', notext=true, size=50})
table.insert(resultPart, '\n|class="table-img" data-sort-value="'..tree.name..'"| '..Icons.Icon({log.name, img=tree.name, type='tree', notext=true, size=50}))
result = result..'||'..tree.name..''
table.insert(resultPart, '\n|'..tree.name)
result = result..'||style="min-width:25px" data-sort-value="'..log.name..'"|'..Icons.Icon({log.name, type='item', notext=true, size=50})
table.insert(resultPart, '\n|class="table-img" data-sort-value="'..log.name..'"| '..Icons.Icon({log.name, type='item', notext=true, size=50}))
result = result..'||'..Icons.Icon({log.name, type='item', noicon=true})
table.insert(resultPart, '\n| '..Icons.Icon({log.name, type='item', noicon=true}))
result = result..'||style="text-align:right"|'..tree.level
table.insert(resultPart, '\n|data-sort-value="' .. tree.level .. '"| ' .. p.getRecipeRequirements(SkillData.Woodcutting.name, tree))
result = result..'||style="text-align:right"|'..tree.baseExperience
table.insert(resultPart, '\n|style="text-align:right"| '..tree.baseExperience)
result = result..'||style="text-align:right" data-sort-value="'..tree.baseInterval..'"|'..Shared.timeString(tree.baseInterval/1000, true)
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="'..tree.baseInterval..'"| '..Shared.timeString(tree.baseInterval/1000, true))
local XPs = tree.baseExperience / (tree.baseInterval / 1000)
local XPs = tree.baseExperience / (tree.baseInterval / 1000)
local GPs = log.sellsFor / (tree.baseInterval / 1000)
local GPs = log.sellsFor / (tree.baseInterval / 1000)
result = result..'||style="text-align:right"|'..Shared.round(XPs, 2, 2)
table.insert(resultPart, '\n|style="text-align:right"| '..Shared.round(XPs, 2, 2))
result = result..'||style="text-align:right" data-sort-value="'..GPs..'"|'..Icons.GP(Shared.round(GPs, 2, 2))
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="'..GPs..'"| '..Icons.GP(Shared.round(GPs, 2, 2)))
end
end


result = result..'\r\n|}'
table.insert(resultPart, '\n|}')
return result
return table.concat(resultPart)
end
end


Line 166: Line 181:
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f'
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f'
table.insert(resultPart, '\r\n|-\r\n|style="text-align:center"| ' .. Icons.Icon({item.name, type='item', notext=true}))
table.insert(resultPart, '\r\n|-\r\n|class="table-img"| ' .. Icons.Icon({item.name, type='item', notext=true}))
table.insert(resultPart, '\r\n| ' .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n| ' .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n|data-sort-value="' .. item.sellsFor .. '"| ' .. Icons.GP(math.floor(item.sellsFor)))
table.insert(resultPart, '\r\n|data-sort-value="' .. item.sellsFor .. '"| ' .. Icons.GP(math.floor(item.sellsFor)))
Line 195: Line 210:
for i, item in ipairs(itemArray) do
for i, item in ipairs(itemArray) do
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|style="min-width:25px"| ' .. Icons.Icon({item.name, type='item', notext=true, size=50}))
table.insert(resultPart, '\r\n|class="table-img"| ' .. Icons.Icon({item.name, type='item', notext=true, size=50}))
table.insert(resultPart, '\r\n| ' .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n| ' .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n|data-sort-value="' .. item.sellsFor .. '"| ' .. Icons.GP(math.floor(item.sellsFor)))
table.insert(resultPart, '\r\n|data-sort-value="' .. item.sellsFor .. '"| ' .. Icons.GP(math.floor(item.sellsFor)))
Line 204: Line 219:


function p.getMiningOresTable(frame)
function p.getMiningOresTable(frame)
local result = '{|class="wikitable sortable stickyHeader"'
local resultPart = {}
result = result..'\r\n|- class="headerRow-0"'
table.insert(resultPart, '{|class="wikitable sortable stickyHeader"')
result = result..'\r\n!colspan=2|Ore!!Requirements'
table.insert(resultPart, '\n|- class="headerRow-0"')
result = result..'!!XP!!Respawn Time!!Ore Value'
table.insert(resultPart, '\n!colspan="2"|Rock!!colspan=2|Ore!!Type!!Requirements')
table.insert(resultPart, '!!XP!!Respawn Time!!Ore Value')


local mineData = GameData.getEntities(SkillData.Mining.rockData, function(rock) return true end)
local mineData = GameData.getEntities(SkillData.Mining.rockData, function(rock) return true end)
Line 214: Line 230:
for i, oreData in ipairs(mineData) do
for i, oreData in ipairs(mineData) do
local ore = Items.getItemByID(oreData.productId)
local ore = Items.getItemByID(oreData.productId)
local reqText = { Icons._SkillReq('Mining', oreData.level) }
local respawnStyle, respawnSort, respawnText = 'class="table-na"', 0, 'N/A'
if oreData.shopItemPurchased ~= nil then
local purchase = Shop.getPurchaseByID(oreData.shopItemPurchased)
if purchase ~= nil then
table.insert(reqText, Shop._getPurchaseIcon({purchase}) .. ' purchased')
end
end
local respawnSort, respawnText = 0, 'N/A'
if oreData.hasPassiveRegen then
if oreData.hasPassiveRegen then
respawnStyle = 'style="text-align:right;'
respawnSort = oreData.baseRespawnInterval / 1000
respawnSort = oreData.baseRespawnInterval / 1000
respawnText = Shared.timeString(respawnSort, true)
respawnText = Shared.timeString(respawnSort, true)
end
end
local rockName = Icons.Icon({oreData.name, type='rock', noicon=true, nolink=true})
result = result..'\r\n|-\r\n|style="min-width:25px"|'..Icons.Icon({ore.name, type='item', size='50', notext=true})
table.insert(resultPart, '\n|-\n|class="table-img" data-sort-value="' .. rockName .. '"| '..Icons.Icon({oreData.name, type='rock', size='50', notext=true, nolink=true}))
result = result..'||'..Icons.Icon({ore.name, type='item', noicon=true})
table.insert(resultPart, '\n| ' .. rockName)
result = result..'||data-sort-value="' .. oreData.level ..'"| '..table.concat(reqText, '<br/>')..'||style="text-align:right"|'..oreData.baseExperience
table.insert(resultPart, '\n|class="table-img" data-sort-value="' .. ore.name .. '"| '..Icons.Icon({ore.name, type='item', size='50', notext=true}))
result = result..'||style="text-align:right" data-sort-value="'..respawnSort..'"|'
table.insert(resultPart, '\n| ' .. Icons.Icon({ore.name, type='item', noicon=true}))
result = result..respawnText
table.insert(resultPart, '\n| ' .. oreData.type)
result = result..'||data-sort-value="'..ore.sellsFor..'"|'..Icons.GP(ore.sellsFor)
table.insert(resultPart, '\n|data-sort-value="' .. oreData.level ..'"| '..p.getRecipeRequirements(SkillData.Mining.name, oreData))
table.insert(resultPart, '\n|style="text-align:right"| '..oreData.baseExperience)
table.insert(resultPart, '\n|' .. respawnStyle .. ' data-sort-value="'..respawnSort..'"| ' .. respawnText)
table.insert(resultPart, '\n|data-sort-value="'..ore.sellsFor..'"| '..Icons.GP(ore.sellsFor))
end
end


result = result..'\r\n|}'
table.insert(resultPart, '\n|}')
return result
return table.concat(resultPart)
end
end