Changes

Undo
Line 1: Line 1:  
local BaseData = require("Module:BaseData")
 
local BaseData = require("Module:BaseData")
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
 
+
 
local format = require('Module:Utils').format
 
local format = require('Module:Utils').format
 
+
 
local ShipCapabilities = BaseData{
 
local ShipCapabilities = BaseData{
 
-- _anti_air_cut_in_types = {
 
-- _anti_air_cut_in_types = {
Line 96: Line 96:  
},
 
},
 
}
 
}
 
+
 
function ShipCapabilities:create(data)
 
function ShipCapabilities:create(data)
 
if data.ship then
 
if data.ship then
Line 106: Line 106:  
return data
 
return data
 
end
 
end
 
+
 
--function ShipCapabilities:anti_air_cut_in()
 
--function ShipCapabilities:anti_air_cut_in()
 
--local result = false
 
--local result = false
Line 114: Line 114:  
--elseif base_name == "Maya" and self._ship:suffix() == "Kai Ni" then
 
--elseif base_name == "Maya" and self._ship:suffix() == "Kai Ni" then
 
-- result = self:maya_kai_ni_anti_air_cut_in()
 
-- result = self:maya_kai_ni_anti_air_cut_in()
 
+
 
function ShipCapabilities:_is_asw_surface_ship(ship)
 
function ShipCapabilities:_is_asw_surface_ship(ship)
 
if not ship then
 
if not ship then
Line 130: Line 130:  
--]]
 
--]]
 
end
 
end
 
+
 
function ShipCapabilities:_is_asw_aviation_ship(ship)
 
function ShipCapabilities:_is_asw_aviation_ship(ship)
 
if not ship then
 
if not ship then
Line 142: Line 142:  
or ship_type == 17
 
or ship_type == 17
 
end
 
end
 
+
 
function ShipCapabilities:_is_aviation_ship(ship)
 
function ShipCapabilities:_is_aviation_ship(ship)
 
if not ship then
 
if not ship then
Line 157: Line 157:  
or ship_type == 18
 
or ship_type == 18
 
end
 
end
 
+
 
function ShipCapabilities:_is_light_carrier(ship)
 
function ShipCapabilities:_is_light_carrier(ship)
 
if not ship then
 
if not ship then
Line 164: Line 164:  
return ship:type() == 7
 
return ship:type() == 7
 
end
 
end
 
+
 
function ShipCapabilities:_is_carrier(ship)
 
function ShipCapabilities:_is_carrier(ship)
 
if not ship then
 
if not ship then
Line 174: Line 174:  
or ship_type == 18
 
or ship_type == 18
 
end
 
end
 
+
 
function ShipCapabilities:_is_submarine(ship)
 
function ShipCapabilities:_is_submarine(ship)
 
if not ship then
 
if not ship then
Line 183: Line 183:  
or ship_type == 14
 
or ship_type == 14
 
end
 
end
 
+
 
function ShipCapabilities:_is_installation(ship)
 
function ShipCapabilities:_is_installation(ship)
 
if not ship then
 
if not ship then
Line 190: Line 190:  
return ship:is_installation()
 
return ship:is_installation()
 
end
 
end
 
+
 
function ShipCapabilities:_is_main_gun(equipment)
 
