Changes

m
14 revisions imported
Line 3: Line 3:  
local Ship = require('Module:Ship')
 
local Ship = require('Module:Ship')
   −
local format = require('Module:StringInterpolation').format
+
local format = require('Module:Core').format
   −
local ShipCategoriesKai = BaseData{}
+
local ShipCategoriesKai = BaseData{
 +
_type_category_template = "Category:${ship_type}s",
 +
_stock_equipment_category_template = "Category:Ships with ${equipment_name} as stock equipment",
 +
}
    
function ShipCategoriesKai:Categories(args)
 
function ShipCategoriesKai:Categories(args)
 
return self{
 
return self{
 
_args = args
 
_args = args
}:create_categories()
+
}:get_categories()
 
end
 
end
   Line 27: Line 30:  
local ship_type = self._ship:type()
 
local ship_type = self._ship:type()
 
if ship_type then
 
if ship_type then
table.insert(self._categories, format{"Category:${ship_type}s", ship_type = Formatting:format_ship_type(ship_type)})
+
table.insert(self._categories, format{self._type_category_template, ship_type = Formatting:format_ship_type(ship_type)})
 
end
 
end
 
end
 
end
Line 56: Line 59:     
function ShipCategoriesKai:create_remodel_categories()
 
function ShipCategoriesKai:create_remodel_categories()
local remodel_blueprint = self._ship:remodel_blueprint()
+
if self._ship:remodel_blueprint() then
if remodel_blueprint then
+
table.insert(self._categories, 'Category:Ships that consume Blueprint during remodeling')
table.insert(self._categories, format{"Category:Ships that require a blueprint for remodelling"})
+
end
 +
if self._ship:remodel_catapult() then
 +
table.insert(self._categories, 'Category:Ships that consume Prototype Flight Deck Catapult during remodeling')
 +
end
 +
if self._ship:remodel_report() then
 +
table.insert(self._categories, 'Category:Ships that consume Action Report during remodeling')
 +
end
 +
if self._ship:remodel_gunmat() then
 +
table.insert(self._categories, 'Category:Ships that consume New Model Gun Mount Improvement Material during remodeling')
 +
end
 +
if self._ship:remodel_airmat() then
 +
table.insert(self._categories, 'Category:Ships that consume New Model Aerial Armament Material during remodeling')
 +
end
 +
if self._ship:remodel_armament() then
 +
table.insert(self._categories, 'Category:Ships that consume New Model Armament Material during remodeling')
 +
end
 +
if self._ship:remodel_development_material() then
 +
table.insert(self._categories, 'Category:Ships that consume Development Material during remodeling')
 +
end
 +
if self._ship:remodel_construction_material() then
 +
table.insert(self._categories, 'Category:Ships that consume Instant Construction Material during remodeling')
 
end
 
end
 
end
 
end
    
function ShipCategoriesKai:create_stock_equipment_categories()
 
function ShipCategoriesKai:create_stock_equipment_categories()
local slots = self._ship:slots()
+
local slots = self._ship:slots_length()
 
if slots then
 
if slots then
 
for i = 1, slots do
 
for i = 1, slots do
 
local equipment, size = self._ship:slot(i)
 
local equipment, size = self._ship:slot(i)
 
if equipment then
 
if equipment then
table.insert(self._categories, format{"Category:Ships with ${equipment_name} as stock equipment", equipment_name = equipment:common_name()})
+
table.insert(self._categories, format{self._stock_equipment_category_template, equipment_name = equipment:link()})
 
end
 
end
 
end
 
end
Line 82: Line 105:  
end
 
end
   −
function ShipCategoriesKai:create_categories()
+
function ShipCategoriesKai:get_categories()
 
self._categories = {}
 
self._categories = {}
 
self:create_ship()
 
self:create_ship()
 
if self._ship then
 
if self._ship then
self:create_static_categories()
+
self:create_categories()
self:create_type_categories()
  −
self:create_class_categories()
  −
--self:create_rarity_categories()
  −
self:create_construction_categories()
  −
self:create_remodel_categories()
  −
self:create_stock_equipment_categories()
   
end
 
end
 
return self:write_categories()
 
return self:write_categories()
 +
end
 +
 +
function ShipCategoriesKai:create_categories()
 +
self:create_static_categories()
 +
self:create_type_categories()
 +
self:create_class_categories()
 +
--self:create_rarity_categories()
 +
self:create_construction_categories()
 +
self:create_remodel_categories()
 +
self:create_stock_equipment_categories()
 
end
 
end
    
return ShipCategoriesKai
 
return ShipCategoriesKai
Bots, gkautomate
12,557

edits