Changes

no edit summary
Line 1: Line 1: −
local Equipment = require('Module:Equipment')
+
local Equipment
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
 
local Ship
 
local Ship
 
local ShipClass = require('Module:ShipClass')
 
local ShipClass = require('Module:ShipClass')
 +
local dropData
 +
local sortIds = require("Module:DropList/Sort")
    
local BaseData = require("Module:BaseData")
 
local BaseData = require("Module:BaseData")
Line 9: Line 11:  
}
 
}
   −
function ShipData:name()
+
--Return the full name of the ship.
 +
function ShipData:name(sep)
 +
    sep = sep or " "
 
local suffix = self:display_suffix()
 
local suffix = self:display_suffix()
if suffix then
+
if suffix and suffix ~= "" then
return self:base_name() .. " " .. suffix
+
return self:base_name() .. sep .. suffix
 
else
 
else
 
return self:base_name()
 
return self:base_name()
Line 18: Line 22:  
end
 
end
   −
function ShipData:unique_name()
+
--Return the unique name of the ship.
return self:base_name() .. " " .. self:suffix()
+
--Differs from name() for some boss enemies that have a legacy role suffix,
 +
--which isn't shown for unique_name().
 +
function ShipData:unique_name(sep)
 +
    sep = sep or " "
 +
local suffix = self:suffix()
 +
if suffix and suffix ~= "" then
 +
return self:base_name() .. sep .. self:suffix()
 +
else
 +
return self:base_name()
 +
end
 
end
 
end
    +
--Return the name of the module containing this ship.
 +
--Note: This is pretty iffy. Try not to use it, it's badly defined.
 +
function ShipData:module_name()
 +
if self._module_name then
 +
return self._module_name
 +
end
 +
return self:base_name()
 +
end
 +
 +
function ShipData:lua_name()
 +
local key = self._key
 +
if key and key ~= "" then
 +
return self:base_name() .. "/" .. key
 +
else
 +
return self:base_name()
 +
end
 +
end
 +
 +
--The base name of the ship.
 
function ShipData:base_name()
 
function ShipData:base_name()
 
return self._name
 
return self._name
 
end
 
end
    +
--The suffix of the ship. Does not include legacy role suffixes.
 
function ShipData:suffix()
 
function ShipData:suffix()
 
return self._suffix
 
return self._suffix
 
end
 
end
    +
--The suffix of the ship. Includes legacy role suffixes.
 
function ShipData:display_suffix()
 
function ShipData:display_suffix()
 
if self._display_suffix ~= nil then
 
if self._display_suffix ~= nil then
Line 37: Line 71:  
end
 
end
    +
--A group of values passable to Formatting:format_link() to create a wikitext link to this ship.
 
function ShipData:link()
 
function ShipData:link()
 +
if self._page then
 +
return self._page, self:unique_name()
 +
elseif self._seasonal then
 +
    return self:base_link()
 +
    elseif self._vita then
 +
        return string.format('KanColle Kai:%s', self:base_link()), self:unique_name()
 +
    else
 +
return self:unique_name()
 +
end
 +
end
 +
 +
--A group of values passable to Formatting:format_link() to create a wikitext link to the base page of this ship.
 +
--E.g. Shigure instead of Shigure Kai Ni.
 +
function ShipData:base_link()
 
if self._page then
 
if self._page then
 
return self._page, self:name()
 
return self._page, self:name()
elseif self:suffix() then
+
else
 
return self:base_name(), self:name()
 
return self:base_name(), self:name()
else
  −
return self:name()
   
end
 
end
 
end
 
end
Line 69: Line 116:  
function ShipData:reading_nick()
 
function ShipData:reading_nick()
 
return self._reading_nick
 
return self._reading_nick
 +
end
 +
 +
function ShipData:wikipedia()
 +
return self._wikipedia
 
end
 
end
   Line 81: Line 132:  
function ShipData:true_id()
 
function ShipData:true_id()
 
return self._true_id
 
return self._true_id
 +
end
 +
 +
function ShipData:sort_id()
 +
return sortIds[self._api_id] or 0
 
end
 
end
   Line 89: Line 144:  
function ShipData:back()
 
function ShipData:back()
 
return self._back or self:rarity()
 
