- 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:NanaminFunctions"
Jump to navigation
Jump to search
m |
m |
||
Line 142: | Line 142: | ||
name = names[name] or name | name = names[name] or name | ||
return name | return name | ||
+ | end | ||
+ | |||
+ | function NanaminFunctions.shorten_name(name) | ||
+ | --This takes an equipment name listed on Sandbox/EquipmentListKai/TypeSorted | ||
+ | --and switches it with a shorter version of the name. | ||
+ | local shortened = { | ||
+ | ["Example"] = "Ex", | ||
+ | } | ||
+ | |||
+ | return shortened[name] or name | ||
end | end | ||
return NanaminFunctions | return NanaminFunctions |
Revision as of 12:56, 5 May 2015
Documentation for this module may be created at Module:NanaminFunctions/doc
local Ship = require("Module:Ship")
local NanaminFunctions = {}
function NanaminFunctions.split(haystack, needle)
local special_inputs = {
"381mm/50 Triple Gun Mount",
"381mm/50 Triple Gun Mount Kai",
}
local result = {}
while mw.ustring.find(haystack, needle) do
local split = mw.ustring.find(haystack, needle)
local input = mw.ustring.sub(haystack, 1, split - 1)
for _, value in pairs(special_inputs) do
if mw.ustring.sub(haystack, 1, #value) == value then
input = mw.ustring.sub(haystack, 1, #value)
haystack = mw.ustring.sub(haystack, split + 1)
split = mw.ustring.find(haystack, needle) or 0
break
end
end
table.insert(result, input)
haystack = mw.ustring.sub(haystack, split + 1)
if split == 0 then haystack = "" end
end
if haystack ~= "" then table.insert(result, haystack) end
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, entry, use_los)
if entry[3] == nil then return current_elos end
local ship = Ship(entry[1], entry[2])
local los = ship:los() or 0
local los_max = ship:los_max() or los
if use_los then
los = tonumber(entry[3])
else
los = math.floor(los + ((los_max - los) * tonumber(entry[3]) / 99))
end
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
function NanaminFunctions.process_legacy_name(name)
local names = {
["12cm Naval Gun"] = "12cm Single Gun Mount",
["12.7cm Naval Gun"] = "12.7cm Single Gun Mount",
["14cm Naval Gun"] = "14cm Single Gun Mount",
["15.5cm Triple Gun Mount (Main)"] = "15.5cm Triple Gun Mount",
["20.3cm(no.2) Twin Gun Mount"] = "20.3cm (No.2) Twin Gun Mount",
["20.3cm(no.3) Twin Gun Mount"] = "20.3cm (No.3) Twin Gun Mount",
["SKC34 20.3cm Twin Cannon"] = "SKC34 20.3cm Twin Gun Mount",
["Prototype 41cm Triple Cannon"] = "Prototype 41cm Triple Gun Mount",
["Prototype 51cm Twin Cannon"] = "Prototype 51cm Twin Gun Mount",
["15.2cm Naval Gun"] = "15.2cm Single Gun Mount",
["15.5cm Triple Gun Mount (Secondary)"] = "15.5cm Triple Secondary Gun Mount",
["15cm Twin Gun Mount"] = "15cm Twin Secondary Gun Mount",
["8cm Twin High-angle Mount"] = "8cm High-angle Gun",
["10cm Twin High-angle Mount"] = "10cm Twin High-angle Gun Mount",
["10cm Twin High-angle Gun Mount (Carriage)"] = "10cm Twin High-angle Carriage Mount",
["10cm Twin High-angle Mount + Anti-Aircraft Fire Director"] = "10cm Twin High-angle Gun Mount + Anti-Aircraft Fire Director",
["12.7cm High-angle Mount"] = "12.7cm Single High-angle Gun Mount",
["12.7cm Twin High-angle Mount"] = "12.7cm Twin High-angle Gun Mount",
["12.7cm Twin High-angle Mount (Late Model)"] = "12.7cm Twin High-angle Gun Mount (Late Model)",
["12.7cm Twin High-angle Mount + Anti-Aircraft Fire Director"] = "12.7cm High-angle Gun + Anti-Aircraft Fire Director",
["12.7mm Machine Gun"] = "12.7mm Single Machine Gun Mount",
["25mm Autocannon"] = "25mm Single Autocannon Mount",
["BI-type 40mm Twin Machine Gun"] = "Type Bi 40mm Twin Autocannon Mount",
["61cm Quad Torpedo Mount"] = "61cm Quadruple Torpedo Mount",
["61cm Quad Oxygen Torpedo Mount"] = "61cm Quadruple (Oxygen) Torpedo Mount",
["61cm Quint Oxygen Torpedo Mount"] = "61cm Quintuple (Oxygen) Torpedo Mount",
["53cm Hull-mount O2 Torpedoes"] = "53cm Bow (Oxygen) Torpedo Mount",
["53cm Submarine Bow Torpedo Mount (8 tubes)"] = "Submarine 53cm Bow Torpedo Mount (8 tubes)",
["Type A Ko-hyoteki"] = "Kouhyouteki",
["Type 21 Zero Fighter"] = "Type 0 Fighter Model 21",
["Type 21 Zero Fighter (Skilled)"] = "Type 0 Fighter Model 21 (Skilled)",
["Type 52 Zero Fighter"] = "Type 0 Fighter Model 52",
["Zero Fighter Type 52 Type C (601 Air Group)"] = "Zero Fighter Model 52C (601 Air Group)",
["Shiden Kai 2"] = "Shiden Kai Ni",
["Type 62 Zero Fighter-bomber"] = "Type 0 Fighter Model 62 (Fighter-bomber)",
["Type 2 Recon Aircraft"] = "Type 2 Reconnaissance Aircraft",
["Type 0 Recon Seaplane"] = "Type 0 Reconnaissance Seaplane",
["Type 98 Recon Seaplane (Night Recon)"] = "Type 98 Reconnaissance Seaplane (Night Recon)",
["Ka-type Observation Autogyro"] = "No. Ka Observation Autogyro",
["Type 3 Spotter/Liaison (ASW)"] = "Type 3 Command Liaison Aircraft (ASW)",
["Type 22 Surface RADAR Kai 4"] = "No. 22 Surface Radar Kai Yon",
["Type 13 AIR RADAR Kai"] = "No. 13 Air Radar Kai",
["Type 21 Air RADAR Kai"] = "No. 21 Air Radar Kai",
["Type 93 Passive SONAR"] = "Type 93 Passive Sonar",
["Type 3 SONAR"] = "Type 3 Active Sonar",
["Type 0 Passive SONAR"] = "Type 0 Passive Sonar",
["Type 94 Depth Charge"] = "Type 94 Depth Charge Projector",
["Type 3 Depth Charge"] = "Type 3 Depth Charge Projector",
["Type 91 Armor-Piercing (AP) Shell"] = "Type 91 Armor Piercing Shell",
["Type 1 Armor-Piercing (AP) Shell"] = "Type 1 Armor Piercing Shell",
["Improved Steam Turbine"] = "Improved Kanhon Type Turbine",
["Enhanced Steam Boiler"] = "Enhanced Kanhon Type Boiler",
["New High Pressure-Temperature Steam Boiler"] = "New Model High Temperature High Pressure Boiler",
["Anti-torpedo Bulge (Medium)"] = "Extension Bulge (Medium)",
["Anti-torpedo Bulge (Large)"] = "Extension Bulge (Large)",
["Drum Canister"] = "Drum Canister (Transport Use)",
}
--Radar/sonar names without any special pieces
name = name:gsub("^Type%s(.+)%sRADAR$", "No. %1 Radar")
name = names[name] or name
return name
end
function NanaminFunctions.shorten_name(name)
--This takes an equipment name listed on Sandbox/EquipmentListKai/TypeSorted
--and switches it with a shorter version of the name.
local shortened = {
["Example"] = "Ex",
}
return shortened[name] or name
end
return NanaminFunctions