Module:ItemTables: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Gammaton32 (talk | contribs) Added replacement string for legendary item costs |
Fixed Witchmail showing up in ability cooldown reduction by adding a dead stat override |
||
| Line 69: | Line 69: | ||
friendly_to_internal["dash distance"] = { "GroundDashReductionPercent", "AirMoveIncreasePercent" } | friendly_to_internal["dash distance"] = { "GroundDashReductionPercent", "AirMoveIncreasePercent" } | ||
friendly_to_internal["damage reduction"] = { "OutgoingDamagePenaltyPercent", "DeathImmunityDamageReduction" } | friendly_to_internal["damage reduction"] = { "OutgoingDamagePenaltyPercent", "DeathImmunityDamageReduction" } | ||
-- Override dead/hidden stats that exist in data but don't actually work in‑game. | |||
-- Keys are item Names, values are tables of { [internalStatName] = replacementValue } | |||
local deadStatOverrides = { | |||
["Witchmail"] = { CooldownReduction = "0" } | |||
} | |||
-- Helper to resolve a stat value, applying any dead‑stat override if defined. | |||
local function resolveStatValue(itemName, t) | |||
if deadStatOverrides[itemName.Name] and deadStatOverrides[itemName.Name][t] ~= nil then | |||
return deadStatOverrides[itemName.Name][t] | |||
end | |||
return itemName[t] | |||
end | |||
-- Returns a table of internal properties | -- Returns a table of internal properties | ||
| Line 178: | Line 192: | ||
for _, v in pairs(data) do | for _, v in pairs(data) do | ||
for _, t in ipairs(listofKeysTable) do | for _, t in ipairs(listofKeysTable) do | ||
local statValue = resolveStatValue(v, t) | |||
if statValue ~= nil and v["IsDisabled"] == false and v["Name"] ~= nil and statValue ~= "0" and statValue ~= "0m" and statValue ~= "" then | |||
table.insert(filteredData, v) | table.insert(filteredData, v) | ||
break | break | ||
| Line 204: | Line 219: | ||
local rowspanTracker = {} | local rowspanTracker = {} | ||
for _, itemName in ipairs(filteredData) do | for _, itemName in ipairs(filteredData) do | ||
local display = frame:expandTemplate{ | |||
title = 'ItemIcon', | |||
args = { itemName["Name"] } | |||
} | |||
local statCount = 0 | |||
for _, t in pairs(listofKeysTable) do | |||
local statVal = resolveStatValue(itemName, t) | |||
if(statVal ~= nil and statVal ~= "0") then | |||
statCount = statCount + 1 | |||
end | |||
end | end | ||
if statCount == 0 then statCount = 1 end | |||
rowspanTracker[itemName["Name"]] = statCount | |||
local firstStat = true | |||
for _, t in pairs(listofKeysTable) do | |||
local statValue = resolveStatValue(itemName, t) | |||
if(statValue ~= nil and statValue ~= "0") then | |||
-- Handles complex stat values from the JSON data. | -- Handles complex stat values from the JSON data. | ||
if type(statValue) == 'table' and statValue.Value ~= nil then | |||
statValue = statValue.Value | |||
end | |||
copyVar = copyVar:gsub("^%l", string.upper) | |||
local categoryDisplay | |||
if itemName["Slot"] == "Armor" then | |||
categoryDisplay = frame:expandTemplate{ | |||
title = 'ItemType', | |||
args = { "Armor", "Vitality" } | |||
} | |||
elseif itemName["Slot"] == "Tech" then | |||
categoryDisplay = frame:expandTemplate{ | |||
title = 'ItemType', | |||
args = { "Tech", "Spirit" } | |||
} | |||
else | |||
categoryDisplay = frame:expandTemplate{ | |||
title = 'ItemType', | |||
args = { "Weapon", "Weapon" } | |||
} | |||
end | |||
local tableData = mw.html.create('tr') | |||
if firstStat then | |||
tableData | |||
:tag('td'):attr('rowspan', statCount):wikitext(display):done() | |||
:tag('td'):attr('rowspan', statCount):wikitext( | |||
(get_cost(itemName["Name"]) == 9999) | |||
and "Legendary" | |||
or commas._add(get_cost(itemName["Name"])) | |||
):done() | |||
:tag('td'):attr('rowspan', statCount):wikitext(categoryDisplay):done() | |||
firstStat = false | |||
end | |||
tableData:tag('td'):wikitext(signPrefix(statValue) .. appendSuffix(t) .. " " .. copyVar):done() | |||
tableData | table.insert(requirements, tableData) | ||
end | end | ||
end | end | ||
end | end | ||
for _, row in ipairs(requirements) do | for _, row in ipairs(requirements) do | ||