return self._back or self:rarity()
 +
end
 +
 +
function ShipData:overlay()
 +
return self._overlay
 
end
 
end
   Line 101: Line 160:  
function ShipData:type()
 
function ShipData:type()
 
return self._type
 
return self._type
 +
end
 +
 +
function ShipData:code()
 +
return Formatting:format_ship_code(self._type)
 +
end
 +
 +
function ShipData:formatted_type()
 +
return Formatting:format_ship_type(self._type)
 +
end
 +
 +
function ShipData:is_battleship()
 +
return self._type == 8 or self._type == 9 or self._type == 10 or self._type == 12
 +
end
 +
 +
function ShipData:is_carrier()
 +
return self._type == 7 or self._type == 11 or self._type == 18
 +
end
 +
 +
function ShipData:is_auxiliary()
 +
return self._type == 22 or self._type == 16 or self._type == 17 or self._type == 19 or self._type == 20
 +
end
 +
 +
function ShipData:is_submarine()
 +
return self._type == 13 or self._type == 14
 +
end
 +
 +
function ShipData:is_CL()
 +
return self._type == 3 or self._type == 4 or self._type == 21
 +
end
 +
 +
function ShipData:is_CA()
 +
return self._type == 5 or self._type == 6
 
end
 
end
   Line 107: Line 198:  
end
 
end
   −
function ShipData:card()
+
function ShipData:is_pillbox()
if self._card then
+
return self._pillbox
 +
end
 +
 
 +
function ShipData:simple_naming()
 +
return self._simple_naming
 +
end
 +
 
 +
function ShipData:card(hd)
 +
if self._card ~= nil then
 
return self._card
 
return self._card
 
elseif self._card_reference then
 
elseif self._card_reference then
 
Ship = Ship or require(self._constructor_module)
 
Ship = Ship or require(self._constructor_module)
return Ship:create_from_reference(self._card_reference, self):card()
+
return Ship:create_from_reference(self._card_reference, self):card(hd)
 
end
 
end
api_id = self:api_id()
+
local api_id, simple_naming = self:api_id(), self:simple_naming()
if api_id then
+
if not api_id and not self:type() then
return Formatting:ship_card(api_id, self:unique_name(), self:type(), self._card_extension)
+
    return Formatting:ship_card(nil, self:unique_name(), nil, self._card_extension, true, hd)
 +
elseif api_id or simple_naming then
 +
return Formatting:ship_card(api_id, self:unique_name(), self:type(), self._card_extension, simple_naming, hd)
 
end
 
end
return self._card
   
end
 
end
   −
function ShipData:card_damaged()
+
function ShipData:card_damaged(hd)
if self._card_damaged then
+
if self._card_damaged ~= nil then
 
return self._card_damaged
 
return self._card_damaged
 
elseif self._card_damaged_reference then
 
elseif self._card_damaged_reference then
 
Ship = Ship or require(self._constructor_module)
 
Ship = Ship or require(self._constructor_module)
return Ship:create_from_reference(self._card_damaged_reference, self):card_damaged()
+
return Ship:create_from_reference(self._card_damaged_reference, self):card_damaged(hd)
 
end
 
end
api_id = self:api_id()
+
local api_id, simple_naming = self:api_id(), self:simple_naming()
if api_id then
+
if not api_id and not self:type() then
return Formatting:ship_card_damaged(api_id, self:unique_name(), self:type(), self._card_damaged_extension)
+
    return Formatting:ship_card_damaged(nil, self:unique_name(), nil, self._card_damaged_extension, true, hd)
 +
elseif api_id or simple_naming then
 +
return Formatting:ship_card_damaged(api_id, self:unique_name(), self:type(), self._card_damaged_extension, simple_naming, hd)
 
end
 
end
return self._card_damaged
   
end
 
end
   −
function ShipData:battle_card()
+
function ShipData:battle_card(hd)
if self._battle_card then
+
if self._battle_card ~= nil then
 
return self._battle_card
 
return self._battle_card
 
elseif self._battle_card_reference then
 
elseif self._battle_card_reference then
 
Ship = Ship or require(self._constructor_module)
 
