• 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 BaseTable = require('Module:BaseTable')
 
local BaseTable = require('Module:BaseTable')
 +
local EnemyColors = require('Module:EnemyColors')
 
local EnemyShip = require('Module:EnemyShip')
 
local EnemyShip = require('Module:EnemyShip')
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
 
local ShipBattleCardKai = require('Module:ShipBattleCardKai')
 
local ShipBattleCardKai = require('Module:ShipBattleCardKai')
local StatIcons = require('Module:StatIcons')
+
local ShipCapabilities = require('Module:ShipCapabilities')
 +
local StatIcons = require('Module:Data/Asset')
 +
local Iterator = require('Module:Iterator')
 +
local EquipInfo = require('Module:EquipmentInfoKai')
   −
local format = require('Module:StringInterpolation').format
+
local format = require('Module:Core').format
    
local EnemyShipListKai = BaseTable{
 
local EnemyShipListKai = BaseTable{
Line 18: Line 22:  
! style="width: 30px; text-align: center; vertical-align: middle; background-color: #F2E279;" | ${armor}
 
! style="width: 30px; text-align: center; vertical-align: middle; background-color: #F2E279;" | ${armor}
 
! style="width: 30px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion}
 
! style="width: 30px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion}
! style="text-align: center; vertical-align: middle;" | Equipment
+
! style="text-align: center; vertical-align: middle;" | Armament
! style="text-align:left;" | Notes]],
+
! style="text-align:left;" | Notes
 +
! OASW
 +
! Opening Torpedo
 +
! Night Bombing
 +
! AACI]],
 
_columns = {
 
_columns = {
 
"card",
 
"card",
Line 31: Line 39:  
"armor",
 
"armor",
 
"evasion",
 
"evasion",
"equipment",
+
"armament",
 
"notes",
 
"notes",
 +
"oasw",
 +
"otorp",
 +
"nightbombing",
 +
"aaci",
 
},
 
},
 +
_cell = [[|style="text-align:${text_align};background-color:${bg_color}"|${value}]],
 
_column_cell_templates = {
 
_column_cell_templates = {
card = [[| style="text-align: ${text_align}; padding:5px 5px 5px 5px; background-color: ${bg_color};" |${value}]],
+
card = [[|style="text-align:${text_align};background-color:${bg_color};background-image:${background_image}" |${value}]],
 +
--card = [[|style="text-align:${text_align}"|${value}]],
 
},
 
},
_cell = [[| style="text-align: ${text_align}; padding:5px 5px 5px 5px;" |${value}]],
   
_item_class = function(item_key) return EnemyShip(item_key) end,
 
_item_class = function(item_key) return EnemyShip(item_key) end,
 
_fragment_prefix = "enemyshiplistkai",
 
_fragment_prefix = "enemyshiplistkai",
_icon_caption_template = "${equipment} ${equipment_type}",
+
_icon_caption_template = "${equipment} - ${equipment_type}",
 +
_installation_label = "Installation",
 +
_pillbox_label = "Pillbox",
 +
_opening_torpedo_label = "Opening Torpedo",
 +
_air_power_template = "${air_power} Air Power",
 +
_night_bombing_label = "Night Bombing",
 +
_asw_label = "ASW",
 +
_high_asw_label = "High ASW",
 +
_estimation_label = "Estimation",
 
}
 
}
    
function EnemyShipListKai:name(ship)
 
function EnemyShipListKai:name(ship)
local name = ship:name()
+
local name = Formatting:format_link(ship:link())
 
local value = {name}
 
local value = {name}
 
local japanese_name = ship:japanese_name()
 
local japanese_name = ship:japanese_name()
 
if japanese_name and name ~= japanese_name then
 
if japanese_name and name ~= japanese_name then
 +
local reading = ship:reading()
 +
if reading then
 +
japanese_name = Formatting:japanese_text(japanese_name, reading)
 +
end
 
table.insert(value, Formatting:format_stat(japanese_name))
 
