Module:Skills/Gathering: Difference between revisions

Left align sources column
(Replace unorthodox use of GameData.getEntities() with Shared.shallowClone(); getFishTable: Amend layout of catch time columns)
(Left align sources column)
 
(10 intermediate revisions by 4 users not shown)
Line 6: Line 6:
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Common = require('Module:Common')
local Common = require('Module:Common')
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Shop = require('Module:Shop')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local ItemSourceTables = require('Module:Items/SourceTables')
local ItemSourceTables = require('Module:Items/SourceTables')
Line 20: Line 21:
table.insert(reqText, Shared.formatnum(recipe.totalMasteryRequired) .. ' ' .. Icons.Icon({skillName, type='skill', notext=true}) .. ' ' .. Icons.Icon({'Mastery'}))
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 type(recipe.requirements) == 'table' then
local purchReq = Shop.getPurchaseByID(recipe.shopItemPurchased)
local reqs = Common.getRequirementString(recipe.requirements)
if purchReq ~= nil then
if reqs ~= nil then
table.insert(reqText, Shop._getPurchaseIcon({purchReq}))
table.insert(reqText, reqs)
end
end
end
end
Line 36: Line 37:
table.insert(resultPart, '!!XP!!Cut Time!!XP/s!!GP/s')
table.insert(resultPart, '!!XP!!Cut Time!!XP/s!!GP/s')


for i, tree in ipairs(SkillData.Woodcutting.trees) do
local trees = Shared.shallowClone(SkillData.Woodcutting.trees)
table.sort(trees, function(a, b) return a.level < b.level end)
for i, tree in ipairs(trees) do
local log = Items.getItemByID(tree.productId)
local log = Items.getItemByID(tree.productId)
table.insert(resultPart, '\n|-')
table.insert(resultPart, '\n|-')
Line 167: Line 170:
local resultPart = {}
local resultPart = {}
table.insert(resultPart, '{|class="wikitable sortable stickyHeader"')
table.insert(resultPart, '{|class="wikitable sortable"')
table.insert(resultPart, '\n|- class="headerRow-0"')
table.insert(resultPart, '\n|- class="headerRow-0"')
table.insert(resultPart, '\n!colspan=2|Gem!!Gem Chance!!Gem Price')
table.insert(resultPart, '\n!colspan=2|Gem!!Gem Chance!!Gem Price')
Line 251: Line 254:
for i, area in ipairs(SkillData.Fishing.areas) do
for i, area in ipairs(SkillData.Fishing.areas) do
result = result..'\r\n|-'
result = result..'\r\n|-'
result = result..'\r\n| style ="text-align: left;" |'..area.name
result = result..'\r\n| style ="text-align: left;" |'..Icons.getExpansionIcon(area.id)..area.name


local fishArray = {}
local fishArray = {}
Line 542: Line 545:
end
end


local result = '{|class="wikitable sortable stickyHeader"'
local tbl = mw.html.create()
result = result..'\r\n|- class="headerRow-0"'
local html = tbl:tag("table")
result = result..'\r\n!colspan=2|Seeds!!'..Icons.Icon({'Farming', type='skill', notext=true})..' Level'
        :addClass("wikitable sortable stickyHeader")
result = result..'!!XP!!Growth Time!!Seed Value'
    :tag('tr'):addClass("headerRow-0")
        :tag('th'):attr("colspan", 2):wikitext("Seeds")
        :tag('th'):wikitext(Icons.Icon({'Farming', type='skill', notext=true}) .. " Level")
        :tag('th'):wikitext('XP')
        :tag('th'):wikitext('Growth Time')
        :tag('th'):wikitext('Seed Value')
 
if category.id == 'melvorD:Allotment' then
if category.id == 'melvorD:Allotment' then
result = result..'!!colspan="2"|Crop!!Crop Healing!!Crop Value'
html:tag('th'):attr("colspan", 2):wikitext("Crop")
:tag('th'):wikitext('Crop Healing')
:tag('th'):wikitext('Crop Value')
elseif category.id == 'melvorD:Herb' then
elseif category.id == 'melvorD:Herb' then
result = result..'!!colspan="2"|Herb!!Herb Value'
html:tag('th'):attr("colspan", 2):wikitext("Herb")
:tag('th'):wikitext('Herb Value')
elseif category.id == 'melvorD:Tree' then
elseif category.id == 'melvorD:Tree' then
result = result..'!!colspan="2"|Logs!!Log Value'
html:tag('th'):attr("colspan", 2):wikitext("Logs")
:tag('th'):wikitext('Log Value')
end
end
result = result..'!!Seed Sources'
html = html:tag('th'):wikitext('Seed Sources')