Ship = Ship or require(self._constructor_module)
return Ship:create_from_reference(self._battle_card_reference, self):battle_card()
+
return Ship:create_from_reference(self._battle_card_reference, self):battle_card(hd)
 
end
 
end
 
api_id = self:api_id()
 
api_id = self:api_id()
if api_id then
+
if api_id or hd then
return Formatting:ship_battle_card(api_id, self:unique_name(), self:type(), self._battle_card_extension)
+
return Formatting:ship_battle_card(api_id, self:unique_name(), self:type(), self._battle_card_extension, false, hd)
 
end
 
end
 
return self._battle_card
 
return self._battle_card
Line 153: Line 254:  
end
 
end
   −
function ShipData:battle_card_damaged()
+
function ShipData:battle_card_damaged(hd)
if self._battle_card_damaged then
+
if self._battle_card_damaged ~= nil then
 
return self._battle_card_damaged
 
return self._battle_card_damaged
 
elseif self._battle_card_damaged_reference then
 
elseif self._battle_card_damaged_reference then
 
Ship = Ship or require(self._constructor_module)
 
Ship = Ship or require(self._constructor_module)
return Ship:create_from_reference(self._battle_card_damaged_reference, self):battle_card_damaged()
+
return Ship:create_from_reference(self._battle_card_damaged_reference, self):battle_card_damaged(hd)
 
end
 
end
 
api_id = self:api_id()
 
api_id = self:api_id()
if api_id then
+
if api_id or hd then
return Formatting:ship_battle_card_damaged(api_id, self:unique_name(), self:type(), self._battle_card_damaged_extension)
+
    if self._can_debuff and api_id > 1500 then
 +
            return string.format("Enemy Banner %s Debuffed.png", self:unique_name():gsub("- Damaged", "Damaged"))
 +
        end
 +
return Formatting:ship_battle_card_damaged(api_id, self:unique_name(), self:type(), self._battle_card_damaged_extension, false, hd)
 
end
 
end
 
return self._battle_card_damaged
 
return self._battle_card_damaged
 
end
 
end
   −
function ShipData:cg()
+
function ShipData:cg(hd)
if self._cg then
+
if self._cg ~= nil then
 
return self._cg
 
return self._cg
 
elseif self._cg_reference then
 
elseif self._cg_reference then
 
Ship = Ship or require(self._constructor_module)
 
Ship = Ship or require(self._constructor_module)
return Ship:create_from_reference(self._cg_reference, self):cg()
+
return Ship:create_from_reference(self._cg_reference, self):cg(hd)
end
+
else
api_id = self:api_id()
+
    local api_id, simple_naming = self:api_id(), self:simple_naming()
if api_id then
+
    if not api_id and not self:type() then
return Formatting:ship_cg(api_id, self:unique_name(), self:type(), self._cg_extension)
+
        return Formatting:ship_cg(nil, self:unique_name(), nil, self._cg_extension, true, hd)
end
+
    elseif api_id or simple_naming then
return self._cg
+
    return Formatting:ship_cg(api_id, self:unique_name(), self:type(), self._cg_extension, simple_naming, hd)
 +
    end
 +
    end
 
end
 
end
   −
function ShipData:cg_damaged()
+
function ShipData:cg_damaged(hd)
if self._cg_damaged then
+
if self._cg_damaged ~= nil then
 
return self._cg_damaged
 
return self._cg_damaged
 
elseif self._cg_damaged_reference then
 
elseif self._cg_damaged_reference then
 
Ship = Ship or require(self._constructor_module)
 
Ship = Ship or require(self._constructor_module)
return Ship:create_from_reference(self._cg_damaged_reference, self):cg_damaged()
+
return Ship:create_from_reference(self._cg_damaged_reference, self):cg_damaged(hd)
 +
else
 +
    local api_id, simple_naming = self:api_id(), self:simple_naming()
 +
    if not api_id and not self:type() then
 +
        return Formatting:ship_cg_damaged(nil, self:unique_name(), nil, self._cg_damaged_extension, true, hd)
 +
    elseif api_id or simple_naming then
 +
        if self._can_debuff and api_id > 1500 then
 +
                return string.format("Enemy Full %s Debuffed.png", self:unique_name():gsub("- Damaged", "Damaged"))
 +
        end
 +
    return Formatting:ship_cg_damaged(api_id, self:unique_name(), self:type(), self._cg_damaged_extension, simple_naming, hd)
 +
    end
 
