Module:Items: Difference between revisions

Update for v1.3
(getItemGrid: Implement filtering for certain items)
(Update for v1.3)
Line 9: Line 9:
local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Modifiers = require('Module:Modifiers')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Num = require('Module:Number')
local Num = require('Module:Number')
Line 145: Line 146:
end
end


-- Function already exists, but without fame.
function p.getValueText(item, minQuantity, maxQuantity)
local minQ, maxQ = 1, 1
if type(minQuantity) == 'number' then
minQ = minQuantity
end
if type(maxQuantity) == 'number' then
maxQ = maxQuantity
else
maxQ = minQ
end
local amt = item.sellsFor or 0
local currID = item.sellsForCurrency or 'melvorD:GP'
return Icons._Currency(currID, amt * minQ, amt * maxQ)
end
 
-- Function already exists, but without frame.
-- Giving it a slightly different name since function overloading doesn't exist
-- Giving it a slightly different name since function overloading doesn't exist
function p.getItemSellsFor(frame)
function p.getItemSellsFor(frame)
Line 180: Line 196:
end
end


--Gets the value of a given modifier for a given itemg
--Gets the value of a given modifier for a given item
--asString is false by default, when true it writes the full bonus text
--asString is false by default, when true it writes the full bonus text
function p._getItemModifier(item, modifier, skillID, asString)
function p._getItemModifier(item, modifier, skillID, asString)
Line 221: Line 237:
-- Ensure that, only in the case where the item is a Familar AND
-- Ensure that, only in the case where the item is a Familar AND
-- the checked stat is summoningMaxhit, the result is ignored.
-- the checked stat is summoningMaxhit, the result is ignored.
function isNonZeroStat(statName, statVal)
local function isNonZeroStat(statName, statVal)
if statName == 'summoningMaxhit' and (p._canItemUseSlot(item, 'Summon1') or p._canItemUseSlot(item, 'Summon2')) then
if statName == 'summoningMaxhit' and (p._canItemUseSlot(item, 'Summon1') or p._canItemUseSlot(item, 'Summon2')) then
return false
return false
Line 376: Line 392:


-- Include differences in modifiers
-- Include differences in modifiers
local modDiff = Constants.getModifiersText(Constants.getModifiersDifference(item2.modifiers, item1.modifiers))
-- TODO Implement getModifiersDifference
--local modDiff = Constants.getModifiersText(Constants.getModifiersDifference(item2.modifiers, item1.modifiers))
local modDiff = nil
if modDiff ~= nil and modDiff ~= '' then
if modDiff ~= nil and modDiff ~= '' then
table.insert(changeArray, modDiff)
table.insert(changeArray, modDiff)
Line 474: Line 492:
table.insert(resultPart, '<span style="color:green">Passive:</span><br/>')
table.insert(resultPart, '<span style="color:green">Passive:</span><br/>')
end
end
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true, false, 10))
table.insert(resultPart, Modifiers.getModifiersText(item.modifiers, true, false, 10))
end
end
return table.concat(resultPart)
return table.concat(resultPart)
Line 587: Line 605:
end
end
cell = curRow:tag('td')
local cell = curRow:tag('td')
:css('height', '48px')
:css('height', '48px')
:css('width', '48px')
:css('width', '48px')
Line 606: Line 624:
function p.getEquipRequirementRow(req)
function p.getEquipRequirementRow(req)
local result = ""
local result = ""
if req.type == "SkillLevel" then
if (req.type == "SkillLevel" or req.type == "AbyssalLevel") then
local pre = (req.type == "AbyssalLevel" and ' Abyssal') or ''
local skillName = Constants.getSkillName(req.skillID)
local skillName = Constants.getSkillName(req.skillID)
local skillIcon = Icons.Icon({skillName, type='skill', notext=true})
local skillIcon = Icons.Icon({skillName, type='skill', notext=true})
result = '\r\n!style="text-align:right;"| '..skillIcon..' Level Required'
result = '\r\n!style="text-align:right;"| '..skillIcon..pre..' Level Required'
result = result..'\r\n|style="text-align:right;"| '..req.level
result = result..'\r\n|style="text-align:right;"| '..req.level
elseif req.type == "DungeonCompletion" then
elseif req.type == "DungeonCompletion" then