2,875
edits
(Created page with "--Splitting some functions into here to avoid bloating a single file local p = {} local Constants = require('Module:Constants') local Shared = require('Module:Shared') local GameData = require('Module:GameData') local SkillData = GameData.skillData local Common = require('Module:Common') local Modifiers = require('Module:Modifiers') local Items = require('Module:Items') local Icons = require('Module:Icons') local Skills = require('Module:Skills') local ItemSourceTables...") |
No edit summary |
||
Line 118: | Line 118: | ||
table.sort(itemArray, function(a, b) return a.weight > b.weight end) | table.sort(itemArray, function(a, b) return a.weight > b.weight end) | ||
local | local html = mw.html.create('table') | ||
html:addClass('wikitable sortable stickyHeader') | |||
-- Add header row | |||
local headerRow = html:tag('tr'):addClass('headerRow-0') | |||
headerRow:tag('th'):attr('colspan', '2'):wikitext('Item') | |||
headerRow:tag('th'):wikitext('Value') | |||
headerRow:tag('th'):attr('colspan', '2'):wikitext('Chance') | |||
-- Add item rows | |||
for i, itemDef in ipairs(itemArray) do | for i, itemDef in ipairs(itemArray) do | ||
local item = Items.getItemByID(itemDef.itemID) | local item = Items.getItemByID(itemDef.itemID) | ||
Line 128: | Line 135: | ||
-- 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' | ||
local row = html:tag('tr') | |||
row:tag('td'):addClass('table-img'):wikitext(Icons.Icon({item.name, type='item', notext=true})) | |||
row:tag('td'):wikitext(Icons.Icon({item.name, type='item', noicon=true})) | |||
row:tag('td') | |||
:attr('data-sort-value', item.sellsFor) | |||
:wikitext(Items.getValueText(item)) | |||
row:tag('td') | |||
:css('text-align', 'right') | |||
:attr('data-sort-value', itemDef.weight) | |||
:wikitext(Shared.fraction(itemDef.weight, totalWt)) | |||
row:tag('td') | |||
:css('text-align', 'right') | |||
:wikitext(string.format(fmt, dropChance) .. '%') | |||
if lootValue[currID] == nil then | if lootValue[currID] == nil then | ||
lootValue[currID] = 0 | lootValue[currID] = 0 | ||
Line 139: | Line 156: | ||
end | end | ||
end | end | ||
return | local result = tostring(html) | ||
local averageValueText = 'The average value of a roll on the special fishing loot table is ' .. lootValueText(lootValue) | |||
return result .. '\n' .. averageValueText | |||
end | end | ||
edits