• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Difference between revisions of "Module:CalcFit"

From Kancolle Wiki
Jump to navigation Jump to search
m (がか moved page Module:Module:Calc/Plugins/FitData to Module:Calc/Plugins/FitData without leaving a redirect)
m
Line 18: Line 18:
 
         if context.hit_rate then
 
         if context.hit_rate then
 
             local diff = 100 * (context.cl1 + context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.hit_rate
 
             local diff = 100 * (context.cl1 + context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.hit_rate
 +
            return string.format("%.2f%%", diff)
 +
        else
 +
            return "nil"
 +
        end
 +
    end,
 +
 +
    critical_difference = function(context)
 +
        if context.critical_hit_rate then
 +
            local diff = 100 * (context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.critical_hit_rate
 
             return string.format("%.2f%%", diff)
 
             return string.format("%.2f%%", diff)
 
         else
 
         else

Revision as of 13:59, 7 November 2017

Documentation for this module may be created at Module:CalcFit/doc

local Stat = require("Module:Stat")

return {

    hit = function(context)
        return Stat.rate({ args = { context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2 } }) .. "%"
    end,

    crit = function(context)
        return Stat.rate({ args = { context.cl2, context.cl0 + context.cl1 + context.cl2 } }) .. "%"
    end,

    error = function(context)
        return Stat.error({ args = { context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2 } }) .. "%"
    end,

    difference = function(context)
        if context.hit_rate then
            local diff = 100 * (context.cl1 + context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.hit_rate
            return string.format("%.2f%%", diff)
        else
            return "nil"
        end
    end,

    critical_difference = function(context)
        if context.critical_hit_rate then
            local diff = 100 * (context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.critical_hit_rate
            return string.format("%.2f%%", diff)
        else
            return "nil"
        end
    end,

}