• 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
Line 38: Line 38:
 
         if accuracy_value_1 and accuracy_value_3 then
 
         if accuracy_value_1 and accuracy_value_3 then
 
             return string.format('<span class="explain" title="Before fit: %.2f%%">%d%%</span>', accuracy_value_1, math.floor(accuracy_value_3))
 
             return string.format('<span class="explain" title="Before fit: %.2f%%">%d%%</span>', accuracy_value_1, math.floor(accuracy_value_3))
 +
        else
 +
            return "nil"
 +
        end
 +
    end,
 +
 +
    fit = function(ship, target, context)
 +
        context._ng = ship._ng
 +
        context._ci, context._hit_rate = Stat.error_(context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2)
 +
        local fit, min_fit, max_fit = Combat2.find_fit(ship, target, context)
 +
        if fit and min_fit and max_fit then
 +
            return string.format('<span class="explain" title="%d ~ %d">%d</span>', min_fit, max_fit, fit)
 
         else
 
         else
 
             return "nil"
 
             return "nil"

Revision as of 19:01, 9 November 2017

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

local Stat = require("Module:Stat")
local Combat2 = require("Module:Combat2")

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,

    accuracy_value = function(ship, target)
        local accuracy_value_1, _, accuracy_value_3 = Combat2.accuracy_value(ship, target)
        if accuracy_value_1 and accuracy_value_3 then
            return string.format('<span class="explain" title="Before fit: %.2f%%">%d%%</span>', accuracy_value_1, math.floor(accuracy_value_3))
        else
            return "nil"
        end
    end,

    fit = function(ship, target, context)
        context._ng = ship._ng
        context._ci, context._hit_rate = Stat.error_(context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2)
        local fit, min_fit, max_fit = Combat2.find_fit(ship, target, context)
        if fit and min_fit and max_fit then
            return string.format('<span class="explain" title="%d ~ %d">%d</span>', min_fit, max_fit, fit)
        else
            return "nil"
        end
    end,

}