function ShipCapabilities:_is_main_gun(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 198: Line 198:  
or equipment_type == 38
 
or equipment_type == 38
 
end
 
end
 
+
 
function ShipCapabilities:_is_secondary_gun(equipment)
 
function ShipCapabilities:_is_secondary_gun(equipment)
 
return equipment:type() == 4
 
return equipment:type() == 4
 
end
 
end
 
+
 
function ShipCapabilities:_is_torpedo(equipment)
 
function ShipCapabilities:_is_torpedo(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 208: Line 208:  
or equipment_type == 32
 
or equipment_type == 32
 
end
 
end
 
+
 
function ShipCapabilities:_is_bomber(equipment)
 
function ShipCapabilities:_is_bomber(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 215: Line 215:  
or equipment_type == 11
 
or equipment_type == 11
 
end
 
end
 
+
 
function ShipCapabilities:_is_air_power_plane(equipment)
 
function ShipCapabilities:_is_air_power_plane(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 223: Line 223:  
or equipment_type == 11
 
or equipment_type == 11
 
end
 
end
 
+
 
function ShipCapabilities:_is_torpedo_bomber(equipment)
 
function ShipCapabilities:_is_torpedo_bomber(equipment)
 
return equipment:type() == 8
 
return equipment:type() == 8
 
end
 
end
 
+
 
function ShipCapabilities:_is_reconnaissance_seaplane(equipment)
 
function ShipCapabilities:_is_reconnaissance_seaplane(equipment)
 
return equipment:type() == 10
 
return equipment:type() == 10
 
end
 
end
 
+
 
function ShipCapabilities:_is_seaplane(equipment)
 
function ShipCapabilities:_is_seaplane(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 237: Line 237:  
or equipment_type == 11
 
or equipment_type == 11
 
end
 
end
 
+
 
function ShipCapabilities:_is_radar(equipment)
 
function ShipCapabilities:_is_radar(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 243: Line 243:  
or equipment_type == 13
 
or equipment_type == 13
 
end
 
end
 
+
 
function ShipCapabilities:_is_sonar(equipment)
 
function ShipCapabilities:_is_sonar(equipment)
 
local equipment_type = equipment:type()
 
local equipment_type = equipment:type()
Line 249: Line 249:  
or equipment_type == 40
 
or equipment_type == 40
 
end
 
end
 
+
 
function ShipCapabilities:_is_depth_charge(equipment)
 
function ShipCapabilities:_is_depth_charge(equipment)
 
return equipment:type() == 15
 
return equipment:type() == 15
 
end
 
end
 
+
 
-- small main guns', recon sea planes' and radars' asw is invalid
 
-- small main guns', recon sea planes' and radars' asw is invalid
 
function ShipCapabilities:_is_unable_asw_equip(equipment)
 
function ShipCapabilities:_is_unable_asw_equip(equipment)
Line 263: Line 263:  
or equipment_type == 93
 
or equipment_type == 93
 
end
 
end
 
+
 
function ShipCapabilities:_is_type_3_shell(equipment)
 
function ShipCapabilities:_is_type_3_shell(equipment)
 
return equipment:type() == 18
 
return equipment:type() == 18
 
end
 
end
 
+
 
function ShipCapabilities:_is_ap_shell(equipment)
 
function ShipCapabilities:_is_ap_shell(equipment)
 
return equipment:type() == 19
 
return equipment:type() == 19
 
end
 
end
 
+
 
function ShipCapabilities:_is_midget_submarine(equipment)
 
function ShipCapabilities:_is_midget_submarine(equipment)
 
return equipment:type() == 22
 
return equipment:type() == 22
 
end
 
end
 
+
 
function ShipCapabilities:_is_wg(equipment)
 
function ShipCapabilities:_is_wg(equipment)
 
return equipment:type() == 37
 
return equipment:type() == 37
 
end
 
end
 
+
 
function ShipCapabilities:_anti_installation()
 
function ShipCapabilities:_anti_installation()
 
local type_3_shells, wgs = 0, 0
 
local type_3_shells, wgs = 0, 0
Line 294: Line 294:  
return { type_3_shell_equiped = type_3_shells > 0, wg_equiped = wgs > 0 }
 
return { type_3_shell_equiped = type_3_shells > 0, wg_equiped = wgs > 0 }
 
end
 
end
 
+
 
-- Basic attack power for shelling and carrier shelling, including anti-installation modifiers and fleet firepower.
 
-- Basic attack power for shelling and carrier shelling, including anti-installation modifiers and fleet firepower.
 
function ShipCapabilities:day_battle(vs_installation, fleet_firepower)
 
function ShipCapabilities:day_battle(vs_installation, fleet_firepower)
Line 369: Line 369:  
return false
 
return false
 
end
 
end
 
+
 
function ShipCapabilities:format_day_battle(mode, attack_power)
 
function ShipCapabilities:format_day_battle(mode, attack_power)
 
if mode then
 
if mode then
Line 378: Line 378:  
return "??"
 
return "??"
 
end
 
end
 
+
 
-- Basic attack power for closing torpedo, including fleet torpedo.
 
-- Basic attack power for closing torpedo, including fleet torpedo.
 
function ShipCapabilities:closing_torpedo(fleet_torpedo)
 
function ShipCapabilities:closing_torpedo(fleet_torpedo)
Line 396: Line 396:  
return false
 
return false
 
end
 
end
 
+
 
function ShipCapabilities:format_torpedo(attack_power)
 
function ShipCapabilities:format_torpedo(attack_power)
 
if attack_power then
 
if attack_power then
Line 403: Line 403:  
return "No"
 
return "No"
 
end
 
end
 
+
 
ShipCapabilities.format_closing_torpedo = ShipCapabilities.format_torpedo
 
ShipCapabilities.format_closing_torpedo = ShipCapabilities.format_torpedo
 
+
 
-- Detect possible day time special attack modifiers.
 
-- Detect possible day time special attack modifiers.
 
function ShipCapabilities:artillery_spotting(post_cap_attack_power)
 
function ShipCapabilities:artillery_spotting(post_cap_attack_power)
Line 467: Line 467:  
return false
 
return false
 
end
 
end
 
+
 
function ShipCapabilities:format_artillery_spotting(modes)
 
function ShipCapabilities:format_artillery_spotting(modes)
 
if modes then
 
if modes then
Line 484: Line 484:  
return "No"
 
return "No"
 
end
 
end
 
+
 
-- Basic attack power for night battle carrier shelling.
 
-- Basic attack power for night battle carrier shelling.
 
-- Or basic attack power for night battle attack, including night special attack, anti-installation and contact modifiers.
 
-- Or basic attack power for night battle attack, including night special attack, anti-installation and contact modifiers.
Line 566: Line 566:  
end
 
end
 
end
 
end
 
+
 
function ShipCapabilities:format_night_battle(mode, attack_power)
 
function ShipCapabilities:format_night_battle(mode, attack_power)
 
if mode then
 
if mode then
Line 580: Line 580:  
return "Unknown"
 
return "Unknown"
 
end
 
end
  −
function ShipCapabilities:_opening_torpedo_conditon(ship)
  −
    if not ship then
  −
        ship = self._ship
  −
    end
   
   
 
   
    local has_special_equipment = false
  −
    for i = 1, ship:slot_length() or 0 do
  −
        local equipment, size = ship:slot(i)
  −
        if equipment and (equipment:id() == 41 or equipment:id() == 541) then
  −
            has_special_equipment = true
  −
        end
  −
    end
  −
    -- copied from Vita ver
  −
    -- Kouhyouteki and Abyssal Cuttelfish Torpedo,
  −
    -- but not midget submarines, are treated solely.
  −
    -- It seems that Abyssal Ambush Torpedo and High-speed Abyssal Torpedo mod.2
  −
    -- cannot perform opening torpedo.
  −
  −
    if ship:type() == 13 or ship:type() == 14 then
  −
        if ship:id() > 1500 then
  −
            return true
  −
            -- copied from Vita ver
  −
        else
  −
            local level = ship:level()
  −
            return has_special_equipment or (level and level >= 10)
  −
        end
  −
    else
  −
        return has_special_equipment
  −
    end
  −
end
  −
   
-- Basic attack power for opening torpedo, including fleet torpedo.
 
-- Basic attack power for opening torpedo, including fleet torpedo.
 
function ShipCapabilities:opening_torpedo(fleet_torpedo)
 
function ShipCapabilities:opening_torpedo(fleet_torpedo)
 
local torpedo = self._ship:torpedo_leveled()
 
local torpedo = self._ship:torpedo_leveled()
if not torpedo or torpedo <= 0 then
+
local opening_torpedo = self._ship:opening_torpedo()
 +
if (opening_torpedo ~= true) and (opening_torpedo == false or not torpedo or torpedo <= 0) then
 
return false
 
return false
 +
end
 +
if self:_is_submarine() then
 +
local level = self._ship:level()
 +
if level and level >= 10 then
 +
opening_torpedo = true
 +
end
 
end
 
end
 
for i = 1, self._ship:slots_length() or 0 do
 
for i = 1, self._ship:slots_length() or 0 do
 
local equipment, size = self._ship:slot(i)
 
local equipment, size = self._ship:slot(i)
 
if equipment then
 
if equipment then
 +
if self:_is_midget_submarine(equipment) then
 +
opening_torpedo = true
 +
end
 
local equipment_torpedo = equipment:torpedo_leveled()
 
local equipment_torpedo = equipment:torpedo_leveled()
 
if equipment_torpedo and torpedo then
 
if equipment_torpedo and torpedo then
Line 627: Line 606:  
end
 
end
 
end
 
end
if self:_opening_torpedo_conditon(self._ship) then
+
if opening_torpedo then
 
return 5 + (fleet_torpedo or 0) + (torpedo or 0)
 
return 5 + (fleet_torpedo or 0) + (torpedo or 0)
 
end
 
end
 
return false
 
return false
 
end
 
end
 
+
 
ShipCapabilities.format_opening_torpedo = ShipCapabilities.format_torpedo
 
ShipCapabilities.format_opening_torpedo = ShipCapabilities.format_torpedo
 
+
 
-- Basic attack power for ASW attack * sonar w/ depth charge modifier (pre-cap).
 
-- Basic attack power for ASW attack * sonar w/ depth charge modifier (pre-cap).
 
function ShipCapabilities:asw_attack()
 
function ShipCapabilities:asw_attack()
Line 680: Line 659:  
return depth_charge_sonar_boost * (base_asw + 1.5 * equipment_asw + 2 * math.sqrt(ship_asw)), day, night, not asw_leveled
 
return depth_charge_sonar_boost * (base_asw + 1.5 * equipment_asw + 2 * math.sqrt(ship_asw)), day, night, not asw_leveled
 
end
 
end
 
+
 
function ShipCapabilities:format_asw_attack(attack_power, day, night, uncertain)
 
function ShipCapabilities:format_asw_attack(attack_power, day, night, uncertain)
 
if attack_power then
 
if attack_power then
Line 701: Line 680:  
return "No"
 
return "No"
 
end
 
end
 
+
 
-- Basic attack power for opening airstrike (returns an array with attack values per each bomber).
 
-- Basic attack power for opening airstrike (returns an array with attack values per each bomber).
 
function ShipCapabilities:opening_airstrike()
 
function ShipCapabilities:opening_airstrike()
Line 724: Line 703:  
return false
 
return false
 
end
 
end
 
+
 
function ShipCapabilities:format_opening_airstrike(attacks)
 
function ShipCapabilities:format_opening_airstrike(attacks)
 
if attacks then
 
if attacks then
Line 735: Line 714:  
return "No"
 
return "No"
 
end
 
end
 
+
 
return ShipCapabilities
 
return ShipCapabilities
Anonymous user