• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
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 Equipment
 
local Equipment
 
local EquipmentFrom
 
local EquipmentFrom
local EquipmentCompatibility --lazily loaded when equippable() is called
+
local EquipmentCompatibility
local Formatting = require('Module:Formatting')
      
local EquipmentData = BaseData({
 
local EquipmentData = BaseData({
Line 11: Line 12:  
_display_none_css = {display = "none"},
 
_display_none_css = {display = "none"},
 
_constructor_module = "Module:Equipment",
 
_constructor_module = "Module:Equipment",
_from_api_module = "Module:EquipmentFrom",
   
})
 
})
    +
--Returns the name of the equipment as !!HTML!! with appropriate classes to show/hide strict/common translation variants.
 +
--Use this for display purposes.
 
function EquipmentData:name()
 
function EquipmentData:name()
 
return self._name
 
return self._name
 
end
 
end
    +
--Returns the equipment's strict name translation as a string.
 
function EquipmentData:strict_name()
 
function EquipmentData:strict_name()
 
return self._strict_name
 
return self._strict_name
 
end
 
end
    +
--Returns the equipment's common name translation as a string.
 
function EquipmentData:common_name()
 
function EquipmentData:common_name()
 
return self._common_name or self:name()
 
return self._common_name or self:name()
 
end
 
end
    +
--Returns the equipment's name used for assets.
 +
--Use this for internal references.
 
function EquipmentData:asset_name()
 
function EquipmentData:asset_name()
 
return self._asset_name or self:common_name()
 
return self._asset_name or self:common_name()
 
end
 
end
    +
--Returns a tuple for use in Formatting:format_link() to generate a link to this equipment's page.
 
function EquipmentData:link()
 
function EquipmentData:link()
 
if self._page then
 
if self._page then
 
return self._page, self:name()
 
return self._page, self:name()
 +
elseif self._common_name then
 +
    return self:common_name(), self:name()
 
end
 
end
 
return self:name()
 
return self:name()
 
end
 
end
    +
--Returns the equipment's id.
 
function EquipmentData:id()
 
function EquipmentData:id()
return self._id
+
return self._is_enemy and self._id and self._id < 1501 and self._id + 1000 or self._id
 
end
 
end
    
EquipmentData.api_id = EquipmentData.id
 
EquipmentData.api_id = EquipmentData.id
    +
--Returns the equipment's localized name, for when the equipment name is translated as romaji.
 
function EquipmentData:localized_name()
 
function EquipmentData:localized_name()
 
return self._localized_name
 
return self._localized_name
 
end
 
end
    +
--Returns the reading of the equipment's Japanese name.
 
function EquipmentData:reading()
 
function EquipmentData:reading()
 
return self._reading
 
return self._reading
 
end
 
end
    +
--Returns the equipment's name in the equipment list.
 
function EquipmentData:list_name()
 
function EquipmentData:list_name()
 
return self._list_name
 
return self._list_name
 
end
 
end
    +
--Returns the equipment's Japanese name in the equipment list.
 
function EquipmentData:list_japanese_name()
 
function EquipmentData:list_japanese_name()
 
return self._list_japanese_name
 
return self._list_japanese_name
 
end
 
end
    +
--Returns the equipment's localized name in the equipment list.
 
function EquipmentData:list_localized_name()
 
function EquipmentData:list_localized_name()
 
return self._list_localized_name
 
return self._list_localized_name
 
end
 
end
    +
--Returns the reading of the equipment's Japanese name in the equipment list.
 
function EquipmentData:list_reading()
 
function EquipmentData:list_reading()
 
return self._list_reading
 
return self._list_reading
 
end
 
end
    +
--Returns the equipment's name in the equipment comparison.
 
function EquipmentData:comparison_name()
 
function EquipmentData:comparison_name()
 
return self._comparison_name
 
return self._comparison_name
 
end
 
end
    +
--Returns the equipment's Japanese name in the equipment comparison.
 
function EquipmentData:comparison_japanese_name()
 
function EquipmentData:comparison_japanese_name()
 
return self._comparison_japanese_name
 
return self._comparison_japanese_name
 
end
 
end
    +
--Returns the equipment's localized name in the equipment comparison.
 
function EquipmentData:comparison_localized_name()
 
function EquipmentData:comparison_localized_name()
 
return self._comparison_localized_name
 
return self._comparison_localized_name
 
end
 
end
    +
--Returns the reading of the equipment's Japanese name in the equipment comparison.
 
function EquipmentData:comparison_reading()
 
function EquipmentData:comparison_reading()
 
return self._comparison_reading
 
