Module:AbilityTable/ComplexRenderers: Difference between revisionsGive feedback
rename val_stat_cells to render_upgradable_stat, simplify RenderHealReduce to use it, fix Lists.props to Lists.lists (with help from vergir-bot LLM) |
update renderer comments, remove unused GameData require, extract find_base_melee_scale to module level (with help from vergir-bot LLM) |
||
| Line 1: | Line 1: | ||
-- Complex cell renderers for AbilityTable. | -- Complex cell renderers for AbilityTable. | ||
local Lists | local Lists = require("Module:AbilityTable/Lists") | ||
-- ============================================================ | -- ============================================================ | ||
| Line 66: | Line 65: | ||
end | end | ||
return false | return false | ||
end | |||
-- Finds the base-level melee scale value by scanning for Scale.Type == "melee". | |||
local function find_base_melee_scale(ability) | |||
for _, v in pairs(ability) do | |||
if type(v) == "table" then | |||
local scale = v["Scale"] | |||
if type(scale) == "table" | |||
and scale["Type"] == "melee" | |||
and type(scale["Value"]) == "number" | |||
and scale["Value"] > 0 | |||
then | |||
return scale["Value"] | |||
end | |||
end | |||
end | |||
return nil | |||
end | end | ||
| Line 154: | Line 170: | ||
local p = {} | local p = {} | ||
-- | -- Renders charge count and time between charges. | ||
-- Special case for abilities that gain charges only through upgrades. | |||
function p.RenderCharges(ability) | function p.RenderCharges(ability) | ||
local base_charges = unwrap_value(ability["AbilityCharges"]) | local base_charges = unwrap_value(ability["AbilityCharges"]) | ||
| Line 206: | Line 223: | ||
end | end | ||
-- | -- Renders light melee scaling. | ||
-- Special case for upgrades that change to heavy melee scaling. | |||
function p.RenderMelee(ability) | function p.RenderMelee(ability) | ||
local cells = {} | local cells = {} | ||
local base_scale = find_base_melee_scale(ability) | local base_scale = find_base_melee_scale(ability) | ||
| Line 256: | Line 258: | ||
end | end | ||
-- | -- Renders heal reduction percentage. | ||
-- Special case for DisableHealing, shown as 100%. | |||
function p.RenderHealReduce(ability) | function p.RenderHealReduce(ability) | ||
-- DisableHealing is always 100%, handle it separately | -- DisableHealing is always 100%, handle it separately | ||
| Line 276: | Line 279: | ||
end | end | ||
-- | -- Shows a note if an ability acquires a debuff via upgrades. | ||
-- Shared by debuffresist and dispelmagic. | |||
function p.RenderDebuff(ability, stat) | function p.RenderDebuff(ability, stat) | ||
local stat_props = Lists.lists[stat] | local stat_props = Lists.lists[stat] | ||
| Line 334: | Line 337: | ||
end | end | ||
-- | -- Renders move slow percentage. | ||
-- Appends a note if the ability also self-slows the caster. | |||
function p.RenderMoveSlow(ability) | function p.RenderMoveSlow(ability) | ||
local cells = render_upgradable_stat(ability, "Move Slow", Lists.lists["moveslow"], "%") | local cells = render_upgradable_stat(ability, "Move Slow", Lists.lists["moveslow"], "%") | ||
| Line 347: | Line 351: | ||
end | end | ||
-- | -- Renders dash slow percentage. | ||
-- Special case for GroundDashReductionPercent coexisting with another dashslow | |||
-- prop, which means it's a caster self-slow and is noted separately. | |||
function p.RenderDashSlow(ability) | function p.RenderDashSlow(ability) | ||
local stat_props = Lists.lists["dashslow"] | local stat_props = Lists.lists["dashslow"] | ||