12,872
edits
(_getEquipmentTable: Implement Strength level requirement column) |
mNo edit summary |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local Common = require('Module:Common') | |||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
Line 10: | Line 11: | ||
local styleOverrides = { | local styleOverrides = { | ||
Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Wrappings', 'Almighty Lute', 'Candy Cane', ' | Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Wrappings', 'Almighty Lute', 'Candy Cane', "Bob's Rake", "Knight's Defender", "Ward of Flame Platebody"}, | ||
Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)', 'Ice Arrows'}, | Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)', 'Ice Arrows'}, | ||
Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves', 'Frostspark Boots', 'Freezing Touch Body', 'Lightning Boots'}, | Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves', 'Frostspark Boots', 'Freezing Touch Body', 'Lightning Boots'}, | ||
Line 218: | Line 219: | ||
for i, spAttID in ipairs(item.specialAttacks) do | for i, spAttID in ipairs(item.specialAttacks) do | ||
local spAtt = GameData.getEntityByID('attacks', spAttID) | local spAtt = GameData.getEntityByID('attacks', spAttID) | ||
table.insert(txtLines, | local attChance = spAtt.defaultChance | ||
if item.overrideSpecialChances ~= nil then | |||
attChance = item.overrideSpecialChances[i] | |||
end | |||
table.insert(txtLines, attChance .. '% chance for ' .. spAtt.name .. ':') | |||
table.insert(txtLines, spAtt.description) | table.insert(txtLines, spAtt.description) | ||
end | end | ||
Line 258: | Line 263: | ||
for i, spAttID in ipairs(item.specialAttacks) do | for i, spAttID in ipairs(item.specialAttacks) do | ||
local spAtt = GameData.getEntityByID('attacks', spAttID) | local spAtt = GameData.getEntityByID('attacks', spAttID) | ||
table.insert(txtLines, | local attChance = spAtt.defaultChance | ||
if item.overrideSpecialChances ~= nil then | |||
attChance = item.overrideSpecialChances[i] | |||
end | |||
table.insert(txtLines, attChance .. '% chance for ' .. spAtt.name .. ':') | |||
table.insert(txtLines, spAtt.description) | table.insert(txtLines, spAtt.description) | ||
end | end | ||
Line 278: | Line 287: | ||
function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription, sortByName) | function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription, sortByName) | ||
-- If slot is a slot name, convert it to the slot ID instead | |||
slot = Constants.getEquipmentSlotID(slot) or (Constants.getEquipmentSlotName(slot) ~= nil and slot) | |||
local itemList = Items.getItems(function(item) | local itemList = Items.getItems(function(item) | ||
Line 384: | Line 392: | ||
local modDetail = {} | local modDetail = {} | ||
for i, modName in pairs(modsDL) do | for i, modName in pairs(modsDL) do | ||
local mName, mText | local mName, mText, mIsNeg, mModifyValue = Constants.getModifierDetails(modName) | ||
modDetail[modName] = { mult = ( | modDetail[modName] = { mult = (mIsNeg == false and 1 or -1) } | ||
end | end | ||
Line 414: | Line 422: | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end | ||
Line 482: | Line 446: | ||
) | ) | ||
else | else | ||
-- If category is a slot name, convert it to the slot ID instead | |||
category = Constants.getEquipmentSlotID(category) or (Constants.getEquipmentSlotName(category) ~= nil and category) | |||
if category == nil then | |||
return Shared.printError('Invalid option. Choose either an equipment slot, Potion, or Other') | return Shared.printError('Invalid option. Choose either an equipment slot, Potion, or Other') | ||
end | end | ||
Line 497: | Line 463: | ||
end | end | ||
local useStatChange = isEquipment or (string.upper(category) == 'POTION') | |||
local resultPart = {} | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | ||
table.insert(resultPart, '\r\n|- class="headerRow-0"') | table.insert(resultPart, '\r\n|- class="headerRow-0"') | ||
table.insert(resultPart, '\r\n!colspan="2"|Upgraded Item!!Ingredients') | table.insert(resultPart, '\r\n!colspan="2"|Upgraded Item!!Ingredients') | ||
if | if useStatChange then table.insert(resultPart, '!!Stat Change') end | ||
for i, upgrade in ipairs(upgradeArray) do | for i, upgrade in ipairs(upgradeArray) do | ||
Line 509: | Line 476: | ||
table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true})) | table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true})) | ||
table.insert(resultPart, '|| ' .. Common.getCostString({ items = upgrade.itemCosts, gp = upgrade.gpCost, sc = upgrade.scCost}, 'None')) | |||
local statChangeString = '' | |||
if useStatChange then | |||
-- Generate stat change column | |||
local statChangeString = '' | |||
if not Shared.tableIsEmpty(upgrade.rootItemIDs) then | |||
if | -- Some items (e.g. FEZ) may have multiple root items. Simply use the first one | ||
statChangeString = | local rootItem = Items.getItemByID(upgrade.rootItemIDs[1]) | ||
if rootItem ~= nil then | |||
statChangeString = Items.getStatChangeString(item, rootItem) | |||
end | end | ||
end | end | ||
table.insert(resultPart, '|| '..statChangeString) | |||
table.insert(resultPart, '||'..statChangeString) | |||
end | end | ||
end | end |