Editing Module:LevelTablesGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
local p = {}; | local p = {}; | ||
-- Loads the necessary data from the wiki's JSON pages. | -- Loads the necessary data from the wiki's JSON pages. | ||
local heroes_data = mw.loadJsonData("Data:HeroData.json") | local heroes_data = mw.loadJsonData("Data:HeroData.json") | ||
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | ||
-- Defines human-readable names for the internal property keys used in headers. | -- Defines human-readable names for the internal property keys used in headers. | ||
| Line 22: | Line 12: | ||
LightMeleeDamage = "Light Melee Damage", | LightMeleeDamage = "Light Melee Damage", | ||
HeavyMeleeDamage = "Heavy Melee Damage" | HeavyMeleeDamage = "Heavy Melee Damage" | ||
} | |||
-- Provides data for special alternate fire modes that are not present in HeroData.json. | |||
local alt_fires = { | |||
Shiv = {base = 55.2, level = 2.64, suffix = "alt fire 12 pellets"}, | |||
Viscous = {base = 63, level = 0.9, suffix = "alt fire AOE"}, | |||
Yamato = {base = 63.36, level = 0.35, suffix = "alt fire AOE"} | |||
} | } | ||
| Line 43: | Line 40: | ||
--]] | --]] | ||
p.write_power_increase_table = function(frame) | p.write_power_increase_table = function(frame) | ||
-- Read and validate the arguments passed from the #invoke call. | -- Read and validate the arguments passed from the #invoke call. | ||
local property = frame.args[1] | local property = frame.args[1] | ||
| Line 68: | Line 61: | ||
end | end | ||
end | end | ||
local max_boons = #pi_souls_list | |||
-- Define the milestones to display in the summary table. | -- Define the milestones to display in the summary table. | ||
local milestones = {10, 20, max_boons} | local milestones = {10, 20, max_boons} | ||
| Line 77: | Line 69: | ||
local filtered_heroes = {} | local filtered_heroes = {} | ||
for _, hero in pairs(heroes_data) do | for _, hero in pairs(heroes_data) do | ||
if (not hero["IsDisabled | if (not hero["IsDisabled"]) then | ||
table.insert(filtered_heroes, hero) | table.insert(filtered_heroes, hero) | ||
end | end | ||
| Line 83: | Line 75: | ||
-- Sort the hero list alphabetically, ignoring "The " for proper sorting. | -- Sort the hero list alphabetically, ignoring "The " for proper sorting. | ||
table.sort(filtered_heroes, | table.sort(filtered_heroes, function(a, b) | ||
return get_sortable_name(a.Name) < get_sortable_name(b.Name) | |||
end) | |||
-- Begin building the main data table. | -- Begin building the main data table. | ||
| Line 101: | Line 95: | ||
local required_souls = pi_souls_list[count] | local required_souls = pi_souls_list[count] | ||
local souls_formatted = string.format("%.1fK", (required_souls + 400) / 1000) | local souls_formatted = string.format("%.1fK", (required_souls + 400) / 1000) | ||
local soul_display = | local soul_display = frame:expandTemplate{ title = "Souls", args = {souls_formatted} } | ||
local full_header = header_text .. "<br /><small>(" .. soul_display .. ")</small>" | local full_header = header_text .. "<br /><small>(" .. soul_display .. ")</small>" | ||
header_row:tag("th"):wikitext(full_header):done() | header_row:tag("th"):wikitext(full_header):done() | ||
| Line 112: | Line 106: | ||
local function addHeroRows(hero_data, is_alt_fire) | local function addHeroRows(hero_data, is_alt_fire) | ||
local base, level, suffix | local base, level, suffix | ||
local hero_icon_wikitext = | local hero_icon_wikitext = frame:expandTemplate{ title = "HeroIcon", args = {hero_data["Name"]}} | ||
-- Determine if this is a main weapon or an alt-fire and set the correct data. | -- Determine if this is a main weapon or an alt-fire and set the correct data. | ||
| Line 120: | Line 114: | ||
suffix = " (" .. hero_data.alt_fire.suffix .. ")" | suffix = " (" .. hero_data.alt_fire.suffix .. ")" | ||
else | else | ||
base = | base = (hero_data[property] or 0) | ||
level = (hero_data["LevelScaling"] and hero_data["LevelScaling"][property] or 0) | level = (hero_data["LevelScaling"] and hero_data["LevelScaling"][property] or 0) | ||
suffix = "" | suffix = "" | ||
local shots = | local shots = (hero_data["BulletsPerShot"] or 1) | ||
local burst = (hero_data["BulletsPerBurst"] or 1) | |||
local burst = | |||
if (property == "BulletDamage" and (shots * burst) > 1) then | if (property == "BulletDamage" and (shots * burst) > 1) then | ||
if (not | if (not hero_data["HitOnceAcrossAllBullets"]) then | ||
base = base * shots * burst | base = base * shots * burst | ||
level = level * shots * burst | level = level * shots * burst | ||
| Line 179: | Line 169: | ||
local required_souls = pi_souls_list[i] | local required_souls = pi_souls_list[i] | ||
local souls_formatted = string.format("%.1fK", (required_souls + 400) / 1000) | local souls_formatted = string.format("%.1fK", (required_souls + 400) / 1000) | ||
local soul_display = Souls | local soul_display = frame:expandTemplate{ title = "Souls", args = {souls_formatted} } | ||
local row_html = string.format("<tr><td>%s</td><td style='text-align:right;'>%.2f</td></tr>", soul_display, total) | local row_html = string.format("<tr><td>%s</td><td style='text-align:right;'>%.2f</td></tr>", soul_display, total) | ||
| Line 209: | Line 199: | ||
for _, hero in ipairs(filtered_heroes) do | for _, hero in ipairs(filtered_heroes) do | ||
addHeroRows(hero, false) | addHeroRows(hero, false) | ||
if (property == "BulletDamage" and alt_fires[hero["Name"]] ~= nil) then | |||
local alt_fire_hero_data = { | |||
if (property == "BulletDamage" and hero | Name = hero.Name, | ||
alt_fire = alt_fires[hero.Name] | |||
} | |||
addHeroRows(alt_fire_hero_data, true) | |||
end | end | ||
end | end | ||
| Line 292: | Line 248: | ||
local burst_heroes = {} | local burst_heroes = {} | ||
for _, hero in pairs(heroes_data) do | for _, hero in pairs(heroes_data) do | ||
if ((hero["BulletsPerShot"] or 1) > 1 and not hero["IsDisabled"]) then | |||
table.insert(spreadshot_heroes, hero) | table.insert(spreadshot_heroes, hero) | ||
elseif ( | elseif ((hero["BulletsPerBurst"] or 1) > 1 and not hero["IsDisabled"]) then | ||
table.insert(burst_heroes, hero) | table.insert(burst_heroes, hero) | ||
end | end | ||
| Line 307: | Line 260: | ||
local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n" | local multishot_str = "Weapons with multiple projectiles (Spreadshot):\n" | ||
for _, hero in ipairs(spreadshot_heroes) do | for _, hero in ipairs(spreadshot_heroes) do | ||
local base = math.floor | local base = math.floor(hero["BulletDamage"] * 100) / 100 | ||
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | ||
local shots = | local shots = hero["BulletsPerShot"] | ||
local | local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | ||
-- Checks for the special property and changes the output text accordingly. | -- Checks for the special property and changes the output text accordingly. | ||
local stat_str | local stat_str | ||
if | if hero["HitOnceAcrossAllBullets"] then | ||
stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, " | stat_str = "* " .. hero_icon .. ": " .. shots .. " pellets, " | ||
.. base .. " total damage (hits only once), +" .. level .. " total\n" | .. base .. " total damage (hits only once), +" .. level .. " total\n" | ||
| Line 327: | Line 279: | ||
multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n" | multishot_str = multishot_str .. "Weapons with burst fire (Burst Fire):\n" | ||
for _, hero in ipairs(burst_heroes) do | for _, hero in ipairs(burst_heroes) do | ||
local base = math.floor | local base = math.floor(hero["BulletDamage"] * 100) / 100 | ||
local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | local level = math.floor(hero["LevelScaling"]["BulletDamage"] * 100) / 100 | ||
local shots = | local shots = hero["BulletsPerBurst"] | ||
local hero_icon = | local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}} | ||
local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, " | local stat_str = "* " .. hero_icon .. ": " .. shots .. " rounds, " | ||
.. base .. "/bullet, +" .. level .. "/bullet\n" | .. base .. "/bullet, +" .. level .. "/bullet\n" | ||