table.insert(value, Formatting:format_stat(japanese_name))
 
end
 
end
return {value = Formatting:id_span(tostring(ship:api_id() or mw.ustring.lower(mw.ustring.gsub(ship:name(), "%s+"))), self._fragment_prefix, table.concat(value, "<br />")), text_align = self._start_align}
+
return {value = Formatting:id_span(tostring(ship:api_id() or mw.ustring.lower(mw.ustring.gsub(ship:name(), "%s+"))), self._fragment_prefix, table.concat(value, "<br />")), bg_color = self._transparent, text_align = self._start_align}
 
end
 
end
    
function EnemyShipListKai:card(ship)
 
function EnemyShipListKai:card(ship)
 
local value
 
local value
local bg_color = Formatting:format_ship_back(ship:back())
+
local bg_color, background_image = EnemyColors:rarity_colors(ship)
 +
background_image = EnemyColors:variant_background_image(ship, background_image)
 
if ship == false then
 
if ship == false then
 
value = Formatting:format_image{self._blank, size = self._size}
 
value = Formatting:format_image{self._blank, size = self._size}
 
else
 
else
value = ShipBattleCardKai:get{ship = ship, size = self._size, link = ship:link(), caption = ship:name()}
+
value = ShipBattleCardKai:get{ship = ship, size = self._size, link = ship:link(), hd = true, size = '160px', caption = ship:name()}
 
end
 
end
return {value = value, bg_color = bg_color, text_align = self._center_align}
+
return {
 +
value = value,
 +
bg_color = bg_color,
 +
background_image = background_image or self._none,
 +
text_align = self._center_align,
 +
}
 
end
 
end
    
function EnemyShipListKai:type(ship)
 
function EnemyShipListKai:type(ship)
return {value = Formatting:format_ship_code(ship:type()), text_align = self._start_align}
+
return {value = Formatting:format_ship_code(ship:type()), bg_color = self._transparent, text_align = self._start_align}
 
end
 
end
    
function EnemyShipListKai:firepower(ship)
 
function EnemyShipListKai:firepower(ship)
return {value = Formatting:format_stat(ship:firepower()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:firepower()), bg_color = "#e6cfcf", text_align = self._center_align}
 
end
 
end
    
function EnemyShipListKai:torpedo(ship)
 
function EnemyShipListKai:torpedo(ship)
return {value = Formatting:format_stat(ship:torpedo()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:torpedo()), bg_color = "#cfdde6", text_align = self._center_align}
 
end
 
end
    
function EnemyShipListKai:aa(ship)
 
function EnemyShipListKai:aa(ship)
return {value = Formatting:format_stat(ship:aa()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:aa()), bg_color = "#e6d9cf", text_align = self._center_align}
 
end
 
end
    
function EnemyShipListKai:asw(ship)
 
function EnemyShipListKai:asw(ship)
return {value = Formatting:format_stat(ship:asw()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:asw()), bg_color = "#d2cee6", text_align = self._center_align}
 
end
 
end
    
function EnemyShipListKai:hp(ship)
 
function EnemyShipListKai:hp(ship)
return {value = Formatting:format_stat(ship:hp()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:hp()), bg_color = "#f0d9dd", text_align = self._center_align}
 
end
 
end
    
function EnemyShipListKai:armor(ship)
 
function EnemyShipListKai:armor(ship)
return {value = Formatting:format_stat(ship:armor()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:armor()), bg_color = "#e6e3cf", text_align = self._center_align}
 
end
 
end
    
function EnemyShipListKai:evasion(ship)
 
function EnemyShipListKai:evasion(ship)
return {value = Formatting:format_stat(ship:evasion()), text_align = self._center_align}
+
return {value = Formatting:format_stat(ship:evasion()), bg_color = "#e6cee6", text_align = self._center_align}
 
end
 
end
   −
function EnemyShipListKai:equipment(ship)
+
function EnemyShipListKai:armament(ship)
local icons = {}
+
local icons, roles = {}, {}
 +