return self._comparison_reading
 
end
 
end
    +
--Returns the equipment's name in battle.
 
function EquipmentData:battle_name()
 
function EquipmentData:battle_name()
 
return self._battle_name
 
return self._battle_name
 
end
 
end
    +
--Returns the equipment's Japanese name in battle.
 
function EquipmentData:battle_japanese_name()
 
function EquipmentData:battle_japanese_name()
 
return self._battle_japanese_name
 
return self._battle_japanese_name
 
end
 
end
    +
--Returns the equipment's localized name in battle.
 
function EquipmentData:battle_localized_name()
 
function EquipmentData:battle_localized_name()
 
return self._battle_localized_name
 
return self._battle_localized_name
 
end
 
end
    +
--Returns the reading of the equipment's Japanese name in battle.
 
function EquipmentData:battle_reading()
 
function EquipmentData:battle_reading()
 
return self._battle_reading
 
return self._battle_reading
 
end
 
end
    +
--Returns the equipment's name in the library.
 
function EquipmentData:library_name()
 
function EquipmentData:library_name()
 
return self._library_name
 
return self._library_name
 
end
 
end
    +
--Returns the equipment's Japanese name in the library.
 
function EquipmentData:library_japanese_name()
 
function EquipmentData:library_japanese_name()
 
return self._library_japanese_name
 
return self._library_japanese_name
 
end
 
end
    +
--Returns the equipment's localized name in the library.
 
function EquipmentData:library_localized_name()
 
function EquipmentData:library_localized_name()
 
return self._library_localized_name
 
return self._library_localized_name
 
end
 
end
    +
--Returns the reading of the equipment's Japanese name in the library.
 
function EquipmentData:library_reading()
 
function EquipmentData:library_reading()
 
return self._library_reading
 
return self._library_reading
 
end
 
end
    +
--Returns the equipment's name on it's card.
 
function EquipmentData:card_name()
 
function EquipmentData:card_name()
 
return self._card_name
 
return self._card_name
 
end
 
end
    +
--Returns the equipment's Japanese name on it's card.
 
function EquipmentData:card_japanese_name()
 
function EquipmentData:card_japanese_name()
 
return self._card_japanese_name
 
return self._card_japanese_name
 
end
 
end
    +
--Returns the equipment's localized name on it's card.
 
function EquipmentData:card_localized_name()
 
function EquipmentData:card_localized_name()
 
return self._card_localized_name
 
return self._card_localized_name
 
end
 
end
    +
--Returns the reading of the equipment's Japanese name on it's card.
 
function EquipmentData:card_reading()
 
function EquipmentData:card_reading()
 
return self._card_reading
 
return self._card_reading
 
end
 
end
    +
--Returns the equipment's Japanese name as a string.
 
function EquipmentData:japanese_name()
 
function EquipmentData:japanese_name()
 
return self._japanese_name
 
return self._japanese_name
 
end
 
end
    +
--Returns the equipment's type as an integer according to the KanColle API.
 +
--You can use Formatting:format_equipment_type to convert this to the name of the type.
 
function EquipmentData:type()
 
function EquipmentData:type()
 
return self._type
 
return self._type
 
end
 
end
    +
function EquipmentData:types()
 +
return self._types
 +
end
 +
 +
--The level of improvement of the equipment in Akashi's Improvement Arsenal (how many stars it has).
 +
--This is not meant to be defined in equipment data modules.
 +
--Instead, call Equipment("equipment name") to get an EquipmentData object.
 +
--Then, call the equipment data object with _level = n to create an EquipmentData object with that level.
 +
--Example: local equip = Equipment("12.7cm Twin Gun Mount")
 +
--        local improved_equip = equip{_level = 10}
 +
function EquipmentData:level()
 +
    return self._level
 +
end
 +
 +
--The rank of the equipment for aircraft proficiency.
 +
--This should be treated similarly to EquipmentData:level() above.
 +
function EquipmentData:rank()
 +
    return self._rank
 +
end
 +
 +
--The type name shown in the album/library as a string.
 
function EquipmentData:album_type()
 
function EquipmentData:album_type()
 
return self._album_type
 
return self._album_type
 
end
 
end
    +
--The rarity of the equipment as an integer according to the KanColle API.
 
function EquipmentData:rarity()
 
function EquipmentData:rarity()
 
return self._rarity
 
return self._rarity
 
end
 
end
    +
--The amount of stars on the rarity ribbon on the equipment's card as an integer. Defaults to EquipmentData:back().
 
function EquipmentData:stars()
 
function EquipmentData:stars()
 
