Changes

Undo: there are still something wrong...
Line 270: Line 270:  
function ShipCapabilities:_is_ap_shell(equipment)
 
function ShipCapabilities:_is_ap_shell(equipment)
 
return equipment:type() == 19
 
return equipment:type() == 19
 +
end
 +
 +
function ShipCapabilities:_is_midget_submarine(equipment)
 +
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
  −
  −
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: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 string.find(ship:suffix(), "[Ff]lagshp|[Ee]lite") ~= nil
  −
            -- 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
 
end
   Line 610: Line 583:  
-- 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)
    return self:_opening_torpedo_conditon(self._ship) and self:closing_torpedo(fleet_torpedo)
+
local torpedo = self._ship:torpedo_leveled()
    -- With the new implementation we can remove _opening_torpedo attribute
+
local opening_torpedo = self._ship:opening_torpedo()
 +
if (opening_torpedo ~= true) and (opening_torpedo == false or not torpedo or torpedo <= 0) then
 +
return false
 +
end
 +
if self:_is_submarine() then
 +
local level = self._ship:level()
 +
if level and level >= 10 then
 +
opening_torpedo = true
 +
end
 +
end
 +
for i = 1, self._ship:slots_length() or 0 do
 +
local equipment, size = self._ship:slot(i)
 +
if equipment then
 +
if self:_is_midget_submarine(equipment) then
 +
opening_torpedo = true
 +
end
 +
local equipment_torpedo = equipment:torpedo_leveled()
 +
if equipment_torpedo and torpedo then
 +
torpedo = torpedo + equipment_torpedo
 +
end
 +
end
 +
end
 +
if opening_torpedo then
 +
return 5 + (fleet_torpedo or 0) + (torpedo or 0)
 +
end
 +
return false
 
end
 
end
  
Anonymous user