local sonar, dc, air_power, active_midget_submarine = false, false, false, false
 +
 
 
for i = 1, ship:slots_length() do
 
for i = 1, ship:slots_length() do
local equipment, size, estimation, icon, equipment_type, equipment_link = ship:slot(i)
+
local equipment, size, estimation = ship:slot(i)
 +
local icon, equipment_type, equipment_link
 
if equipment then
 
if equipment then
 
icon = equipment:icon()
 
icon = equipment:icon()
 
equipment_type = equipment:type()
 
equipment_type = equipment:type()
 +
if ShipCapabilities:_is_air_power_plane(equipment) then
 +
air_power = true
 +
elseif ShipCapabilities:_is_sonar(equipment) then
 +
sonar = true
 +
elseif ShipCapabilities:_is_depth_charge(equipment) then
 +
dc = true
 +
end
 +
local real_equipment = equipment:link()
 +
equipment = real_equipment or equipment
 +
equipment_link = equipment
 +
--[[
 
equipment_link, equipment = Formatting:format_link(equipment:link())
 
equipment_link, equipment = Formatting:format_link(equipment:link())
 
equipment = equipment or equipment_link
 
equipment = equipment or equipment_link
 +
]]
 
else
 
else
 
icon = disabled and "" or false
 
icon = disabled and "" or false
Line 116: Line 162:  
table.insert(icons, icon)
 
table.insert(icons, icon)
 
end
 
end
return {value = table.concat(icons), text_align = self._start_align}
+
if air_power then
 +
    local ap_text = format{self._air_power_template, air_power = Formatting:format_stat(ship:air_power())}
 +
    if ship:air_power_estimation() then
 +
        ap_text = Formatting:tooltip(ap_text, self._estimation_label)
 +
        end
 +
table.insert(roles, ap_text)
 +
end
 +
if sonar or dc then
 +
if sonar and dc then
 +
table.insert(roles, self._high_asw_label)
 +
else
 +
table.insert(roles, self._asw_label)
 +
end
 +
end
 +
 
 +
return {value = table.concat(icons) .. '<br/>' .. table.concat(roles, ", "), bg_color = self._transparent, text_align = self._start_align}
 
end
 
end
    
function EnemyShipListKai:notes(ship)
 
function EnemyShipListKai:notes(ship)
 
local note = self._notes[ship]
 
local note = self._notes[ship]
 +
local back = ship:back() or 0
 +
local value = {}
 +
if back < -1 then
 +
table.insert(value, tostring(mw.html.create('span'):css({color = Formatting:format_ship_back(back)}):tag('b'):wikitext(Formatting:format_ship_rarity(back)):allDone()))
 +
end
 +
if ship:speed() == 0 then
 +
table.insert(value, tostring(mw.html.create('b'):wikitext(ship:is_pillbox() and self._pillbox_label or self._installation_label)))
 +
end
 
if note then
 
if note then
return {value = note.note or "", text_align = self._start_align}
+
table.insert(value, note.note or "")
 +
end
 +
return {value = table.concat(value, "<br/>"), bg_color = self._transparent, text_align = self._start_align}
 +
end
 +
 
 +
function EnemyShipListKai:oasw(ship)
 +
local capabilities = ShipCapabilities{_ship = ship}
 +
local value = {}
 +
local attack_power, opening, day, night, uncertain = capabilities:asw_attack()
 +
local label = opening and "Yes" or "No"
 +
 +
return {value = label, bg_color = opening and "green" or self._transparent, text_align = self._start_align}
 +
end
 +
 
 +
function EnemyShipListKai:otorp(ship)
 +
local roles = {}
 +
local active_midget_submarine = false
 +
 
 +
for i = 1, ship:slots_length() do
 +
local equipment, size, estimation = ship:slot(i)
 +
if equipment then
 +
if ShipCapabilities._is_active_midget_submarine(equipment) then
 +
active_midget_submarine = true
 +
end
 +
end
 +
end
 +
 +
