Line 1: |
Line 1: |
| + | local format = require("Module:Utils").format |
| 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 ShipCapabilities = BaseData{ | | local ShipCapabilities = BaseData{ |
− | -- _anti_air_cut_in_types = {
| |
− | -- {
| |
− | -- name = "Akizuki (HA HA R)",
| |
− | -- ship = {"Akizuki"},
| |
− | -- equipment = {"High-angle Gun", "High-angle Gun", "Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Akizuki (HA AAR)",
| |
− | -- ship = {"Akizuki"},
| |
− | -- equipment = {"High-angle Gun", "Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Akizuki (HA HA)",
| |
− | -- ship = {"Akizuki"},
| |
− | -- equipment = {"High-angle Gun", "High-angle Gun"}
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Type 3 AAR",
| |
− | -- equipment = {"Large Caliber Main Gun", "Type 3 Shell", "Anti-Aircraft Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HAFD HAFD AAR",
| |
− | -- equipment = {"High-angle Gun + Fire Director", "High-angle Gun + Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Type 3",
| |
− | -- equipment = {"Large Caliber Main Gun", "Type 3 Shell", "Anti-Aircraft Fire Director"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HA AAFD AAR",
| |
− | -- equipment = {"High-angle Gun", "Anti-Aircraft Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HAFD AAR",
| |
− | -- equipment = {"High-angle Gun + Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "HA AAFD",
| |
− | -- equipment = {"High-angle Gun + Fire Director", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Maya Kai Ni (HA CD AAR)",
| |
− | -- ship = {"Maya/Kai Ni"},
| |
− | -- equipment = {"High-angle Gun", "25mm Triple Autocannon Mount Concentrated Deployment", "Anti-Air Radar"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "Maya Kai Ni (HA CD)",
| |
− | -- ship = {"Maya/Kai Ni"},
| |
− | -- equipment = {"High-angle Gun", "25mm Triple Autocannon Mount Concentrated Deployment"},
| |
− | -- },
| |
− | -- {
| |
− | -- name = "CD AAMG AAR",
| |
− | -- equipment = {"25mm Triple Autocannon Mount Concentrated Deployment", "Anti-Air Machine Gun", "Anti-Air Radar"}
| |
− | -- },
| |
− | -- },
| |
| _attack_template = "${mode} (${attack_power})", | | _attack_template = "${mode} (${attack_power})", |
| _day_battle_modes = { | | _day_battle_modes = { |
Line 107: |
Line 51: |
| end | | end |
| | | |
− | --function ShipCapabilities:anti_air_cut_in()
| + | local Self = ShipCapabilities |
− | --local result = false | + | |
− | --base_name = self._ship:base_name()
| + | function Self:_find_equipment(fn) |
− | --if base_name == "Akizuki" then
| + | for i = 1, self._ship:slots_length() or 0 do |
− | -- result = self:akizuki_anti_air_cut_in() | + | local equipment, size = self._ship:slot(i) |
− | --elseif base_name == "Maya" and self._ship:suffix() == "Kai Ni" then
| + | if equipment and fn(equipment, size) then |
− | -- result = self:maya_kai_ni_anti_air_cut_in()
| + | return equipment |
| + | end |
| + | end |
| + | return false |
| + | end |
| + | |
| + | function Self:_fold_equipment(result, fn) |
| + | for i = 1, self._ship:slots_length() or 0 do |
| + | local equipment, size = self._ship:slot(i) |
| + | if equipment then |
| + | result = fn(equipment, result) |
| + | end |
| + | end |
| + | return result |
| + | end |
| | | |
| function ShipCapabilities:_is_asw_surface_ship(ship) | | function ShipCapabilities:_is_asw_surface_ship(ship) |
Line 278: |
Line 236: |
| function ShipCapabilities:_is_wg(equipment) | | function ShipCapabilities:_is_wg(equipment) |
| return equipment:type() == 37 | | return equipment:type() == 37 |
| + | end |
| + | |
| + | --- Midget Submarines (type = 22) that trigger opening torpedo |
| + | function Self._is_active_midget_submarine(equipment) |
| + | return equipment:id() == 41 or equipment:id() == 541 |
| end | | end |
| | | |
Line 581: |
Line 544: |
| 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()
| + | fleet_torpedo = fleet_torpedo or 0 |
− | local opening_torpedo = self._ship:opening_torpedo() | + | local torpedo = self._ship:torpedo_leveled() |
− | if (opening_torpedo ~= true) and (opening_torpedo == false or not torpedo or torpedo <= 0) then
| + | if self._ship:opening_torpedo() == false or not torpedo or torpedo <= 0 then |
| return false | | return false |
| end | | end |
− | if self:_is_submarine() then
| + | if |
− | local level = self._ship:level()
| + | self:_find_equipment(Self._is_active_midget_submarine) or |
− | if level and level >= 10 then
| + | self:_is_submarine() and self._ship:level() and self._ship:level() >= 10 or |
− | opening_torpedo = true
| + | self:_is_submarine() and self._ship:suffix() and self._ship:suffix():match("Elite") or |
− | end
| + | self:_is_submarine() and self._ship:suffix() and self._ship:suffix():match("Flagship") |
− | end
| + | then |
− | for i = 1, self._ship:slots_length() or 0 do
| + | torpedo = self:_fold_equipment(torpedo, function(equipment, torpedo) |
− | local equipment, size = self._ship:slot(i)
| + | return torpedo + (equipment:torpedo_leveled() or 0) |
− | if equipment then
| + | end) |
− | if self:_is_midget_submarine(equipment) then
| + | return 5 + fleet_torpedo + torpedo |
− | opening_torpedo = true
| + | end |
− | end
| + | return false |
− | 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 |
| | | |