Changes

no edit summary
Line 1: Line 1:  +
local U = require("Module:Core")
 
local BaseData = require("Module:BaseData")
 
local BaseData = require("Module:BaseData")
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
Line 248: Line 249:  
if self._cg then
 
if self._cg then
 
return self._cg
 
return self._cg
elseif self._cg_reference then
+
end
 +
if self._cg == false then
 +
return false
 +
end
 +
local id = self:api_id()
 +
if id and id > 1500 then
 +
local new_id = require('Module:Data/EnemyEquipmentCG')[id]
 +
new_id = new_id or id - 1500
 +
local reference
 +
if new_id and new_id ~= id and new_id > 1500 then
 +
local EnemyEquipment = require('Module:Collection/EnemyEquipment')
 +
reference = U.find(EnemyEquipment, new_id, '_id')
 +
end
 +
if new_id and new_id ~= id and new_id <= 1500 then
 +
local ShipEquipment = require('Module:Data/Equipment')
 +
reference = U.find(ShipEquipment, new_id, '_id')
 +
end
 +
if reference then
 +
Equipment = Equipment or require(self._constructor_module)
 +
return Equipment(reference._name):cg()
 +
end
 +
end
 +
--[[
 +
if self._cg_reference then
 
Equipment = Equipment or require(self._constructor_module)
 
Equipment = Equipment or require(self._constructor_module)
 
return Equipment(self._cg_reference):cg()
 
return Equipment(self._cg_reference):cg()
 
end
 
end
local api_id = self:api_id()
+
]]--
if api_id then
+
if id then
return Formatting:equipment_cg(api_id, self:asset_name())
+
return Formatting:equipment_cg(id, self:asset_name())
 
end
 
end
return self._cg
+
return false
 
end
 
end
   Line 392: Line 416:     
function EquipmentData:is_lbas_plane()
 
function EquipmentData:is_lbas_plane()
local eq_type = self:type()
+
self:_load_compatibility()
return eq_type == 6 -- Carrier-based Fighter Aircraft
+
return EquipmentCompatibility.AirBase[self:type()] or false
or eq_type == 7 -- Carrier-based Dive Bomber
+
-- local eq_type = self:type()
or eq_type == 8 -- Carrier-based Torpedo Bomber
+
-- return eq_type == 6 -- Carrier-based Fighter Aircraft
or eq_type == 9 -- Carrier-based Reconnaissance Aircraft
+
-- or eq_type == 7 -- Carrier-based Dive Bomber
or eq_type == 10 -- Reconnaissance Seaplane
+
-- or eq_type == 8 -- Carrier-based Torpedo Bomber
or eq_type == 11 -- Seaplane Bomber
+
-- or eq_type == 9 -- Carrier-based Reconnaissance Aircraft
or eq_type == 25 -- Rotorcraft
+
-- or eq_type == 10 -- Reconnaissance Seaplane
or eq_type == 26 -- Anti-submarine Patrol Aircraft
+
-- or eq_type == 11 -- Seaplane Bomber
or eq_type == 41 -- Large Flying Boat
+
-- or eq_type == 25 -- Rotorcraft
or eq_type == 45 -- Seaplane Fighter
+
-- or eq_type == 26 -- Anti-submarine Patrol Aircraft
or eq_type == 47 -- Land-based Attack Aircraft
+
-- or eq_type == 41 -- Large Flying Boat
or eq_type == 48 -- Land-based Fighter
+
-- or eq_type == 45 -- Seaplane Fighter
or eq_type == 49 -- Land-based Reconnaissance Aircraft
+
-- or eq_type == 47 -- Land-based Attack Aircraft
or eq_type == 53 -- Large Land-based Aircraft
+
-- or eq_type == 48 -- Land-based Fighter
or eq_type == 56 -- Jet-powered Fighter Aircraft
+
-- or eq_type == 49 -- Land-based Reconnaissance Aircraft
or eq_type == 57 -- Jet-powered Fighter-Bomber
+
-- or eq_type == 53 -- Large Land-based Aircraft
or eq_type == 58 -- Jet-powered Attack Aircraft
+
-- or eq_type == 56 -- Jet-powered Fighter Aircraft
or eq_type == 59 -- Jet-powered Recon Aircraft
+
-- or eq_type == 57 -- Jet-powered Fighter-Bomber
or eq_type == 94 -- Carrier-based Reconnaissance Aircraft (II)
+
-- or eq_type == 58 -- Jet-powered Attack Aircraft
 +
-- or eq_type == 59 -- Jet-powered Recon Aircraft
 +
-- or eq_type == 91 -- Jet-powered Fighter-Bomber (II)
 +
-- or eq_type == 94 -- Carrier-based Reconnaissance Aircraft (II)
 
end
 
end
    
function EquipmentData:is_lbas_ha_bomber()
 
function EquipmentData:is_lbas_ha_bomber()
     return self:id() >= 501 and self:type() == 7 and self:range() == 4
+
     return self:id() >= 1501 and self:type() == 7 and self:range() == 4
 
end
 
end
   Line 463: Line 490:  
or eq_type == 57 -- Jet-powered Fighter-Bomber
 
or eq_type == 57 -- Jet-powered Fighter-Bomber
 
or eq_type == 58 -- Jet-powered Attack Aircraft
 
or eq_type == 58 -- Jet-powered Attack Aircraft
 +
or eq_type == 91 -- Jet-powered Fighter-Bomber (II)
 
end
 
end
   Line 521: Line 549:  
return eq_type == 4 -- Secondary Guns
 
return eq_type == 4 -- Secondary Guns
 
or eq_type == 95 -- Secondary Guns (II)
 
or eq_type == 95 -- Secondary Guns (II)
 +
end
 +
 +
function EquipmentData:is_jet_powered_fighter_bomber()
 +
local eq_type = self:type()
 +
return eq_type == 57 -- Jet-powered Fighter-Bombers
 +
or eq_type == 91 -- Jet-powered Fighter-Bombers (II)
 
end
 
end
   Line 529: Line 563:  
function EquipmentData:info()
 
function EquipmentData:info()
 
  return self._info
 
  return self._info
 +
end
 +
 +
function EquipmentData:info_en()
 +
  return self._info_en
 
end
 
end
   Line 671: Line 709:  
local function convert_compatibility(compatibility_table, equipment_type, name)
 
local function convert_compatibility(compatibility_table, equipment_type, name)
 
local value = compatibility_table[name] or compatibility_table[equipment_type]
 
local value = compatibility_table[name] or compatibility_table[equipment_type]
return value == true and 1 or type(value) == 'string' and {value = 2, note = value, code = value} or 0
+
return value == true and 1 or type(value) == 'string' and {value = U.startsWith(value, 'Only') and 2 or 3, note = value, code = value} or 0
 
end
 
end
  
56,565

edits