Anonymous

Module:Skills/Gathering/Sandbox: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 343: Line 343:
local skillID = 'Fishing'
local skillID = 'Fishing'


local recipeList = GameData.getEntities(SkillData.Fishing.fish,
local recipeList = GameData.getEntities(SkillData.Fishing.fish, function(obj)
function(obj)
return Skills.getRecipeRealm(obj) == realm.id
return Skills.getRecipeRealm(obj) == realm.id
end)
end
)
table.sort(recipeList, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
table.sort(recipeList, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)


Line 362: Line 360:
end
end


local resultPart = {}
local html = mw.html.create('table')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
html:addClass('wikitable sortable stickyHeader')
table.insert(resultPart, '\n|- class="headerRow-0"')
 
table.insert(resultPart, '\n!colspan="2" rowspan="2"|Fish\n!rowspan="2"|Requirements')
-- Add header row
table.insert(resultPart, '\n!colspan="3"|Catch Time\n!rowspan="2"|XP\n!rowspan="2"|Value\n!rowspan="2"|XP/s\n!rowspan="2"|Price/s')
local headerRow0 = html:tag('tr'):addClass('headerRow-0')
table.insert(resultPart, '\n!rowspan="2"|' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' Level')
headerRow0:tag('th'):attr('colspan', '2'):attr('rowspan', '2'):wikitext('Fish')
table.insert(resultPart, '\n|- class="headerRow-1"\n!Min\n!Max\n!Avg')
headerRow0:tag('th'):attr('rowspan', '2'):wikitext('Requirements')
headerRow0:tag('th'):attr('colspan', '3'):wikitext('Catch Time')
headerRow0:tag('th'):attr('rowspan', '2'):wikitext('XP')
headerRow0:tag('th'):attr('rowspan', '2'):wikitext('Value')
headerRow0:tag('th'):attr('rowspan', '2'):wikitext('XP/s')
headerRow0:tag('th'):attr('rowspan', '2'):wikitext('Price/s')
headerRow0:tag('th'):attr('rowspan', '2'):wikitext(Icons.Icon({'Cooking', type='skill', notext=true}) .. ' Level')
 
local headerRow1 = html:tag('tr'):addClass('headerRow-1')
headerRow1:tag('th'):wikitext('Min')
headerRow1:tag('th'):wikitext('Max')
headerRow1:tag('th'):wikitext('Avg')
 
-- Add fish rows
for i, recipe in ipairs(recipeList) do
for i, recipe in ipairs(recipeList) do
local fish = Items.getItemByID(recipe.productId)
local fish = Items.getItemByID(recipe.productId)
Line 375: Line 386:
local timeAvg = (timeMin + timeMax) / 2
local timeAvg = (timeMin + timeMax) / 2
local timeSortVal = (recipe.baseMinInterval + recipe.baseMaxInterval) / 2000
local timeSortVal = (recipe.baseMinInterval + recipe.baseMaxInterval) / 2000
local timeStr = string.format("%.1fs - %.1fs", recipe.baseMinInterval / 1000, recipe.baseMaxInterval / 1000)
local level = Skills.getRecipeLevel(skillID, recipe)
local level = Skills.getRecipeLevel(skillID, recipe)
local reqText = Skills.getRecipeRequirementText(skillID, recipe)
local reqText = Skills.getRecipeRequirementText(skillID, recipe)
Line 389: Line 399:
cookStr = Skills.getRecipeRequirementText('Cooking', cookRecipe)
cookStr = Skills.getRecipeRequirementText('Cooking', cookRecipe)
end
end
table.insert(resultPart, '\n|-')
 
table.insert(resultPart, '\n|class="table-img"| ' .. Icons.Icon({fish.name, type='item', notext=true}))
local row = html:tag('tr')
table.insert(resultPart, '\n|data-sort-value="'..fish.name..'"|'..Icons.getDLCColumnIcon(fish.id) .. Icons.Icon({fish.name, type='item', noicon=true}))
row:tag('td'):addClass('table-img'):wikitext(Icons.Icon({fish.name, type='item', notext=true}))
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. level .. '"| ' .. reqText)
row:tag('td')
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. timeMin .. '"| ' .. string.format("%.1fs", timeMin))
:attr('data-sort-value', fish.name)
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. timeMax .. '"| ' .. string.format("%.1fs", timeMax))
:wikitext(Icons.getDLCColumnIcon(fish.id) .. Icons.Icon({fish.name, type='item', noicon=true}))
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. timeAvg .. '"| ' .. string.format("%.1fs", timeAvg))
row:tag('td')
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. baseXP .. '"| ' .. Shared.formatnum(baseXP))
:css('text-align', 'right')
table.insert(resultPart, '\n|data-sort-value="' .. fish.sellsFor .. '"| ' .. Items.getValueText(fish))
:attr('data-sort-value', level)
table.insert(resultPart, '\n|style="text-align:right"| ' .. Shared.round(XPSec, 2, 2))
:wikitext(reqText)
table.insert(resultPart, '\n|data-sort-value="' .. currPerSec .. '"|' .. Icons._Currency(sellCurrency, currPerSec))
row:tag('td')
table.insert(resultPart, '\n|' .. cookStyle .. 'data-sort-value="' .. cookLevel .. '"| ' .. cookStr)
:css('text-align', 'right')
:attr('data-sort-value', timeMin)
:wikitext(string.format("%.1fs", timeMin))
row:tag('td')
:css('text-align', 'right')
:attr('data-sort-value', timeMax)
:wikitext(string.format("%.1fs", timeMax))
row:tag('td')
:css('text-align', 'right')
:attr('data-sort-value', timeAvg)
:wikitext(string.format("%.1fs", timeAvg))
row:tag('td')
:css('text-align', 'right')
:attr('data-sort-value', baseXP)
:wikitext(Shared.formatnum(baseXP))
row:tag('td')
:attr('data-sort-value', fish.sellsFor)
:wikitext(Items.getValueText(fish))
row:tag('td')
:css('text-align', 'right')
:wikitext(Shared.round(XPSec, 2, 2))
row:tag('td')
:attr('data-sort-value', currPerSec)
:wikitext(Icons._Currency(sellCurrency, currPerSec))
row:tag('td')
:attr(cookStyle)
:attr('data-sort-value', cookLevel)
:wikitext(cookStr)
end
end
end
end
table.insert(resultPart, '\n|}')
 
return table.concat(resultPart)
return tostring(html)
end
end


function p.getFishingAreasTable(frame)
function p.getFishingAreasTable(frame)
2,875

edits