Module:BTD6 stats: Difference between revisions
mNo edit summary |
saving progress |
||
| Line 20: | Line 20: | ||
subtowers ="BTD6 tower" | subtowers ="BTD6 tower" | ||
} | } | ||
local function parse_beast_table(data, tiers) | |||
local ret = {"\n{|class='wikitable mw-collapsible mw-collapsed'\n|+style='white-space:nowrap'|Beast Power-dependent stats"} | |||
-- local functions to improve performance | |||
local tinsert = table.insert | |||
local tconcat = table.concat | |||
local sformat = string.format | |||
local msqrt = math.sqrt | |||
local mfloor = math.floor | |||
-- -- -- -- -- -- | |||
-- CREATE HEADING | |||
-- -- -- -- -- -- | |||
local headingUpper = {} | |||
local upperColspans = {} | |||
local headingLower = {} | |||
local headingEffects = function(effects) | |||
for i, v in ipairs(effects["_order"]) do | |||
local effect = effects[v] | |||
local amount = 0 | |||
if effect["lifespan"]~=nil then tinsert(headingLower, "Lifespan") amount = amount + 1 end | |||
if amount > 0 then | |||
tinsert(headingUpper, v) | |||
tinsert(upperColspans, amount) | |||
end | |||
end | |||
end | |||
local headingProjectiles = function(projectiles) | |||
for i, v in ipairs(projectiles["_order"]) do | |||
local projectile = projectiles[v] | |||
local amount = 0 | |||
if projectile["maxPierce"]<1 and projectile["pierce"]<99999 then tinsert(headingLower, "Pierce") amount = amount + 1 end | |||
if projectile["damage"]~=nil and projectile["damage"]>0 then tinsert(headingLower, "Damage") amount = amount + 1 end | |||
if projectile["damageModifierForStunned"]~=nil then tinsert(headingLower, "Damage to stunned") amount = amount + 1 end | |||
if amount > 0 then | |||
tinsert(headingUpper, v) | |||
tinsert(upperColspans, amount) | |||
end | |||
end | |||
end | |||
local headingAttacks = function(attacks) | |||
for i, v in ipairs(attacks["_order"]) do | |||
local attack = attacks[v] | |||
local amount = 0 | |||
if attack["rate"] then tinsert(headingLower, "Cooldown") amount = amount + 1 end | |||
if attack["initialDamage"] and attack["initialDamage"] ~= 0 then tinsert(headingLower, "Scratch damage") amount = amount + 1 end | |||
if attack["grapplingDamage"] and attack["grapplingDamage"] ~= 0 then tinsert(headingLower, "Grappling damage") amount = amount + 1 end | |||
if amount > 0 then | |||
tinsert(headingUpper, v) | |||
tinsert(upperColspans, amount) | |||
end | |||
-- projectiles | |||
if attack["projectiles"] ~= nil then headingProjectiles(attack["projectiles"]) end | |||
end | |||
end | |||
local minPower = { | |||
["_002"] = 3, | |||
["_003"] = 8, | |||
["_004"] = 16, | |||
["_005"] = 36, | |||
["_020"] = 3, | |||
["_030"] = 8, | |||
["_040"] = 16, | |||
["_050"] = 36, | |||
["_200"] = 3, | |||
["_300"] = 8, | |||
["_400"] = 16, | |||
["_500"] = 36 | |||
} | |||
local maxPower = { | |||
["_200"] = 6, | |||
["_300"] = 24, | |||
["_400"] = 64, | |||
["_500"] = 132, | |||
["_020"] = 6, | |||
["_030"] = 24, | |||
["_040"] = 64, | |||
["_050"] = 132, | |||
["_002"] = 6, | |||
["_003"] = 24, | |||
["_004"] = 64, | |||
["_005"] = 132 | |||
} | |||
-- insert headings | |||
if data["attacks"] then headingAttacks(data["attacks"]) end | |||
if data["abilities"] then | |||
for i, v in ipairs(abils["_order"]) do | |||
if abils[v]["projectiles"] then headingProjectiles(abils[v]["projectiles"]) end | |||
end | |||
end | |||
tinsert(ret, "!rowspan=2|Power") | |||
for i, v in ipairs(headingUpper) do | |||
tinsert(ret, sformat("!colspan=%i|%s", upper_colspans[i], v)) | |||
end | |||
tinsert(ret, "|-\n!" .. table.concat(heading_lower, "!!")) | |||
for i = minPower[tiers], maxPower[tiers] do | |||
local scale = ((i - minPower[tiers]) / (maxPower[tiers] - minPower[tiers])) | |||
end | |||
tinsert(ret, "|}") | |||
return table.concat(ret, "\n") | |||
end | |||
function parse_paragon_table(data) | function parse_paragon_table(data) | ||
| Line 572: | Line 692: | ||
for i, v in ipairs(upgrade_crosspaths[frame.args[2]]) do | for i, v in ipairs(upgrade_crosspaths[frame.args[2]]) do | ||
local result = parse_tower(frame, base_data, my_data, "<h3>%s</h3>", false) | local result = parse_tower(frame, base_data, my_data, "<h3>%s</h3>", false) | ||
-- inject beast handler stats table | |||
if frame.args[1] == "Beast Handler" and not (frame.args[2] == "_000" or frame.args[2] == "_100" or frame.args[2] == "_010" or frame.args[2] == "_001") then | |||
result = result .. parse_beast_table(base_data, frame.args[2]) | |||
end | |||
if i == 1 then tinsert(ret, result) end | if i == 1 then tinsert(ret, result) end | ||
for ii, vv in ipairs(v) do | for ii, vv in ipairs(v) do | ||