return self._stars or self:back()
 
return self._stars or self:back()
 
end
 
end
    +
--The rarity of the background of the equipment's card as an integer. Defaults to EquipmentData:rarity().
 
function EquipmentData:back()
 
function EquipmentData:back()
 
return self._back or self:rarity()
 
return self._back or self:rarity()
 
end
 
end
   −
function EquipmentData:card()
+
function EquipmentData:card(as_item)
 +
    if self._item or as_item and self._item_id then
 +
        return Formatting:item_card(self:asset_name())
 +
    end
 
if self._card then
 
if self._card then
 
return self._card
 
return self._card
Line 162: Line 224:  
return Equipment(self._card_reference):card()
 
return Equipment(self._card_reference):card()
 
end
 
end
api_id = self:api_id()
+
local api_id = self:api_id()
if api_id then
+
if self._item then
 +
    return Formatting:equipment_card(false, self:asset_name())
 +
elseif api_id ~= nil then
 
return Formatting:equipment_card(api_id, self:asset_name())
 
return Formatting:equipment_card(api_id, self:asset_name())
end
+
    end
return self._card
   
end
 
end
   Line 176: Line 239:  
return Equipment(self._fairy_reference):fairy()
 
return Equipment(self._fairy_reference):fairy()
 
end
 
end
api_id = self:api_id()
+
local api_id = self:api_id()
 
if api_id then
 
if api_id then
 
return Formatting:equipment_fairy(api_id, self:asset_name())
 
return Formatting:equipment_fairy(api_id, self:asset_name())
Line 190: Line 253:  
return Equipment(self._cg_reference):cg()
 
return Equipment(self._cg_reference):cg()
 
end
 
end
api_id = self:api_id()
+
local api_id = self:api_id()
 
if api_id then
 
if api_id then
    if self._enemy_default_assets then
  −
    Equipment = Equipment or require(self._constructor_module)
  −
    EquipmentFrom = EquipmentFrom or require(self._from_api_module)
  −
    return Equipment(EquipmentFrom:api_id_lookup{api_id - 500}):cg()
  −
    end
   
return Formatting:equipment_cg(api_id, self:asset_name())
 
return Formatting:equipment_cg(api_id, self:asset_name())
 
end
 
end
Line 209: Line 267:  
return Equipment(self._cg_fairy_reference):cg_fairy()
 
return Equipment(self._cg_fairy_reference):cg_fairy()
 
end
 
end
api_id = self:api_id()
+
local api_id = self:api_id()
 
if api_id then
 
if api_id then
 
return Formatting:equipment_full(api_id, self:asset_name())
 
return Formatting:equipment_full(api_id, self:asset_name())
Line 221: Line 279:  
end
 
end
   −
function EquipmentData:icon()
+
function EquipmentData:icon(as_item)
return self._icon
+
    if self._item or as_item and self._item_id then
 +
        return Formatting:item_icon(self:asset_name())
 +
    end
 +
    if self._icon or self._icon == false then
 +
        return self._icon
 +
    else
 +
        return Formatting:equipment_image('Icon', false, self:asset_name())
 +
    end
 
end
 
end
   Line 317: Line 382:     
function EquipmentData:combat_radius()
 
function EquipmentData:combat_radius()
    return self._combat_radius or self._flight_range
+
return self._combat_radius or self._flight_range
 
end
 
end
    
function EquipmentData:deployment_cost()
 
function EquipmentData:deployment_cost()
    return {fuel = false, ammo = false, steel = false, bauxite = self._deployment_cost or self._flight_cost, devmat = false, screw = false}
+
return {fuel = false, ammo = false, steel = false, bauxite = self._deployment_cost or self._flight_cost, devmat = false, conmat = false, screw = false}
 
end
 
end
    
EquipmentData.flight_range = EquipmentData.combat_radius
 
EquipmentData.flight_range = EquipmentData.combat_radius
 
EquipmentData.flight_cost = EquipmentData.deployment_cost
 
EquipmentData.flight_cost = EquipmentData.deployment_cost
 +
 +
function EquipmentData:is_lbas_plane()
 +
self:_load_compatibility()
 +
return EquipmentCompatibility.AirBase[self:type()] or false
 +
-- local eq_type = self:type()
 +
-- return eq_type == 6 -- Carrier-based Fighter Aircraft
 +
-- or eq_type == 7 -- Carrier-based Dive Bomber
 +
-- or eq_type == 8 -- Carrier-based Torpedo Bomber
 +
-- or eq_type == 9 -- Carrier-based Reconnaissance Aircraft
 +
