Module:Sandbox/LVL: Difference between revisions

LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 20: Line 20:
Yamato = {base = 63.36, level = 0.35, suffix = "alt fire AOE"}
Yamato = {base = 63.36, level = 0.35, suffix = "alt fire AOE"}
}
}
-- A helper function that returns a sort-friendly version of a name by removing leading articles.
local function get_sortable_name(name)
if string.sub(name, 1, 4) == "The " then
return string.sub(name, 5)
end
return name
end


--[[
--[[
Line 65: Line 73:
end
end
-- Sort the hero list alphabetically by name for consistent ordering.
-- Sort the hero list alphabetically, ignoring "The " for proper sorting.
table.sort(filtered_heroes, function(a, b)
table.sort(filtered_heroes, function(a, b)
return a.Name < b.Name
return get_sortable_name(a.Name) < get_sortable_name(b.Name)
end)
end)
Line 232: Line 240:
--]]
--]]
p.write_multishot_stats = function(frame)
p.write_multishot_stats = function(frame)
-- Use the same smart sorting for this list.
local function hero_sort(h1, h2)  
local function hero_sort(h1, h2)  
return h1["Name"] < h2["Name"]
return get_sortable_name(h1.Name) < get_sortable_name(h2.Name)
end
end
local spreadshot_heroes = {}
local spreadshot_heroes = {}
Line 254: Line 263:
local shots = hero["BulletsPerShot"]
local shots = hero["BulletsPerShot"]
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "  
.. base .. "/pellet, +" .. level .. "/pellet\n"
-- Checks for the special property and changes the output text accordingly.
local stat_str
if hero["HitOnceAcrossAllBullets"] then
stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "  
.. base .. " total damage (hits only once), +" .. level .. " total\n"
else
stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, "
.. base .. "/pellet, +" .. level .. "/pellet\n"
end
multishot_str = multishot_str .. stat_str
multishot_str = multishot_str .. stat_str
end
end