Module:GolbinRaid: Difference between revisions

Removed prefix code in getRaidModifierList
(getCrateContents: Initial implementation)
 
(Removed prefix code in getRaidModifierList)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}
local RaidData = mw.loadData('Module:GolbinRaid/data')


local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local GameData = require('Module:GameData')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Items = require('Module:Items')
Line 16: Line 15:
[35] = 'Common'
[35] = 'Common'
}
}
local crateContents = RaidData.GolbinCrate


local resultTable = mw.html.create('table')
local resultTable = mw.html.create('table')
Line 34: Line 32:
end
end


for i, crateEntry in Shared.spairs(RaidData.GolbinCrate, sortFunc) do
for i, crateEntry in Shared.spairs(GameData.rawData.golbinRaid.crateItems, sortFunc) do
local item = Items.getItemByID(crateEntry.itemID)
local item = Items.getItemByID(crateEntry.itemID)
if item ~= nil then
if item ~= nil then
Line 59: Line 57:
-- If the item has special attacks, use those
-- If the item has special attacks, use those
local spAttText = {}
local spAttText = {}
for j, spAtt in ipairs(item.specialAttacks) do
for j, spAttID in ipairs(item.specialAttacks) do
table.insert(spAttText, '<b>' .. spAtt.name .. ' (' .. Shared.round(spAtt.defaultChance, 2, 0) .. '%)</b> - ' .. spAtt.description)
local spAtt = GameData.getEntityByID('attacks', spAttID)
if spAtt ~= nil then
table.insert(spAttText, '<b>' .. spAtt.name .. ' (' .. Shared.round(spAtt.defaultChance, 2, 0) .. '%)</b> - ' .. spAtt.description)
end
end
end
descText = table.concat(spAttText, '<br/>')
descText = table.concat(spAttText, '<br/>')
Line 78: Line 79:
end
end
end
end
return tostring(resultTable)
end
function p.getRaidModifierList()
local modList = {}
for i, modDet in ipairs(GameData.rawData.golbinRaid.possibleModifiers) do
local baseName, modText, isNeg, modifyValue = Constants.getModifierDetails(modDet.key)
if modList[baseName] == nil then
local modVal = {1, 5}
local mult = modDet.multiplier
if mult ~= nil then
modVal = {modVal[1] * mult, modVal[2] * mult}
end
modText = Constants._getModifierText(modDet.key, modVal, false)
modList[baseName] = {modText, ["ord"] = i, ["mods"] = 1}
else
modList[baseName]["mods"] = modList[baseName]["mods"] + 1
end
end
local resultTable = mw.html.create('table')
resultTable
:addClass('wikitable'):addClass('stickyHeader'):addClass('sortable')
:addClass('mw-collapsible'):addClass('mw-collapsed')
resultTable:tag('tr'):addClass('headerRow-0')
:tag('th'):attr('style', 'min-width:400px'):wikitext('Modifier'):done()
local sortFunc = function(t, a, b) return t[a].ord < t[b].ord end
for baseName, modDet in Shared.spairs(modList, sortFunc) do
local modText = modDet[1]
if modDet['mods'] > 1 then
local replPat = '[+-]'
modText = string.gsub(modDet[1], replPat, '+/-', 2)
end
resultTable:tag('tr')
:tag('td'):wikitext(modText):done()
end
return tostring(resultTable)
return tostring(resultTable)
end
end


return p
return p
599

edits