end
 
end
api_id = self:api_id()
+
end
if api_id then
+
 
return Formatting:ship_cg_damaged(api_id, self:unique_name(), self:type(), self._cg_damaged_extension)
+
function ShipData:accuracy()
end
+
return self._accuracy
return self._cg_damaged
+
end
 +
 
 +
function ShipData:morale()
 +
return self._morale
 
end
 
end
   Line 207: Line 326:  
end
 
end
   −
function ShipData:hp_leveled()
+
function ShipData:hp_mod()
 +
    local hp = self:hp()
 +
    local hp_max = self:hp_max()
 +
    return hp and hp_max and math.min(2, hp_max - hp)
 +
end
 +
 
 +
function ShipData:hp_mod_married()
 +
    local hp = self:hp_married()
 +
    local hp_max = self:hp_max()
 +
    return hp and hp_max and math.min(2, hp_max - hp)
 +
end
 +
 
 +
-- min(hp_max, hp + [4, 4, 4, 5, 6, 7, 7, 8, 8, 9][Math.floor(hp / 10)])
 +
function ShipData:hp_married()
 +
local bonuses = {
 +
[0] = 4,
 +
[1] = 4,
 +
[2] = 4,
 +
[3] = 5,
 +
[4] = 6,
 +
[5] = 7,
 +
[6] = 7,
 +
[7] = 8,
 +
[8] = 8,
 +
[9] = 9,
 +
}
 +
    local exceptions = {
 +
[131] = true, -- Yamato
 +
[143] = true, -- Musashi
 +
[163] = true, -- Maruyu
 +
-- [402] = true, -- Maruyu Kai (is +4, 7 -> 11)
 +
[171] = true, -- Bismarck
 +
[172] = true, -- Bismarck Kai
 +
[173] = true, -- Bismarck zwei
 +
[178] = true, -- Bismarck drei
 +
[275] = true, -- Nagato Kai
 +
[276] = true, -- Mutsu Kai
 +
[352] = true, -- Hayasui Kai
 +
[441] = true, -- Littorio
 +
[442] = true, -- Roma
 +
[446] = true, -- Italia
 +
[447] = true, -- Roma Kai
 +
[541] = true, -- Nagato Kai Ni
 +
}
 
local hp = self:hp()
 
local hp = self:hp()
if self._level and self._level > 100 then
+
local hp_max = self:hp_max()
return math.floor((self:hp_max() - hp) * (self._level - 99) / 51 + hp)
+
if not hp or not hp_max then
 +
return nil
 +
end
 +
-- not using exceptions should work as well
 +
if exceptions[self:api_id()] then
 +
return hp_max
 +
else
 +
local bonus = bonuses[math.floor(hp / 10)]
 +
if bonus then
 +
return math.min(hp_max, hp + bonus)
 +
else
 +
return nil
 +
end
 
end
 
end
return hp
   
end
 
end
   Line 238: Line 411:  
end
 
end
   −
function ShipData:firepower_leveled()
+
function ShipData:torpedo_leveled()
 
if self._torpedo_leveled then
 
if self._torpedo_leveled then
 
return self._torpedo_leveled
 
return self._torpedo_leveled
Line 253: Line 426:  
end
 
end
   −
function ShipData:firepower_leveled()
+
function ShipData:aa_leveled()
 
if self._aa_leveled then
 
if self._aa_leveled then
 
return self._aa_leveled
 
return self._aa_leveled
Line 283: Line 456:  
end
 
end
   −
function ShipData:asw_leveled()
+
function ShipData:asw_leveled(level)
if self._level then
+
if not level and self._level then
 +
level = self._level
 +
end
 +
if level then
 
local asw = self:asw()
 
local asw = self:asw()
return math.floor((self:asw_max() - asw) * self._level / 99 + asw)
+
if asw then
 +
return math.floor(((self:asw_max() or asw) - asw) * level / 99 + asw)
 +
end
 
end
 
end
 
return self:asw_max()
 
return self:asw_max()
Line 299: Line 477:  
end
 
end
   −
