Module:ItemTables: Difference between revisions

cap first letter, fix spacing
add more keys, add unit suffix
Line 55: Line 55:
-- end
-- end


local internal_to_friendly = {}
local friendly_to_internal = {}
internal_to_friendly["ammo"] = { "BonusClipSizePercent", "BonusClipSize" }
friendly_to_internal["ammo"] = { "BonusClipSizePercent", "BonusClipSize" }
internal_to_friendly["weapon damage"] = { "BaseAttackDamagePercent" }
friendly_to_internal["weapon damage"] = { "BaseAttackDamagePercent" }
internal_to_friendly["bullet shield health"] = { "BulletShieldMaxHealth", "BulletShieldOnCast", "SaviorBulletShieldHealth", "FlyingBulletShield" }
friendly_to_internal["bullet shield health"] = { "BulletShieldMaxHealth", "BulletShieldOnCast", "SaviorBulletShieldHealth", "FlyingBulletShield" }
internal_to_friendly["spirit shield health"] = { "TechShieldMaxHealth", "TechShieldOnCast", "SaviorMagicShieldHealth", "FlyingTechShield" }
friendly_to_internal["spirit shield health"] = { "TechShieldMaxHealth", "TechShieldOnCast", "SaviorMagicShieldHealth", "FlyingTechShield" }
internal_to_friendly["health"] = { "BonusHealth" }
friendly_to_internal["spirit resist"] = { "TechResist" }
internal_to_friendly["health regen"] = { "BonusHealthRegen" }
friendly_to_internal["bullet resist"] = { "BulletResist" }
internal_to_friendly["fire rate"] = { "BonusFireRate" }
friendly_to_internal["health"] = { "BonusHealth" }
internal_to_friendly["stamina"] = { "Stamina" }
friendly_to_internal["health regen"] = { "BonusHealthRegen" }
friendly_to_internal["fire rate"] = { "BonusFireRate" }
friendly_to_internal["stamina"] = { "Stamina" }
friendly_to_internal["stamina recovery"] = { "StaminaCooldownReduction" }


function amicableNames(desc)
local function friendlyNames(desc)
local keysTable = {}
local keysTable = {}
desc = string.lower(desc or "")
desc = string.lower(desc or "")
for link, patterns in pairs(internal_to_friendly) do
for link, patterns in pairs(friendly_to_internal) do
if (desc == link) then keysTable = patterns end  
if (desc == link) then keysTable = patterns end  
end
end
return keysTable
return keysTable
end
end
local unitSuffix = {
["%"] = { "BonusClipSizePercent", "BaseAttackDamagePercent", "TechResist", "BulletResist", "BonusFireRate", "StaminaCooldownReduction" },
["m/s"] = { "BonusMoveSpeed" }
}
local function appendSuffix(internal)
local unitName = ""
for key, s in pairs(unitSuffix) do
for link, pattern in pairs(s) do
if (internal == pattern) then return key end
end
end
return unitName
end


p.itemPropTable = function(frame)
p.itemPropTable = function(frame)
Line 81: Line 100:
local property = frame.args[1] or mw.title.getCurrentTitle().text
local property = frame.args[1] or mw.title.getCurrentTitle().text
local copyVar = property
local copyVar = property
listofKeysTable = amicableNames(property) -- need to switch this around from value to key, to key to values
listofKeysTable = friendlyNames(property)  
local createTable = mw.html.create('table')
local createTable = mw.html.create('table')
Line 117: Line 136:
:tag('td'):wikitext(get_cost(itemName["Name"])):done()
:tag('td'):wikitext(get_cost(itemName["Name"])):done()
:tag('td'):wikitext(get_type(itemName["Name"])):done()
:tag('td'):wikitext(get_type(itemName["Name"])):done()
:tag('td'):wikitext("+<b>" .. itemName[t].. "</b> " .. copyVar):done()
:tag('td'):wikitext("+<b>" .. itemName[t].. "</b>" .. appendSuffix(t) .. " " .. copyVar):done()
table.insert(requirements, tableData)
table.insert(requirements, tableData)