local can_otorp = false
 +
 +
if ShipCapabilities:_is_submarine(ship) then
 +
if ship:suffix() and (ship:suffix():match("Elite") or ship:suffix():match("Flagship")) then
 +
can_otorp = true
 +
end
 +
elseif active_midget_submarine then
 +
can_otorp = true
 +
end
 +
local label = can_otorp and "Yes" or "No"
 +
 
 +
return {value = label, bg_color = can_otorp and "green" or self._transparent, text_align = self._start_align}
 +
end
 +
 
 +
function EnemyShipListKai:nightbombing(ship)
 +
local roles = {}
 +
local can_night = false
 +
 
 +
if ShipCapabilities:_is_night_bombing(ship) then
 +
can_night = true
 +
end
 +
local label = can_night and "Yes" or "No"
 +
 
 +
return {value = label, bg_color = can_night and "green" or self._transparent, text_align = self._start_align}
 +
end
 +
 
 +
function EnemyShipListKai:aaci(ship)
 +
local ha_aafd, cd_mg, other_mg, air_radar = 0, 0, 0, 0
 +
 
 +
for i = 1, ship:slots_length() do
 +
local equipment, size, estimation = ship:slot(i)
 +
local equipment_type
 +
if equipment then
 +
equipment_type = equipment:type()
 +
 +
if ShipCapabilities:_is_main_gun(equipment) or ShipCapabilities:_is_secondary_gun(equipment) then
 +
if equipment:is_aafd() then
 +
ha_aafd = ha_aafd + 1
 +
end
 +
elseif ShipCapabilities:_is_radar(equipment) then
 +
if equipment:aa() and equipment:aa() > 2 then
 +
air_radar = air_radar + 1
 +
end
 +
elseif equipment_type == 21 then --AA guns
 +
if equipment:aa() >= 9 then
 +
cd_mg = cd_mg + 1
 +
elseif equipment:aa() >= 3 then
 +
other_mg = other_mg + 1
 +
end
 +
end
 +
end
 +
end
 +
 +
local can_aaci = true
 +
local api = nil
 +
 +
if ha_aafd >= 2 and air_radar >= 1 then
 +
api = 5
 +
elseif ha_aafd >= 1 and air_radar >= 1 then
 +
api = 8
 +
elseif cd_mg >= 1 and other_mg >= 1 and air_radar >= 1 then
 +
api = 12
 +
else
 +
can_aaci = false
 
end
 
end
return {value = "", text_align = self._start_align}
+
local label = can_aaci and "API: " .. api or "No"
 +
 
 +
return {value = label, bg_color = can_aaci and "green" or self._transparent, text_align = self._start_align}
 
end
 
end
   Line 151: Line 312:  
return EnemyShipListKai:Table(args)
 
return EnemyShipListKai:Table(args)
 
end
 
end
 +
 +
-- * Tests.
 +
function EnemyShipListKai.test()
 +
    function testList(name, args)
 +
    local names = {}
 +
        local iterator = Iterator[name](args)
 +
        local i = 0
 +
        while iterator.next() do
 +
            names[i] = iterator.current() or '?'
 +
            i = i + 1
 +
        end
 +
        return names
 +
    end
 +
   
 +
    local result = testList('enemiesByTypeAndInstallationAndBoss', { type = '9', boss = 'no', installation='yes'})
 +
    mw.log(EnemyShipListKai:Table(result))
 +
   
 +
    result = testList('enemiesByTypeAndInstallationAndBoss', { type = '2', boss = 'no' , listBase = 'true'})
 +
mw.log(EnemyShipListKai:Table(result))
 +
 +
    result = testList('enemiesByTypeAndInstallationAndBoss', { type = '-13', boss = 'yes' , installation = 'no'})
 +
mw.log(EnemyShipListKai:Table(result))
 +
end
 +
-- p.test()
    
return EnemyShipListKai
 
return EnemyShipListKai
cssedit, gkautomate
7,064

edits

Navigation menu