function ShipData:evasion_leveled()
+
function ShipData:evasion_leveled(level)
if self._level then
+
if not level and self._level then
 +
level = self._level
 +
end
 +
if level then
 
local evasion = self:evasion()
 
local evasion = self:evasion()
return math.floor((self:evasion_max() - evasion) * self._level / 99 + evasion)
+
if evasion then
 +
return math.floor(((self:evasion_max() or evasion) - evasion) * level / 99 + evasion)
 +
end
 
end
 
end
 
return self:evasion_max()
 
return self:evasion_max()
Line 315: Line 498:  
end
 
end
   −
function ShipData:los_leveled()
+
function ShipData:los_leveled(level)
if self._level then
+
if not level and self._level then
 +
level = self._level
 +
end
 +
if level then
 
local los = self:los()
 
local los = self:los()
return math.floor((self:los_max() - los) * self._level / 99 + los)
+
if los then
 +
return math.floor(((self:los_max() or los) - los) * level / 99 + los)
 +
end
 
end
 
end
 
return self:los_max()
 
return self:los_max()
Line 344: Line 532:  
function ShipData:buildable_lsc()
 
function ShipData:buildable_lsc()
 
return self._buildable_lsc
 
return self._buildable_lsc
 +
end
 +
 +
function ShipData:buildable_or()
 +
return self._buildable or self._buildable_lsc
 +
end
 +
 +
function ShipData:buildable_and()
 +
return self._buildable and self._buildable_lsc
 
end
 
end
    
function ShipData:build_time()
 
function ShipData:build_time()
 
return self._build_time
 
return self._build_time
 +
end
 +
 +
local function prepareDropData()
 +
if not dropData then
 +
dropData = require('Module:Data/ShipDrop')
 +
end
 +
end
 +
 +
function ShipData:dropable()
 +
prepareDropData()
 +
return dropData[self._name] and true or false
 
end
 
end
   Line 363: Line 570:     
function ShipData:remodel_cost()
 
function ShipData:remodel_cost()
return {fuel = false, ammo = self._remodel_ammo, steel = self._remodel_steel, bauxite = false}
+
return {
 +
    fuel = false,
 +
    ammo = self._remodel_ammo,
 +
    steel = self._remodel_steel,
 +
    bauxite = false,
 +
    devmat = self._remodel_development_material,
 +
    conmat = self._remodel_construction_material or false,
 +
    screw = self._remodel_screw or false,
 +
    }
 
end
 
end
    
function ShipData:remodel_blueprint()
 
function ShipData:remodel_blueprint()
 
return self._remodel_blueprint
 
return self._remodel_blueprint
 +
end
 +
 +
function ShipData:remodel_catapult()
 +
return self._remodel_catapult
 +
end
 +
 +
function ShipData:remodel_report()
 +
return self._remodel_report
 +
end
 +
 +
function ShipData:remodel_gunmat()
 +
return self._remodel_gunmat
 +
end
 +
 +
function ShipData:remodel_airmat()
 +
return self._remodel_airmat
 +
end
 +
 +
function ShipData:remodel_armament()
 +
return self._remodel_armament
 +
end
 +
 +
function ShipData:remodel_development_material()
 +
return self._remodel_development_material
 +
end
 +
 +
function ShipData:remodel_construction_material()
 +
return self._remodel_construction_material
 +
end
 +
 +
function ShipData:remodel_screw()
 +
return self._remodel_screw
 +
end
 +
 +
function ShipData:remodel_to_level()
 +
return self._remodel_to_level
 +
end
 +
 +
function ShipData:remodel_to_cost()
 +
return {
 +
    fuel = false,
 +
    ammo = self._remodel_to_ammo,
 +
    steel = self._remodel_to_steel,
 +
    bauxite = false,
 +
    devmat = self._remodel_to_development_material,
 +
    conmat = self._remodel_to_construction_material or false,
 +
    screw = self._remodel_to_screw or false,
 +
    }
 +
end
 +
 +
function ShipData:remodel_to_blueprint()
 +
return self._remodel_to_blueprint
 +
end
 +
 +
function ShipData:remodel_to_catapult()
 +
return self._remodel_to_catapult
 +
end
 +
 +
function ShipData:remodel_to_report()
 +