-- or eq_type == 10 -- Reconnaissance Seaplane
 +
-- or eq_type == 11 -- Seaplane Bomber
 +
-- or eq_type == 25 -- Rotorcraft
 +
-- or eq_type == 26 -- Anti-submarine Patrol Aircraft
 +
-- or eq_type == 41 -- Large Flying Boat
 +
-- or eq_type == 45 -- Seaplane Fighter
 +
-- or eq_type == 47 -- Land-based Attack Aircraft
 +
-- or eq_type == 48 -- Land-based Fighter
 +
-- or eq_type == 49 -- Land-based Reconnaissance Aircraft
 +
-- or eq_type == 53 -- Large Land-based Aircraft
 +
-- or eq_type == 56 -- Jet-powered Fighter Aircraft
 +
-- or eq_type == 57 -- Jet-powered Fighter-Bomber
 +
-- or eq_type == 58 -- Jet-powered Attack Aircraft
 +
-- or eq_type == 59 -- Jet-powered Recon Aircraft
 +
-- or eq_type == 94 -- Carrier-based Reconnaissance Aircraft (II)
 +
end
 +
 +
function EquipmentData:is_lbas_ha_bomber()
 +
    return self:id() >= 501 and self:type() == 7 and self:range() == 4
 +
end
 +
 +
function EquipmentData:is_lbas_attack_aircraft()
 +
    return self:type() == 47 or self:type() == 53
 +
end
 +
 +
function EquipmentData:is_large_caliber_main_gun()
 +
local eq_type = self:type()
 +
return eq_type == 3 -- Large Caliber Main Gun
 +
or eq_type == 38 -- Large Caliber Main Gun (II)
 +
end
 +
 +
function EquipmentData:is_main_gun()
 +
local eq_type = self:type()
 +
return eq_type == 1 -- Small Caliber Main Guns
 +
or eq_type == 2 -- Medium Caliber Main Guns
 +
or eq_type == 3 -- Large Caliber Main Guns
 +
or eq_type == 38 -- Large Caliber Main Guns (II)
 +
end
 +
 +
function EquipmentData:is_aafd()
 +
return self:aa() and self:aa() >= 8
 +
end
 +
 +
function EquipmentData:is_not_aafd()
 +
return not (self:is_aafd())
 +
end
 +
 +
function EquipmentData:is_fighter_aircraft()
 +
local eq_type = self:type()
 +
return eq_type == 6 -- Carrier-based Fighter Aircraft
 +
or eq_type == 45 -- Seaplane Fighter
 +
or eq_type == 48 -- Land-based Fighter
 +
or eq_type == 56 -- Jet-powered Fighter Aircraft
 +
end
 +
 +
function EquipmentData:is_bomber_aircraft()
 +
local eq_type = self:type()
 +
or eq_type == 7 -- Carrier-based Dive Bomber
 +
or eq_type == 8 -- Carrier-based Torpedo Bomber
 +
or eq_type == 11 -- Seaplane Bomber
 +
-- or eq_type == 25 -- Rotorcraft
 +
or eq_type == 26 -- Anti-submarine Patrol Aircraft
 +
or eq_type == 47 -- Land-based Attack Aircraft
 +
or eq_type == 53 -- Large Land-based Aircraft
 +
or eq_type == 57 -- Jet-powered Fighter-Bomber
 +
or eq_type == 58 -- Jet-powered Attack Aircraft
 +
end
 +
 +
function EquipmentData:is_reconnaissance_aircraft()
 +
local eq_type = self:type()
 +
return eq_type == 9 -- Carrier-based Reconnaissance Aircraft
 +
or eq_type == 10 -- Reconnaissance Seaplanes
 +
or eq_type == 49 -- Land-based Reconnaissance Aircraft
 +
or eq_type == 94 -- Carrier-based Reconnaissance Aircraft (II)
 +
end
 +
 +
function EquipmentData:is_carrier_based_reconnaissance_aircraft()
 +
local eq_type = self:type()
 +
return eq_type == 9 -- Carrier-based Reconnaissance Aircraft
 +
or eq_type == 94 -- Carrier-based Reconnaissance Aircraft (II)
 +
end
 +
 +
function EquipmentData:is_torpedo()
 +
local eq_type = self:type()
 +
return eq_type == 5 -- Torpedo
 +
or eq_type == 32 -- Submarine Torpedo
 +
end
 +
 +
function EquipmentData:is_radar()
 +
local eq_type = self:type()
 +
return eq_type == 12 -- Small Radar
 +
or eq_type == 13 -- Large Radar
 +
