Module:CreatureStats

local p = {}

local function checkFlag(args, flag) return args[flag] and string.lower(args[flag]) == 'yes' end

local Strings = { ["Attribute"] = "Attribute", ["BaseValue"] = "Base Value", ["BaseValueNote"] = "The value of the Attribute at level 1.", ["LevelIncrease"] = "Level Increase", ["TamingBonus"] = "Taming Bonus", ["Tamed"] = "Tamed", ["TamedNote"] = "These percentages are based on the value of the Attribute at the moment the Creature was tamed.", } local Stats = { { "health",    "Health" }, { "stamina",   "Stamina" }, { "oxygen",    function(creature, args) if creature == 'Tek Stryder' then return 'Tek Stryder#Charge Capacity|Charge Capacity|image=Oxygen.png' elseif checkFlag(args, 'canBeCharged') then return 'Charge Regeneration' end return "Oxygen" end }, { "food",      function(creature, args) if checkFlag(args, 'eatsEnergy') then return 'Energy' end return 'Food' end }, }

local function renderStatRow(statId, name, args) local base = args[name .. '1']   local incW = args[name .. 'IncW'] local incD = args[name .. 'IncD'] local tameAdd = args[name .. 'TamingBonusAdd'] local tameMul = args[name .. 'TamingBonusMult']

local out = ''

if base == 'N/A' then return out .. ' || N/A || N/A || N/A || ||' end end

function p.main(frame) local args = frame:getParent.args local creature = frame.args[1] local noAutoCategories = frame.args.noAutoCategories == '1'

if not creature then return 'error: first argument to Module:CreatureStats must be a creature name' end

local shouldShowTamed = false for _, stat in ipairs(Stats) do       local stat = stat[1] local incD = args[stat .. 'IncD'] local tameAdd = args[name .. 'TamingBonusAdd'] local tameMul = args[name .. 'TamingBonusMult'] if (incD and incD ~= 'N/A') or (tameAdd and tameAdd ~= 'N/A') or (tameMul and tameMul ~= 'N/A') then shouldShowTamed = true break end end

local out =  .. Strings.Attribute .. ! colspan= .. (shouldShowTamed and '2' or '1') .. | .. Strings.LevelIncrease .. .. (shouldShowTamed and '!! colspan=2 | ' .. Strings.TamingBonus or '') .. ! Wild .. (   shouldShowTamed and    '|   Additive  Multiplicative' or    '') .. 

out = out .. '|}'   return out end

return p