Module:Items/ComparisonTables: Difference between revisions

Add two-handed indicator column for weapon tables
m (Fix attack speed handling)
(Add two-handed indicator column for weapon tables)
 
(3 intermediate revisions by 2 users not shown)
Line 23: Line 23:


local slotOverrides = {
local slotOverrides = {
['2hWeapons'] = 'melvorD:2hWeapons',
['Enhancement'] = 'melvorD:Enhancement'
['Enhancement'] = 'melvorD:Enhancement'
}
}
Line 95: Line 94:
for _, slotLocalID in ipairs(item.validSlots) do
for _, slotLocalID in ipairs(item.validSlots) do
local newSlotID = slotLocalID
local newSlotID = slotLocalID
-- Separate two-handed weapons from other weapons
if slotLocalID == 'Weapon' and Items._getItemStat(item, 'isTwoHanded') then
newSlotID = '2hWeapons'
-- Classify javelins and throwing knives as weapons
-- Classify javelins and throwing knives as weapons
elseif slotLocalID == 'Quiver' and Shared.contains({'Javelins', 'ThrowingKnives'}, item.ammoType) then
if slotLocalID == 'Quiver' and Shared.contains({'Javelins', 'ThrowingKnives'}, item.ammoType) then
newSlotID = 'Weapon'
newSlotID = 'Weapon'
-- Combine all enhancements
-- Combine all enhancements
elseif Shared.contains({'Enhancement1', 'Enhancement2', 'Enhancment3'}, slotLocalID) then
elseif Shared.contains({'Enhancement1', 'Enhancement2', 'Enhancement3'}, slotLocalID) then
newSlotID = 'Enhancement'
newSlotID = 'Enhancement'
end
end
equipEntry.slots[newSlotID] = true
equipEntry.slots[newSlotID] = true
end
end
equipEntry.isWeapon = equipEntry.slots['Weapon'] or equipEntry.slots['2hWeapons'] or Shared.contains(occupiesSlots, 'Weapon')
equipEntry.isWeapon = equipEntry.slots['Weapon'] or Shared.contains(occupiesSlots, 'Weapon')


-- Determine the style of the item (Melee, Ranged, Magic, Other)
-- Determine the style of the item (Melee, Ranged, Magic, Other)
Line 327: Line 323:
:toTable()
:toTable()
 
 
local isWeapon = (slot == 'Weapon' or slot == '2hWeapons')
local isWeapon = (slot == 'Weapon')
local itemColspan = 3
local itemColspan = (isWeapon and 5) or 3
if isWeapon == true then itemColspan = 4 end
local html = mw.html.create('table')
local html = mw.html.create('table')
Line 352: Line 347:
header1:tag('th'):wikitext('DLC')
header1:tag('th'):wikitext('DLC')
if isWeapon == true then
if isWeapon == true then
header1:tag('th'):wikitext('Two<br>Handed')
header1:tag('th'):wikitext('Attack<br>Speed')
header1:tag('th'):wikitext('Attack<br>Speed')
end
end
Line 388: Line 384:
:attr('data-sort-value', Icons.getExpansionID(item.id))
:attr('data-sort-value', Icons.getExpansionID(item.id))


-- Add attack speed.
-- Add two-handed & attack speed.
if isWeapon == true then
if isWeapon == true then
local twoHandText = (Items._getItemStat(item, 'isTwoHanded') and 'Yes') or 'No'
row:tag('td'):wikitext(twoHandText)
:css('text-align', 'center')
local atkSpeed = Items._getItemStat(item, 'attackSpeed') or 0
local atkSpeed = Items._getItemStat(item, 'attackSpeed') or 0
if atkSpeed > 0 then
if atkSpeed > 0 then
Line 468: Line 468:
return p.getEquipmentTable(itemList)
return p.getEquipmentTable(itemList)
end
end
end
function p.getDoubleLootTable(frame)
local modsDL = {
["id"] = {
'melvorD:doubleItemsSkill',
'melvorD:doubleItemsChanceAgainstDamageType'
},
["alias"] = {
'increasedChanceToDoubleLootCombat',
'decreasedChanceToDoubleLootCombat',
'increasedChanceToDoubleItemsGlobal',
'decreasedChanceToDoubleItemsGlobal'
}
}
local matchCriteria = Modifiers.getMatchCriteriaFromIDs(modsDL.id, modsDL.alias)
local itemMatchedMods = {}
local itemList = Items.getItems(
function(item)
if item.modifiers ~= nil then
local matchedMods = Modifiers.getMatchingModifiers(item.modifiers, matchCriteria)
if Shared.tableIsEmpty(matchedMods.matched) then
return false
else
itemMatchedMods[item.id] = matchedMods.matched
return true
end
end
end
)
local resultPart = {}
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"')
table.insert(resultPart, '\r\n!colspan="2"|Name!!Bonus!!Description')
for i, item in Shared.skpairs(itemList) do
local lootValue = Modifiers.getModifierValue(itemMatchedMods[item.id])
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..lootValue..'"|'..lootValue..'%')
table.insert(resultPart, '||' .. getItemDesc(item))
end
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end
end


Line 630: Line 584:
local PR = item.providedRunes
local PR = item.providedRunes
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|style="text-align: centre;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
table.insert(resultPart, '\r\n|style="text-align: center;"|'..Icons.Icon({item.name, type='item', size=50, notext=true}))
table.insert(resultPart, '\r\n|' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n|' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
local runeLines = {}
local runeLines = {}