or eq_type == 93 -- Large Radar (II)
 +
end
 +
 +
function EquipmentData:is_large_radar()
 +
local eq_type = self:type()
 +
return eq_type == 13 -- Large Radar
 +
or eq_type == 93 -- Large Radar (II)
 +
end
 +
 +
function EquipmentData:is_sonar()
 +
local eq_type = self:type()
 +
return eq_type == 14 -- Sonar
 +
or eq_type == 40 -- Large Sonar
 +
end
 +
 +
function EquipmentData:is_asw_aircraft()
 +
local eq_type = self:type()
 +
return eq_type == 25 -- Autogyro
 +
or eq_type == 26 -- Anti-submarine Patrol Aircraft
 +
end
 +
 +
function EquipmentData:is_extra_armor()
 +
local eq_type = self:type()
 +
return eq_type == 16 -- Extra Armor
 +
or eq_type == 27 -- Extra Armor (Medium)
 +
or eq_type == 28 -- Extra Armor (Large)
 +
end
 +
 +
function EquipmentData:is_secondary_gun()
 +
local eq_type = self:type()
 +
return eq_type == 4 -- Secondary Guns
 +
or eq_type == 95 -- Secondary Guns (II)
 +
end
    
function EquipmentData:scrap()
 
function EquipmentData:scrap()
return {fuel = self._scrap_fuel, ammo = self._scrap_ammo, steel = self._scrap_steel, bauxite = self._scrap_bauxite, devmat = false, screw = false}
+
return {fuel = self._scrap_fuel, ammo = self._scrap_ammo, steel = self._scrap_steel, bauxite = self._scrap_bauxite, devmat = false, conmat = false, screw = false}
 +
end
 +
 
 +
function EquipmentData:info()
 +
  return self._info
 +
end
 +
 
 +
function EquipmentData:wikipedia()
 +
  return self._wikipedia
 
end
 
end
    
function EquipmentData:buildable()
 
function EquipmentData:buildable()
 
  return self._buildable
 
  return self._buildable
 +
end
 +
 +
function EquipmentData:improvable()
 +
  return self._improvements and true or false
 
end
 
end
   Line 412: Line 623:  
bauxite = self._improvements._bauxite,
 
bauxite = self._improvements._bauxite,
 
devmat = false,
 
devmat = false,
 +
conmat = false,
 
screw = false,
 
screw = false,
 
}
 
}
Line 452: Line 664:  
function EquipmentData:gun_fit_group()
 
function EquipmentData:gun_fit_group()
 
return self._gun_fit_group
 
return self._gun_fit_group
 +
end
 +
 +
function EquipmentData:_load_compatibility()
 +
if not EquipmentCompatibility then
 +
EquipmentCompatibility = mw.loadData('Module:Data/EquipmentRefit')
 +
end
 +
end
 +
 +
local function convert_compatibility(compatibility_table, equipment_type, name)
 +
local value = compatibility_table[name] or compatibility_table[equipment_type]
 +
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
    
function EquipmentData:equippable(ship_type)
 
function EquipmentData:equippable(ship_type)
 
self:_load_compatibility()
 
self:_load_compatibility()
local equipment_type = self:type()
   
if not ship_type then
 
if not ship_type then
 
local result = {}
 
local result = {}
 
for ship_type, compatibility_table in pairs(EquipmentCompatibility) do
 
for ship_type, compatibility_table in pairs(EquipmentCompatibility) do
result[ship_type] = compatibility_table[equipment_type]
+
result[ship_type] = convert_compatibility(compatibility_table, self:type(), self:name())
 
end
 
end
 
return result
 
return result
 +
end
 +
local compatibility_table = EquipmentCompatibility[ship_type]
 +
if not compatibility_table then
 +
return nil
 +
end
 +
local compatibility = convert_compatibility(compatibility_table, self:type(), self:name())
 +
if type(compatibility) ~= "table" then
 +
return compatibility
 
else
 
else
local compatibility_table = EquipmentCompatibility[ship_type]
+
return compatibility.value, compatibility.note
if compatibility_table then
  −
local compatibility = compatibility_table[equipment_type]
  −
if type(compatibility) ~= "table" then
  −
return compatibility
  −
else
  −
return compatibility.value, compatibility.note
  −
end
  −
end
  −
end
  −
end
  −
 
  −
function EquipmentData:_load_compatibility()
  −
if not EquipmentCompatibility then
  −
EquipmentCompatibility = mw.loadData('Module:EquipmentCompatibility')
   
end
 
end
 
end
 
end
cssedit, gkautomate
6,926

edits

Navigation menu