Module:Damage: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 53: Line 53:
         avg_useful = 0
         avg_useful = 0
     }
     }
    local i = 1
     local vars = {}
     local vars = {}
     for k,v in spairs(args) do
 
        function getTotal(arg, dmg, hits, fval)
     function getTotal(arg, dmg, hits, fval)
        local i = 1
        for k,v in spairs(args) do
             if string.starts(k, arg) then
             if string.starts(k, arg) then
                 fvals[fval] = fvals[fval] + args[dmg .. i] * args[hits .. i]
                 fvals[fval] = fvals[fval] + args[dmg .. i] * args[hits .. i]
Line 62: Line 63:
             end
             end
         end
         end
    end


        -- getTotal('dmg', 'dmg', 'hits', 'total')
    for k,v in spairs(args) do
        getTotal('hits_useful', 'dmg', 'hits_useful', 'total_useful')
         -- -- total damage only
         -- -- total damage only
         -- if string.starts(k, 'dmg') then
         -- if string.starts(k, 'dmg') then
Line 75: Line 76:
         -- end
         -- end
     end
     end
    getTotal('dmg', 'dmg', 'hits', 'total')
    getTotal('hits_useful', 'dmg', 'hits_useful', 'total_useful')
     table.insert(vars, var('total_damage', fvals.total))
     table.insert(vars, var('total_damage', fvals.total))
     if inArgs('useful_penalty') then
     if inArgs('useful_penalty') then