return self._remodel_to_report
 +
end
 +
 +
function ShipData:remodel_to_gunmat()
 +
return self._remodel_to_gunmat
 +
end
 +
 +
function ShipData:remodel_to_airmat()
 +
return self._remodel_to_airmat
 
end
 
end
   Line 375: Line 658:     
function ShipData:scrap()
 
function ShipData:scrap()
return {fuel = self._scrap_fuel, ammo = self._scrap_ammo, steel = self._scrap_steel, bauxite = self._scrap_baux}
+
return {fuel = self._scrap_fuel, ammo = self._scrap_ammo, steel = self._scrap_steel, bauxite = self._scrap_baux, devmat = false, conmat = false, screw = false}
 
end
 
end
   Line 401: Line 684:  
if equipment_slot then
 
if equipment_slot then
 
if type(equipment_slot.equipment) == "string" then
 
if type(equipment_slot.equipment) == "string" then
equipment_slot.equipment = Equipment(equipment_slot.equipment)
+
self:_prepare_Equipment()
 +
equipment_slot.equipment = Equipment(equipment_slot.equipment, self._enemy)
 
end
 
end
return equipment_slot.equipment, equipment_slot.size, equipment_slot.estimation
+
return equipment_slot.equipment, equipment_slot.size, equipment_slot.estimation, equipment_slot.stars
 
end
 
end
 
end
 
end
Line 410: Line 694:     
function ShipData:slots()
 
function ShipData:slots()
if self._equipment then
+
return self._slots or self:slots_length()
local i = 0
  −
for _, v in ipairs(self._equipment) do
  −
size = v.size
  −
if size ~= false then
  −
i = i + 1
  −
end
  −
end
  −
return i
  −
end
  −
return nil
   
end
 
end
   Line 451: Line 725:  
function ShipData:speed()
 
function ShipData:speed()
 
return self._speed
 
return self._speed
 +
end
 +
 +
function ShipData:formatted_speed()
 +
return Formatting:format_speed(self._speed)
 
end
 
end
   Line 457: Line 735:  
end
 
end
   −
function ShipData:air_power()
+
function ShipData:formatted_range()
 +
return Formatting:format_range(self._range)
 +
end
 +
 
 +
function ShipData:equipment_armor()
 +
    local armor = 0
 +
    for i = 1, self:slots_length() or 0 do
 +
        local equipment = self:slot(i)
 +
        if equipment then
 +
            armor = armor + (equipment:armor() or 0)
 +
        end
 +
    end
 +
    return armor
 +
end
 +
 
 +
function ShipData:air_power(count_recons)
 +
    if self._air_power then
 +
        return self._air_power
 +
    end
 
     local air_power = 0
 
     local air_power = 0
     for i = 1, self:slots() or 0 do
+
    local slots_length = self:slots_length()
 +
    if not slots_length then
 +
        air_power = self._as_rating
 +
    end
 +
     for i = 1, slots_length or 0 do
 
         local slot_equipment, slot_space = self:slot(i)
 
         local slot_equipment, slot_space = self:slot(i)
 
         if slot_equipment == nil or slot_space == nil then
 
         if slot_equipment == nil or slot_space == nil then
Line 473: Line 773:  
                 slot_equipment_type == 7 or  
 
                 slot_equipment_type == 7 or  
 
                 slot_equipment_type == 8 or  
 
                 slot_equipment_type == 8 or  
                 slot_equipment_type == 11) then
+
                 slot_equipment_type == 11 or
 +
                slot_equipment_type == 47 or
 +
                count_recons and slot_equipment_type == 10) then
 
                 air_power = air_power +  
 
                 air_power = air_power +  
 
                   math.floor(math.sqrt(slot_space) * slot_equipment_aa)
 
                   math.floor(math.sqrt(slot_space) * slot_equipment_aa)
Line 485: Line 787:  
     return air_power
 
     return air_power
 
end
 
end
+
 
 +
function ShipData:has_lbas_ha_bomber()
 +
    for i = 1, self:slots_length() or 0 do
 +
        local equipment = self:slot(i)
 +
        if equipment and equipment:is_lbas_ha_bomber() then
 +
            return true
 +
        end
 +
    end
 +
    return false
 +
