| Line 7: |
Line 7: |
| | local StatIcons = require('Module:Data/Asset') | | local StatIcons = require('Module:Data/Asset') |
| | local Iterator = require('Module:Iterator') | | local Iterator = require('Module:Iterator') |
| | + | local EquipInfo = require('Module:EquipmentInfoKai') |
| | | | |
| | local format = require('Module:Core').format | | local format = require('Module:Core').format |
| | | | |
| | local EnemyShipListKai = BaseTable{ | | local EnemyShipListKai = BaseTable{ |
| − | _header_template = [[! style="min-width: 180px;" | Card | + | _table_start = [[{| class="wikitable" style="text-align:center" ]], |
| − | ! style="min-width: 75px;" | Name | + | _header_template = [[! style="min-width:180px" | Card |
| | + | ! style="min-width:75px" | Name |
| | ! Type | | ! Type |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: pink;" | ${hp} | + | ! style="width:30px;background-color:pink" | ${hp} |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightcoral;" | ${firepower} | + | ! style="width:30px;background-color:lightcoral" | ${firepower} |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightskyblue;" | ${torpedo} | + | ! style="width:30px;background-color:lightskyblue" | ${torpedo} |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: sandybrown;" | ${aa} | + | ! style="width:30px;background-color:sandybrown" | ${aa} |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: #9C8FEE;" | ${asw} | + | ! style="width:30px;background-color:#9C8FEE" | ${asw} |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: #F2E279;" | ${armor} | + | ! style="width:30px;background-color:#F2E279" | ${armor} |
| − | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion} | + | ! style="width:30px;background-color:violet" | ${evasion} |
| − | ! style="text-align: center; vertical-align: middle;" | Armament | + | ! Armament |
| − | ! style="text-align:left;" | Notes | + | ! Notes |
| − | ! style="text-align:left;" | OASW]], | + | ! OASW |
| | + | ! Opening Torpedo |
| | + | ! Night Bombing |
| | + | ! AACI]], |
| | _columns = { | | _columns = { |
| | "card", | | "card", |
| Line 37: |
Line 42: |
| | "armament", | | "armament", |
| | "notes", | | "notes", |
| − | "OASW", | + | "oasw", |
| | + | "otorp", |
| | + | "nightbombing", |
| | + | "aaci", |
| | }, | | }, |
| − | _cell = [[|style="text-align:${text_align};background-color:${bg_color}"|${value}]], | + | _cell = [[|style="background-color:${bg_color}"|${value}]], |
| | _column_cell_templates = { | | _column_cell_templates = { |
| − | -- card = [[|style="text-align:${text_align};background-color:${bg_color};background-image:${background_image}" |${value}]], | + | card = [[|style="background-color:${bg_color};background-image:${background_image}" |${value}]], |
| − | card = [[|style="text-align:${text_align}"|${value}]], | + | --card = [[|style="text-align:${text_align}"|${value}]], |
| | }, | | }, |
| | _item_class = function(item_key) return EnemyShip(item_key) end, | | _item_class = function(item_key) return EnemyShip(item_key) end, |
| Line 82: |
Line 90: |
| | return { | | return { |
| | value = value, | | value = value, |
| − | -- bg_color = bg_color, | + | bg_color = bg_color, |
| − | -- background_image = background_image or self._none, | + | background_image = background_image or self._none, |
| | text_align = self._center_align, | | text_align = self._center_align, |
| | } | | } |
| Line 136: |
Line 144: |
| | elseif ShipCapabilities:_is_depth_charge(equipment) then | | elseif ShipCapabilities:_is_depth_charge(equipment) then |
| | dc = true | | dc = true |
| − | elseif ShipCapabilities._is_active_midget_submarine(equipment) then
| |
| − | active_midget_submarine = true
| |
| | end | | end |
| | local real_equipment = equipment:link() | | local real_equipment = equipment:link() |
| Line 156: |
Line 162: |
| | end | | end |
| | table.insert(icons, icon) | | table.insert(icons, icon) |
| − | end
| |
| − | if ShipCapabilities:_is_submarine(ship) then
| |
| − | if ship:suffix() and (ship:suffix():match("Elite") or ship:suffix():match("Flagship")) then
| |
| − | table.insert(roles, self._opening_torpedo_label)
| |
| − | end
| |
| − | elseif active_midget_submarine then
| |
| − | table.insert(roles, self._opening_torpedo_label)
| |
| | end | | end |
| | if air_power then | | if air_power then |
| Line 170: |
Line 169: |
| | end | | end |
| | table.insert(roles, ap_text) | | table.insert(roles, ap_text) |
| − | end
| |
| − | if ShipCapabilities:_is_night_bombing(ship) then
| |
| − | table.insert(roles, self._night_bombing_label)
| |
| | end | | end |
| | if sonar or dc then | | if sonar or dc then |
| Line 201: |
Line 197: |
| | end | | end |
| | | | |
| − | function EnemyShipListKai:OASW(ship) | + | function EnemyShipListKai:oasw(ship) |
| | local capabilities = ShipCapabilities{_ship = ship} | | local capabilities = ShipCapabilities{_ship = ship} |
| | local value = {} | | local value = {} |
| | local attack_power, opening, day, night, uncertain = capabilities:asw_attack() | | local attack_power, opening, day, night, uncertain = capabilities:asw_attack() |
| − | table.insert(value, opening and "Yes" or "No") | + | 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 |
| | | | |
| − | return {value = table.concat(value, "<br/>"), bg_color = opening and "green" or self._transparent, text_align = self._start_align} | + | 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 |
| | + | 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 248: |
Line 327: |
| | end | | end |
| | | | |
| − | local result = testList('enemiesByTypeAndInstallationAndBoss', { type = '2', boss = 'no' , listBase = 'true'}) | + | 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)) | | mw.log(EnemyShipListKai:Table(result)) |
| | | | |