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

Module:NanaminFunctions

From Kancolle Wiki
Revision as of 01:32, 23 April 2015 by Nanamin (talk | contribs)
Jump to navigation Jump to search

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

local NanaminFunctions = {}

function NanaminFunctions.split(haystack, needle)
    local result = {}
    while mw.ustring.find(haystack, needle) do
        local split = mw.ustring.find(haystack, needle)
        table.insert(result, mw.ustring.sub(haystack, 1, split - 1))
        haystack = mw.ustring.sub(haystack, split + 1)
    end
    table.insert(result, haystack)
    return result
end

function NanaminFunctions.add_to_fighter_power(current_fp, equip, planes)
    --Only fighter planes, dive bombers, torpedo bombers and seaplane bombers with an AA stat are counted
    local types_allowed = { [6] = true, [7] = true, [8] = true, [11] = true }
    if types_allowed[equip:type()] and equip:aa() then
        current_fp = current_fp + math.floor(math.sqrt(planes) * equip:aa())
    end
    return current_fp
end

function NanaminFunctions.add_to_elos_ship(current_elos, ship)
    local los = ship:los() or 0
    local los_max = ship:los_max() or los
    los = math.floor(los + ((los_max - los) * tonumber(entry[3]) / 99))
    return current_elos + math.sqrt(los) * 1.69
end

function NanaminFunctions.add_to_elos(current_elos, equip)
    --[[Effective LoS = Dive Bomber LoS x (1.04) + Torpedo Bomber LoS x (1.37)
    + Carrier-based Recon Plane LoS x (1.66) + Recon Seaplane LoS x (2.00)
    + Seaplane Bomber LoS x (1.78) + Small Radar LoS x (1.00) + Large Radar LoS x (0.99)
    + Searchlight LoS x (0.91) + √(base LoS of each ship) * (1.69)
    + (HQ Lv. rounded up to the next multiple of 5) x (-0.61)--]]
    local multiplier = { [7] = 1.04, [8] = 1.04, [9] = 1.66, [10] = 2.00, [11] = 1.78, [12] = 1.00, [13] = 0.99, [29] = 0.91 }
    if multiplier[equip:type()] ~= nil and equip:los() then
        current_elos = current_elos + (equip:los() * multiplier[equip:type()])
    end
    return current_elos
end

function NanaminFunctions.get_hq_bracket(hq_level)
    local bracket = tonumber(hq_level or 0)
 
    --Get bracket of 5
    bracket = bracket - (bracket % 5) + 5
    if tonumber(hq_level or 0) % 5 == 0 then
        bracket = bracket + 5
    end
    
    return bracket
end

return NanaminFunctions