I am trying to create a "catchall" function to get stats (either average them all, get the best stats without mods, or with mods. I would kile to default the booleans in the function. Any idea about this ?
Code: Select all
function getPartyStat(stat,baseStat=true,average=false)
local finalStat = 0
local a = {}
local p = party.party
local finalAverage = 0
local c = p:getChampion(i)
if baseStat then
local statToRecover = c:getBaseStat(stat)
elseif baseStat == false then
local statToRecover = c:getCurrentStat(stat)
end
end
if average == false then
for i = 1,4 do
c = p:getChampion(i)
if c:getEnabled() and c:isAlive() and statToRecover > finalStat
then finalStat = c:getCurrentStat(stat)
end
end
elseif
for i=1, 4 do
if c:getEnabled() and c:isAlive() then
finalAverage = finalAverage+statToRecover
table.insert(a,i)
end
finalStat = (finalAverage / #a)
end
end
return finalStat
end