table.sort(seedList, function(a, b) return a.level < b.level end)
table.sort(seedList, function(a, b) return a.level < b.level end)
Line 561: Line 574:
local productItem = Items.getItemByID(seed.productId)
local productItem = Items.getItemByID(seed.productId)
if seedItem ~= nil and productItem ~= nil then
if seedItem ~= nil and productItem ~= nil then
result = result..'\r\n|-'
html =  
result = result..'\r\n|'..Icons.Icon({seedItem.name, type='item', size='50', notext=true})
html:tag('tr')
result = result..'|| ' .. Icons.getExpansionIcon(seedItem.id) .. Icons.Icon({seedItem.name, type='item', noicon=true})
:tag('td'):wikitext(Icons.Icon({seedItem.name, type='item', size='50', notext=true}))
result = result..'||'..seed.level..'||'..Shared.formatnum(seed.baseExperience)
:tag('td'):wikitext(Icons.getExpansionIcon(seedItem.id) .. Icons.Icon({seedItem.name, type='item', noicon=true}))
result = result..'||data-sort-value="'..(seed.baseInterval / 1000)..'"|'..Shared.timeString(seed.baseInterval / 1000, true)
:tag('td'):wikitext(seed.level)
result = result..'||data-sort-value="'..seedItem.sellsFor..'"|'..Icons.GP(seedItem.sellsFor)
:tag('td'):wikitext(Shared.formatnum(seed.baseExperience))
result = result..'||'..Icons.Icon({productItem.name, type='item', size='50', notext=true})
:tag('td'):attr('data-sort-value', (seed.baseInterval / 1000))
result = result..'|| ' .. Icons.getExpansionIcon(productItem.id) .. Icons.Icon({productItem.name, type='item', noicon=true})
  :wikitext(Shared.timeString(seed.baseInterval / 1000, true))
:tag('td'):attr('data-sort-value', seedItem.sellsFor)
      :wikitext(Icons.GP(seedItem.sellsFor))
:tag('td'):wikitext(Icons.Icon({productItem.name, type='item', size='50', notext=true}))
:tag('td'):wikitext(Icons.getExpansionIcon(productItem.id) .. Icons.Icon({productItem.name, type='item', noicon=true}))
 
if category.id == 'melvorD:Allotment' then
if category.id == 'melvorD:Allotment' then
result = result..'||'..Icons.Icon({'Hitpoints', type='skill', notext=true})..' '..((productItem.healsFor or 0) * 10)
html:tag('td'):wikitext(Icons.Icon({'Hitpoints', type='skill', notext=true}))
  :wikitext(' ')
  :wikitext(((productItem.healsFor or 0) * 10))
end
end
result = result..'||data-sort-value="'..productItem.sellsFor..'"|'..Icons.GP(productItem.sellsFor)
html =
result = result..'||'..ItemSourceTables._getItemSources(seedItem)
html:tag('td'):attr('data-sort-value', productItem.sellsFor)
  :wikitext(Icons.GP(productItem.sellsFor))
:tag('td'):wikitext(ItemSourceTables._getItemSources(seedItem))
  :css('text-align', 'left')
:done()
end
end
end
end


result = result..'\r\n|}'
return tostring(tbl:done())
return result
end
end


Line 626: Line 649:
function(plot)
function(plot)
return plot.categoryID == category.id
return plot.categoryID == category.id
end)
table.sort(patches,
function(a, b)
if a.level == b.level then
return a.id < b.id
else
return a.level < b.level
end
end)
end)
if Shared.tableIsEmpty(patches) then
if Shared.tableIsEmpty(patches) then
Line 634: Line 665:
result = result..'\r\n!Plot!!'..Icons.Icon({'Farming', type='skill', notext=true})..' Level!!Cost'
result = result..'\r\n!Plot!!'..Icons.Icon({'Farming', type='skill', notext=true})..' Level!!Cost'


for i, patch in Shared.skpairs(patches) do
for i, patch in ipairs(patches) do
result = result..'\r\n|-\r\n|'..i
result = result..'\r\n|-\r\n|'..i
result = result..'||style="text-align:right;" data-sort-value="' .. patch.level .. '"|'..patch.level
result = result..'||style="text-align:right;" data-sort-value="' .. patch.level .. '"|'..patch.level
local costText = (patch.gpCost > 0 and Icons.GP(patch.gpCost)) or 'Free'
local costText = Common.getCostString({ items = patch.itemCosts, gp = patch.gpCost }, 'Free')
result = result..'||style="text-align:right;" data-sort-value="'..patch.gpCost..'"|'..costText
result = result..'||style="text-align:right;" data-sort-value="'..patch.gpCost..'"|'..costText
end
end
Line 654: Line 685:
table.insert(resultPart, string.rep('\n! ' .. Icons.Icon({'Mastery', notext=true}) .. 'Level\n! Modifiers', 2))
table.insert(resultPart, string.rep('\n! ' .. Icons.Icon({'Mastery', notext=true}) .. 'Level\n! Modifiers', 2))


for i, cons in ipairs(SkillData.Astrology.recipes) do
local recipes = Shared.shallowClone(SkillData.Astrology.recipes)
table.sort(recipes, function(a, b) return a.level < b.level end)
for i, cons in ipairs(recipes) do
-- Generate the list of modifiers first for the purpose of determining the
-- Generate the list of modifiers first for the purpose of determining the
-- the number of rows required to display all stars
-- the number of rows required to display all stars
Line 688: Line 721:
local rowSpan = (maxRows > 1 and 'rowspan="' .. maxRows .. '"') or ''
local rowSpan = (maxRows > 1 and 'rowspan="' .. maxRows .. '"') or ''
table.insert(resultPart, '\n|-')
table.insert(resultPart, '\n|-')
table.insert(resultPart, '\n|' .. rowSpan .. ' data-sort-value="' .. name .. '"| ' .. Icons.Icon({name, type='constellation', size='50', notext=true}))
table.insert(resultPart, '\n|' .. rowSpan .. ' data-sort-value="' .. name .. '" id="'..name..'"| ')
table.insert(resultPart, Icons.Icon({name, type='constellation', size='50', notext=true}))
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. Icons.getExpansionIcon(cons.id) .. name)
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. Icons.getExpansionIcon(cons.id) .. name)
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.level)
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.level)
915

edits