end
 +
 
 +
function ShipData:air_power_estimation(count_recons)
 +
    return self._air_power_estimation
 +
end
 +
 
 +
function ShipData:gun_fit_properties(fit_group)
 +
if not self._gun_fit_properties then
 +
return nil
 +
else
 +
return self._gun_fit_properties[fit_group]
 +
end
 +
end
 +
 
 
function ShipData:night_bombing()
 
function ShipData:night_bombing()
 
return self._night_bombing
 
return self._night_bombing
 +
end
 +
 +
function ShipData:night_aviation_personnel()
 +
return self._night_aviation_personnel
 
end
 
end
   Line 500: Line 828:  
function ShipData:seasonal()
 
function ShipData:seasonal()
 
return self._seasonal
 
return self._seasonal
 +
end
 +
 +
--The voice actor for this ship. A string, or nil if unknown.
 +
--EXPERIMENTAL, DO NOT USE. Spec for this feature may rapidly change.
 +
function ShipData:voice_actor()
 +
if self._voice_actor ~= nil then
 +
return self._voice_actor
 +
elseif self._voice_actor_reference or self:remodel_from() then
 +
Ship = Ship or require(self._constructor_module)
 +
return Ship:create_from_reference(self._voice_actor_reference or self:remodel_from(), self):voice_actor()
 +
end
 +
    return self._voice_actor
 +
end
 +
 +
--The artist for this ship. A string, or nil if unknown.
 +
--EXPERIMENTAL, DO NOT USE. Spec for this feature may rapidly change.
 +
function ShipData:artist()
 +
if self._artist ~= nil then
 +
return self._artist
 +
elseif self._artist_reference or self:remodel_from() then
 +
Ship = Ship or require(self._constructor_module)
 +
return Ship:create_from_reference(self._artist_reference or self:remodel_from(), self):artist()
 +
end
 +
    return self._artist
 +
end
 +
 +
--The availability for this ship.
 +
--false = not available.
 +
--nil = unknown.
 +
--Otherwise a table with obtainment methods under numeric keys and optional detailed data under the obtainment method key.
 +
--E.g. {"drop", "event_reward", "event_drop",
 +
--      drop = {{1/*world*/, 4/*map*/, "B"/*node*/, 3/*formation (optional)*/}, {3, 2, "A"}},
 +
--      event_reward = {{2016/*year*/, 4/*1 = winter, 4 = spring, 7 = summer, 10 = fall*/, 5/*map*/}},
 +
--      event_drop = {{2016, 4, 7, "N"}}}
 +
--EXPERIMENTAL, DO NOT USE. Spec for this feature may rapidly change.
 +
function ShipData:availability()
 +
    if self:remodel_from() then
 +
Ship = Ship or require(self._constructor_module)
 +
return Ship:create_from_reference(self:remodel_from(), self):availability()
 +
else
 +
    return self._availability
 +
end
 +
end
 +
 +
function ShipData:implementation_date()
 +
if self._implementation_date ~= nil then
 +
return self._implementation_date
 +
elseif self._implementation_date_reference or self:remodel_from() then
 +
Ship = Ship or require(self._constructor_module)
 +
return Ship:create_from_reference(self._implementation_date_reference or self:remodel_from(), self):implementation_date()
 +
end
 +
    return self._implementation_date
 +
end
 +
 +
function ShipData:implementation_date_string()
 +
local date = self:implementation_date()
 +
    return not date and "??" or string.format("%s/%s/%s", date[1], date[2] < 10 and "0" .. date[2] or date[2], date[3] < 10 and "0" .. date[3] or date[3])
 +
end
 +
 +
function ShipData:_prepare_Equipment()
 +
if not Equipment then
 +
Equipment = require('Module:Equipment')
 +
end
 
end
 
end
    
function ShipData:create(ship)
 
function ShipData:create(ship)
 
ship = ship or {}
 
ship = ship or {}
if ship._class then
+
-- apparently wikia (mediawiki?) can have shared state between invokes
 +
if type(ship._class) == 'string' then
 
ship._class = ShipClass(ship._class)
 
ship._class = ShipClass(ship._class)
 
end
 
end
cssedit, gkautomate
6,928

edits