Line 1: |
Line 1: |
| local EnemyShip = require('Module:EnemyShip') | | local EnemyShip = require('Module:EnemyShip') |
| local ShipCapabilities = require('Module:ShipCapabilities') | | local ShipCapabilities = require('Module:ShipCapabilities') |
| + | local ShipGraphicKai = require('Module:ShipGraphicKai') |
| local ShipInfoKai = require('Module:ShipInfoKai') | | local ShipInfoKai = require('Module:ShipInfoKai') |
| local Formatting = require('Module:Formatting') | | local Formatting = require('Module:Formatting') |
| + | local Tabber = require('Module:Tabber') |
| | | |
− | local format = require('Module:StringInterpolation').format | + | local format = require('Module:Core').format |
| | | |
| local EnemyShipInfoKai = ShipInfoKai{ | | local EnemyShipInfoKai = ShipInfoKai{ |
− | _template = [[{|class="${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 320px;" | + | _template = [[{|class="typography-xl-optout ${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 320px;" |
| |- | | |- |
| | colspan="6" style="position: relative; text-align: center; padding: 1px 40px; background-color: ${top_bg_color};${top_extra_style}" | <div style="position: absolute; right: 5px;">${edit_link}</div> | | | colspan="6" style="position: relative; text-align: center; padding: 1px 40px; background-color: ${top_bg_color};${top_extra_style}" | <div style="position: absolute; right: 5px;">${edit_link}</div> |
Line 60: |
Line 62: |
| <div style="background-color: lightskyblue; text-align: center; margin: 0px;">'''Extra Statistics'''</div> | | <div style="background-color: lightskyblue; text-align: center; margin: 0px;">'''Extra Statistics'''</div> |
| <div class="mw-collapsible-content"> | | <div class="mw-collapsible-content"> |
− | <div style="text-align: left; display: flex; margin: 2px 0px;"> | + | <div style="text-align: left; display: ${opening_airstrike_display}; margin: 2px 0px;"> |
− | <div margin-right: 1px; flex-basis: 120px; background-color: whitesmoke;">'''${icons.aircraft} Opening Airstrike'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; display: flex; align-items: center;"><span>${icons.aircraft} Opening Airstrike</span></div> |
− | <div margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${opening_airstrike}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${opening_airstrike}'''</div> |
| </div> | | </div> |
− | <div style="text-align: left; display: flex; margin: 2px 0px;"> | + | <div style="text-align: left; display: ${opening_torpedo_display}; margin: 2px 0px;"> |
− | <div margin-right: 1px; flex-basis: 120px; background-color: whitesmoke;">'''${icons.torpedo} Opening Torpedo'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; display: flex; align-items: center;"><span>${icons.torpedo} Opening Torpedo</span></div> |
− | <div margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${opening_torpedo}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${opening_torpedo}'''</div> |
| </div> | | </div> |
| <div style="text-align: left; display: flex; margin: 2px 0px;"> | | <div style="text-align: left; display: flex; margin: 2px 0px;"> |
− | <div style="margin-right: 1px; flex-basis: 120px; background-color: whitesmoke; color: dodgerblue;">'''${icons.firepower} Day Battle'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; color: dodgerblue; display: flex; align-items: center;"><span>${icons.firepower} Day Battle</span></div> |
− | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${day_battle}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${day_battle}'''</div> |
| </div> | | </div> |
− | <div style="text-align: left; display: flex; margin: 2px 0px;"> | + | <div style="text-align: left; display: ${artillery_spotting_display}; margin: 2px 0px;"> |
− | <div style="margin-right: 1px; flex-basis: 120px; background-color: whitesmoke; color: forestgreen;">'''${icons.firepower} Artillery Spotting'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; color: forestgreen; display: flex; align-items: center;"><span>${icons.firepower}${icons.los} Artillery Spotting</span></div> |
− | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${artillery_spotting}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${artillery_spotting}'''</div> |
| </div> | | </div> |
− | <div style="text-align: left; display: flex; margin: 2px 0px;"> | + | <div style="text-align: left; display: ${closing_torpedo_display}; margin: 2px 0px;"> |
− | <div style="margin-right: 1px; flex-basis: 120px; background-color: whitesmoke;">'''${icons.torpedo} Closing Torpedo'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; display: flex; align-items: center;"><span>${icons.torpedo} Closing Torpedo</span></div> |
− | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${closing_torpedo}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${closing_torpedo}'''</div> |
| </div> | | </div> |
| <div style="text-align: left; display: flex; margin: 2px 0px;"> | | <div style="text-align: left; display: flex; margin: 2px 0px;"> |
− | <div style="margin-right: 1px; flex-basis: 120px; background-color: whitesmoke;">'''${icons.asw} ASW Attack'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; display: flex; align-items: center;"><span>${icons.asw} ASW Attack</span></div> |
− | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${asw_attack}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${asw_attack}'''</div> |
| </div> | | </div> |
| <div style="text-align: left; display: flex; margin: 2px 0px;"> | | <div style="text-align: left; display: flex; margin: 2px 0px;"> |
− | <div style="margin-right: 1px; flex-basis: 120px; background-color: whitesmoke;">'''${icons.firepower}${icons.torpedo} Night Battle'''</div> | + | <div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; color: midnightblue; display: flex; align-items: center;"><span>${icons.firepower}${icons.torpedo} Night Battle</span></div> |
− | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke;">'''${night_battle}'''</div> | + | <div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;">'''${night_battle}'''</div> |
| </div> | | </div> |
| </div> | | </div> |
Line 94: |
Line 96: |
| _common_background_color = "darkgrey", | | _common_background_color = "darkgrey", |
| _background_color = "grey", | | _background_color = "grey", |
− | _rare_background_color = "#B04040", | + | _background_image = "background-image: radial-gradient(circle farthest-corner at center center , rgba(102, 102, 102, 0) 0%, rgba(102, 102, 102, 0) 60%, rgb(102, 102, 102) 100%);", |
− | _rare_background_image = "background-image: linear-gradient(to bottom, #804040, #B04040 80%, #C04040);", | + | _plain_rare_background_color = "#d8d840", |
− | _link_color = "black", | + | _plain_rare_background_image = "background-image: radial-gradient(circle farthest-corner at center center , rgba(192, 192, 0, 0) 0%, rgba(192, 192, 0, 0.4) 60%, rgba(144, 144, 0, 0.7) 100%);", |
| + | _elite_glow_background_color = "#c95050", |
| + | _mid_boss_background_color = "#A67474", |
| + | _mid_boss_background_image = "background-image: radial-gradient(circle farthest-corner at center center , rgba(140, 98, 98, 0) 0%, rgba(140, 98, 98, 0) 60%, rgb(140, 98, 98) 100%);", |
| + | _rare_background_color = "#d84040", |
| + | _rare_background_image = "background-image: radial-gradient(circle farthest-corner at center center , #e65555 0%, #c04040 90%, #A04040);", |
| + | _link_color = "#3a3a3a", |
| _text_shadow_template = "0 0 ${radius} ${color}", | | _text_shadow_template = "0 0 ${radius} ${color}", |
| _text_shadows = { | | _text_shadows = { |
Line 126: |
Line 134: |
| }, | | }, |
| _link_color_template = [[<span style="color: ${color};">${text}</span>]], | | _link_color_template = [[<span style="color: ${color};">${text}</span>]], |
− | _cg_size = "218x300px", | + | _cg_size = "300x300px", |
| + | _tabber_cg_size = "294x294px", |
| + | _display_flex = "flex", |
| + | _display_none = "none", |
| } | | } |
| + | |
| + | function EnemyShipInfoKai:get_module() |
| + | self._ship_data_module = EnemyShip:get_module(self._args.name or self._args[1], true) |
| + | end |
| | | |
| function EnemyShipInfoKai:bg_color() | | function EnemyShipInfoKai:bg_color() |
Line 135: |
Line 150: |
| if rarity then | | if rarity then |
| if rarity >= 4 and rarity <= 7 then | | if rarity >= 4 and rarity <= 7 then |
− | bg_color = self._background_color | + | if rarity == 5 then |
| + | bg_color = self._elite_glow_background_color |
| + | elseif rarity == 6.5 then |
| + | bg_color = self._mid_boss_background_color |
| + | extra_style = self._mid_boss_background_image |
| + | elseif rarity == 7 then |
| + | bg_color = self._plain_rare_background_color |
| + | extra_style = self._plain_rare_background_image |
| + | else |
| + | bg_color = self._background_color |
| + | extra_style = self._background_image |
| + | end |
| elseif rarity < 4 then | | elseif rarity < 4 then |
| bg_color = self._common_background_color | | bg_color = self._common_background_color |
Line 165: |
Line 191: |
| color = glow_colors[index] | | color = glow_colors[index] |
| end | | end |
− | table.insert(text_shadows, format{self._text_shadow_template, radius = radius, color = color}) | + | --table.insert(text_shadows, format{self._text_shadow_template, radius = radius, color = color}) |
| end | | end |
| self._vars.top_bg_color, self._vars.text_shadow, self._vars.top_extra_style = bg_color, table.concat(text_shadows, ", "), extra_style | | self._vars.top_bg_color, self._vars.text_shadow, self._vars.top_extra_style = bg_color, table.concat(text_shadows, ", "), extra_style |
Line 182: |
Line 208: |
| function EnemyShipInfoKai:class() | | function EnemyShipInfoKai:class() |
| self._vars.class = self._abyssal_class | | self._vars.class = self._abyssal_class |
| + | end |
| + | |
| + | function EnemyShipInfoKai:type() |
| + | local ship_type = Formatting:format_ship_type(self._ship:type()) |
| + | if self._ship:speed() == 0 then |
| + | ship_type = ship_type .. |
| + | (self._ship:is_pillbox() and " (Pillbox)" or " (Installation)") |
| + | end |
| + | -- automatically make units with 0 speed installations |
| + | -- deprecate _installation |
| + | self._vars.type = ship_type |
| end | | end |
| | | |
| function EnemyShipInfoKai:image() | | function EnemyShipInfoKai:image() |
− | self._vars.image = Formatting:format_image{self._ship:cg(), size = self._cg_size} | + | if self._ship:can_debuff() then |
| + | local tabber = Tabber() |
| + | tabber:add_tab("Normal", ShipGraphicKai:get{ship = self._ship, size = self._args.cg_size or self._tabber_cg_size, hd = true}) |
| + | tabber:add_tab("Armor Broken", ShipGraphicKai:get{ship = self._ship, damaged = true, size = self._args.cg_size or self._tabber_cg_size}) |
| + | self._vars.image = tostring(tabber) |
| + | else |
| + | self._vars.image = ShipGraphicKai:get{ship = self._ship, size = self._args.cg_size or self._cg_size, hd = true} |
| + | end |
| end | | end |
| + | |
| + | EnemyShipInfoKai.hp = EnemyShipInfoKai.base_hp |
| | | |
| function EnemyShipInfoKai:firepower() | | function EnemyShipInfoKai:firepower() |
Line 193: |
Line 239: |
| | | |
| function EnemyShipInfoKai:armor() | | function EnemyShipInfoKai:armor() |
− | self._vars.armor = Formatting:format_stat(self._ship:armor())
| + | local equipment_armor = self._ship:equipment_armor() |
| + | local armor = self._ship:armor() |
| + | local stat = Formatting:format_stat(armor) |
| + | self._vars.armor = equipment_armor ~= 0 and Formatting:tooltip(stat, armor + equipment_armor) or stat |
| end | | end |
| | | |
Line 260: |
Line 309: |
| | | |
| function EnemyShipInfoKai:air_power() | | function EnemyShipInfoKai:air_power() |
− | self._vars.air_power = Formatting:format_stat(self._ship:air_power()) | + | self._vars.air_power = Formatting:format_air_power(self._ship:air_power(), self._ship:air_power_estimation()) |
| end | | end |
| | | |
| function EnemyShipInfoKai:capabilities() | | function EnemyShipInfoKai:capabilities() |
| local capabilities = ShipCapabilities{ship = self._ship} | | local capabilities = ShipCapabilities{ship = self._ship} |
− | self._vars.opening_airstrike = capabilities:opening_airstrike() | + | local opening_airstrike = { capabilities:opening_airstrike() } |
− | self._vars.opening_torpedo = capabilities:opening_torpedo() | + | local opening_torpedo = { capabilities:opening_torpedo() } |
− | self._vars.day_battle = capabilities:day_battle() | + | local day_battle = { capabilities:day_battle() } |
− | self._vars.artillery_spotting = capabilities:artillery_spotting() | + | local artillery_spotting = { capabilities:artillery_spotting() } |
− | self._vars.closing_torpedo = capabilities:closing_torpedo() | + | local closing_torpedo = { capabilities:closing_torpedo() } |
− | self._vars.asw_attack = capabilities:asw_attack() | + | local asw_attack = { capabilities:asw_attack() } |
− | self._vars.night_battle = capabilities:night_battle() | + | local night_battle = { capabilities:night_battle() } |
| + | self._vars.opening_airstrike_display, self._vars.opening_airstrike = opening_airstrike[1] and self._display_flex or self._display_none, capabilities:format_opening_airstrike(unpack(opening_airstrike)) |
| + | self._vars.opening_torpedo_display, self._vars.opening_torpedo = opening_torpedo[1] and self._display_flex or self._display_none, capabilities:format_opening_torpedo(unpack(opening_torpedo)) |
| + | self._vars.day_battle = capabilities:format_day_battle(unpack(day_battle)) |
| + | self._vars.artillery_spotting_display, self._vars.artillery_spotting = artillery_spotting[1] and self._display_flex or self._display_none, capabilities:format_artillery_spotting(unpack(artillery_spotting)) |
| + | self._vars.closing_torpedo_display, self._vars.closing_torpedo = closing_torpedo[1] and self._display_flex or self._display_none, capabilities:format_closing_torpedo(unpack(closing_torpedo)) |
| + | self._vars.asw_attack = capabilities:format_asw_attack(unpack(asw_attack)) |
| + | self._vars.night_battle = capabilities:format_night_battle(unpack(night_battle)) |
| end | | end |
| | | |
| function EnemyShipInfoKai:create_item() | | function EnemyShipInfoKai:create_item() |
− | self._ship = EnemyShip(self._args.name, self._args.model) | + | if self._args.name then |
| + | self._ship = EnemyShip(self._args.name, self._args.model) |
| + | else |
| + | self._ship = EnemyShip(self._args[1]) |
| + | end |
| end | | end |
| | | |