Module:ItemTables: Difference between revisions

add return fire to bullet resist
add bullet resist reduction, add souls icon, apply fix for negative numbers that are not red, cleanup
Line 38: Line 38:
     return copy
     return copy
end
end


-- local link_patterns = {}
-- local link_patterns = {}
Line 66: Line 65:
friendly_to_internal["spirit shield health"] = { "TechShieldMaxHealth", "TechShieldOnCast", "SaviorMagicShieldHealth", "FlyingTechShield", "VexBarrierTechMaxHealth" }
friendly_to_internal["spirit shield health"] = { "TechShieldMaxHealth", "TechShieldOnCast", "SaviorMagicShieldHealth", "FlyingTechShield", "VexBarrierTechMaxHealth" }
friendly_to_internal["bullet resist"] = { "BulletResist", "LocalBulletArmorReduction", "ReturnFireBulletResist" }
friendly_to_internal["bullet resist"] = { "BulletResist", "LocalBulletArmorReduction", "ReturnFireBulletResist" }
friendly_to_internal["bullet resist reduction"] = { "BulletArmorReduction", "BulletResistReduction" }
friendly_to_internal["spirit resist"] = { "TechResist" }
friendly_to_internal["spirit resist"] = { "TechResist" }
friendly_to_internal["health"] = { "BonusHealth" }
friendly_to_internal["health"] = { "BonusHealth" }
Line 94: Line 94:
"TechResist", "BulletResist",
"TechResist", "BulletResist",
"BonusFireRate", "FireRateWhenShielded", "FervorFireRate", "FireRateBonus", "AmbushBonusFireRate", "ActiveBonusFireRate", "FireRateSlow",
"BonusFireRate", "FireRateWhenShielded", "FervorFireRate", "FireRateBonus", "AmbushBonusFireRate", "ActiveBonusFireRate", "FireRateSlow",
"LocalBulletArmorReduction", "ReturnFireBulletResist",
"LocalBulletArmorReduction", "ReturnFireBulletResist", "BulletArmorReduction", "BulletResistReduction",
"BonusBulletSpeedPercent",
"BonusBulletSpeedPercent",
"StaminaCooldownReduction" },
"StaminaCooldownReduction" },
Line 122: Line 122:
         return get_cost(a["Name"]) * sortByWeapon[a["Slot"]] < get_cost(b["Name"]) * sortByWeapon[b["Slot"]]
         return get_cost(a["Name"]) * sortByWeapon[a["Slot"]] < get_cost(b["Name"]) * sortByWeapon[b["Slot"]]
     end
     end
end
-- Formats the value of the stat with a + or -
-- @function  signPrefix
-- @param      {string}
-- @return    {string}
local function signPrefix(value)
local signString = ""
value = tonumber(value)
if (value > 0) then
return "+<b>" .. value .. "</b>"
elseif (value < 0) then
value = math.abs(value)
return "-<b>" .. value .. "</b>"
end
end
end


Line 129: Line 144:
-- @return    {string}
-- @return    {string}
p.itemPropTable = function(frame)
p.itemPropTable = function(frame)
local TableValues = {}
local requirements = {}
local requirements = {}
local listofKeysTable = {}
local listofKeysTable = {}
Line 153: Line 167:
createTable:node(createTableHeader)
createTable:node(createTableHeader)
-- query the filtered items
-- query all the filtered items. itemName is the item table.
for internalName, itemName in ipairs(filteredData) do --itemName is the item table. go through whole table.
for internalName, itemName in ipairs(filteredData) do  


local display = frame:expandTemplate{
local display = frame:expandTemplate{
Line 162: Line 176:
}
}
}
}
local soulIcon = frame:expandTemplate{ title = 'Souls' }
for k, t in pairs(listofKeysTable) do
for k, t in pairs(listofKeysTable) do
Line 172: Line 187:
tableData
tableData
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(commas._add(get_cost(itemName["Name"]))):done()
:tag('td'):wikitext(soulIcon .. commas._add(get_cost(itemName["Name"]))):done()
:tag('td'):wikitext(get_type(itemName["Name"])):done()
:tag('td'):wikitext(get_type(itemName["Name"])):done()
if (tonumber(itemName[t]) < 0) then  
if (t == "LocalBulletArmorReduction") then  
tableData
tableData
:tag('td'):wikitext("<span style=\"color:red;\"><b>" .. itemName[t].. "</b>" .. appendSuffix(t) .. "</span> " .. copyVar):done()
:tag('td'):wikitext("<span style=\"color:red;\">" .. signPrefix(itemName[t]) .. appendSuffix(t) .. "</span> " .. copyVar):done()
else
else
tableData
tableData
:tag('td'):wikitext("+<b>" .. itemName[t].. "</b>" .. appendSuffix(t) .. " " .. copyVar):done()
:tag('td'):wikitext(signPrefix(itemName[t]) .. appendSuffix(t) .. "</span> " .. copyVar):done()
end
end
table.insert(requirements, tableData)
table.insert(requirements, tableData)
-- TableValues = table.insert(TableValues, itemName["Name"]) -- i may want to make a table first, so it includes weapon and cost to make it sortable.
end
end
end
end
Line 195: Line 209:
return tostring(createTable)
return tostring(createTable)
--return listofItems -- this is just a string list, same thing as createTable. delete this when line when finished
--return listofItems -- this is just a string list, same thing as createTable. delete this when line when finished
--return table.concat(TableValues, ", ")


end
end


return p
return p