Changes

no edit summary
Line 3: Line 3:  
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 13: Line 15:  
     sep = sep or " "
 
     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() .. sep .. suffix
 
return self:base_name() .. sep .. suffix
 
else
 
else
Line 26: Line 28:  
     sep = sep or " "
 
     sep = sep or " "
 
local suffix = self:suffix()
 
local suffix = self:suffix()
if suffix then
+
if suffix and suffix ~= "" then
 
return self:base_name() .. sep .. self:suffix()
 
return self:base_name() .. sep .. self:suffix()
 
else
 
else
Line 40: Line 42:  
end
 
end
 
return self:base_name()
 
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
 
end
   Line 64: Line 75:  
if self._page then
 
if self._page then
 
return self._page, self:unique_name()
 
return self._page, self:unique_name()
else
+
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()
 
return self:unique_name()
 
end
 
end
Line 117: 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 141: 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 155: Line 206:  
end
 
end
   −
function ShipData:card()
+
function ShipData:card(hd)
 
if self._card ~= nil then
 
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 ~= nil 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 ~= nil 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 201: Line 254:  
end
 
end
   −
function ShipData:battle_card_damaged()
+
function ShipData:battle_card_damaged(hd)
 
if self._battle_card_damaged ~= nil 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 ~= nil 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)
 
else
 
else
 
    local api_id, simple_naming = self:api_id(), self:simple_naming()
 
    local api_id, simple_naming = self:api_id(), self:simple_naming()
 
    if not api_id and not self:type() then
 
    if not api_id and not self:type() then
        return Formatting:ship_cg(nil, self:unique_name(), nil, self._cg_extension, true)
+
        return Formatting:ship_cg(nil, self:unique_name(), nil, self._cg_extension, true, hd)
 
    elseif api_id or simple_naming then
 
    elseif api_id or simple_naming then
    return Formatting:ship_cg(api_id, self:unique_name(), self:type(), self._cg_extension, simple_naming)
+
    return Formatting:ship_cg(api_id, self:unique_name(), self:type(), self._cg_extension, simple_naming, hd)
 
    end
 
    end
 
     end
 
     end
 
end
 
end
   −
function ShipData:cg_damaged()
+
function ShipData:cg_damaged(hd)
 
if self._cg_damaged ~= nil 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
 
else
 
    local api_id, simple_naming = self:api_id(), self:simple_naming()
 
    local api_id, simple_naming = self:api_id(), self:simple_naming()
 
    if not api_id and not self:type() then
 
    if not api_id and not self:type() then
        return Formatting:ship_cg_damaged(nil, self:unique_name(), nil, self._cg_damaged_extension, true)
+
        return Formatting:ship_cg_damaged(nil, self:unique_name(), nil, self._cg_damaged_extension, true, hd)
 
    elseif api_id or simple_naming then
 
    elseif api_id or simple_naming then
    return Formatting:ship_cg_damaged(api_id, self:unique_name(), self:type(), self._cg_damaged_extension, simple_naming)
+
        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
 
end
Line 473: 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 499: Line 577:  
    devmat = self._remodel_development_material,
 
    devmat = self._remodel_development_material,
 
    conmat = self._remodel_construction_material or false,
 
    conmat = self._remodel_construction_material or false,
    screw = false
+
    screw = self._remodel_screw or false,
 
     }
 
     }
 
end
 
end
Line 509: Line 587:  
function ShipData:remodel_catapult()
 
function ShipData:remodel_catapult()
 
return self._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
 
end
   Line 523: Line 629:  
    devmat = self._remodel_to_development_material,
 
    devmat = self._remodel_to_development_material,
 
    conmat = self._remodel_to_construction_material or false,
 
    conmat = self._remodel_to_construction_material or false,
    screw = false
+
    screw = self._remodel_to_screw or false,
 
     }
 
     }
 
end
 
end
Line 533: Line 639:  
function ShipData:remodel_to_catapult()
 
function ShipData:remodel_to_catapult()
 
return self._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 567: Line 685:  
if type(equipment_slot.equipment) == "string" then
 
if type(equipment_slot.equipment) == "string" then
 
self:_prepare_Equipment()
 
self:_prepare_Equipment()
equipment_slot.equipment = Equipment(equipment_slot.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 607: 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
    
function ShipData:range()
 
function ShipData:range()
 
return self._range
 
return self._range
 +
end
 +
 +
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
 
end
   Line 637: Line 774:  
                 slot_equipment_type == 8 or  
 
                 slot_equipment_type == 8 or  
 
                 slot_equipment_type == 11 or
 
                 slot_equipment_type == 11 or
 +
                slot_equipment_type == 47 or
 
                 count_recons and slot_equipment_type == 10) then
 
                 count_recons and slot_equipment_type == 10) then
 
                 air_power = air_power +  
 
                 air_power = air_power +  
Line 648: Line 786:  
     end
 
     end
 
     return air_power
 
     return air_power
 +
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
 
end
   Line 660: Line 812:  
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 716: Line 872:  
end
 
end
   −
--The implementation date for this ship. A 3-tuple of year, month, day (JST) as a table, or nil if unknown.
  −
--EXPERIMENTAL, DO NOT USE. Spec for this feature may rapidly change.
   
function ShipData:implementation_date()
 
function ShipData:implementation_date()
 
if self._implementation_date ~= nil then
 
if self._implementation_date ~= nil then
Line 726: Line 880:  
end
 
end
 
     return self._implementation_date
 
     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
 
end
   Line 736: Line 895:  
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,926

edits