Line 1: |
Line 1: |
| local BaseTable = require('Module:BaseTable') | | local BaseTable = require('Module:BaseTable') |
| local Formatting = require('Module:Formatting') | | local Formatting = require('Module:Formatting') |
− | local MiscIcons = require('Module:MiscIcons')
| + | local ResourceIcons = require('Module:Data/Asset') |
− | local ResourceIcons = require('Module:ResourceIcons') | |
| local Ship = require('Module:Ship') | | local Ship = require('Module:Ship') |
− | local StatIcons = require('Module:StatIcons') | + | local StatIcons = require('Module:Data/Asset') |
| | | |
− | local format = require('Module:StringOperations').format | + | local format = require('Module:Core').format |
− | local split = require('Module:StringOperations').split | + | local split = require('Module:Core').split |
| | | |
| local EliteShipsKai = BaseTable({ | | local EliteShipsKai = BaseTable({ |
| + | _table_start = [[{| class="wikitable typography-xl-optout" style="width: -moz-max-content; width: -webkit-max-content; width: max-content;"]], |
| _header_template = [[!No. | | _header_template = [[!No. |
| !Name | | !Name |
Line 16: |
Line 16: |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: lightcoral;" | ${firepower} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: lightcoral;" | ${firepower} |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: lightskyblue;" | ${torpedo} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: lightskyblue;" | ${torpedo} |
− | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: sandybrown;" | ${aa} | + | ${night_battle_header_cell}! style="width: 24px; text-align: center; vertical-align: middle; background-color: sandybrown;" | ${aa} |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: #9C8FEE;" | ${asw} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: #9C8FEE;" | ${asw} |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: aquamarine;" | ${los} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: aquamarine;" | ${los} |
Line 24: |
Line 24: |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion} |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: #72E6E6;" | ${speed} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: #72E6E6;" | ${speed} |
− | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: silver;" | ${aircraft} | + | ${range_header_cell}! style="width: 24px; text-align: center; vertical-align: middle; background-color: silver;" | ${aircraft} |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: forestgreen;" | ${fuel} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: forestgreen;" | ${fuel} |
| ! style="width: 24px; text-align: center; vertical-align: middle; background-color: darkgoldenrod;" | ${ammo} | | ! style="width: 24px; text-align: center; vertical-align: middle; background-color: darkgoldenrod;" | ${ammo} |
− | ! class="eliteshipskai-detailed" style="text-align:left;" | Notes]], | + | ! class="toggle-target-eliteshipskai-detail" style="text-align:left;" | Notes]], |
| _column_cell_templates = { | | _column_cell_templates = { |
| luck = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" | ${values.luck}(${values.luck_max})]], | | luck = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" | ${values.luck}(${values.luck_max})]], |
| id = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;${extra_style}" |${values.value}]], | | id = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;${extra_style}" |${values.value}]], |
| notes = [[| class="${class}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" |<small>${values.value}</small>]], | | notes = [[| class="${class}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" |<small>${values.value}</small>]], |
− | ["!"] = [[| class="${class}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;${extra_style}" |${values.value}]] | + | ["!"] = [[| class="${class}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" |<div style="max-width: 600px;">${values.value}</div>]] |
| }, | | }, |
− | _columns = { | + | _night_battle_header_cell = [[! style="width: 24px; text-align: center; vertical-align: middle; background-color: slategrey;" | ${firepower}${torpedo} |
| + | ]], |
| + | _range_header_cell = [[! style="width: 24px; text-align: center; vertical-align: middle;" | ${range} |
| + | ]], |
| + | _base_columns = { --gets copied to self._columns in create_table_prep so we can mutate it. Don't mutate base_columns! |
| "id", | | "id", |
| "name", | | "name", |
Line 40: |
Line 44: |
| "remodel", | | "remodel", |
| "firepower", | | "firepower", |
− | "torpedo", | + | "torpedo", --night_battle is added after this depending on args in create_table_prep. If adding columns please preserve this behaviour. |
| "aa", | | "aa", |
| "asw", | | "asw", |
Line 48: |
Line 52: |
| "armor", | | "armor", |
| "evasion", | | "evasion", |
− | "speed", | + | "speed", --range is added after this depending on args in create_table_prep. If adding columns please preserve this behaviour. |
| "aircraft", | | "aircraft", |
| "fuel", | | "fuel", |
Line 55: |
Line 59: |
| }, | | }, |
| _no_remodel_level = "-", | | _no_remodel_level = "-", |
− | _simple_class = "eliteshipskai-simple", | + | _simple_class = "toggle-anti-target-eliteshipskai-detail", |
− | _detailed_class = "eliteshipskai-detailed hidden", | + | _detailed_class = "toggle-target-eliteshipskai-detail hidden", |
− | _detailed_start = '<span class="eliteshipskai-detailed hidden" style="display:none;">', | + | _detailed_start = '<span class="toggle-target-eliteshipskai-detail hidden">', |
| _detailed_end = '</span>', | | _detailed_end = '</span>', |
− | _display_none_style = " display: none;", | + | _name_style = {["max-width"] = "150px"}, |
| _detailed_columns = 1, | | _detailed_columns = 1, |
− | _detail_toggle = '<p id="eliteshipskai-detailed-toggle" class="eliteshipskai-detailed-toggle hidden" style="display: none;">[[#eliteshipskai-detailed-toggle|Show details]][[#eliteshipskai-detailed-hidden|Hide details]]</p>', | + | _detail_toggle = '<div class="toggle" data-target="eliteshipskai-detail" data-anti-target="eliteshipskai-detail" data-default="hide" style="display: none;"><span class="toggle-show" style="cursor: pointer; color: #006cb0;">☑ Show details</span><span class="toggle-hide" style="cursor: pointer; color: #006cb0;">☒ Show details</span></div>', |
− | _nickname_template = [[Nicknamed ''${nickname}'']], | + | _nickname_template = "''${nick} ${japanese_nick}''", |
| + | _kekkon_max_template = "Maximum after marriage: ${value}", |
| + | _kekkon_template = "After marriage: ${value}", |
| _item_class = Ship, | | _item_class = Ship, |
| }) | | }) |
Line 78: |
Line 84: |
| table.insert(value, self._detailed_end) | | table.insert(value, self._detailed_end) |
| end | | end |
− | local nickname = ship:nick() | + | local nick = ship:nick() |
− | if nickname then | + | if nick then |
− | table.insert(value, self._detailed_start)
| |
| table.insert(value, "<br />") | | table.insert(value, "<br />") |
− | table.insert(value, self._detailed_end)
| |
| table.insert(value, self._detailed_start) | | table.insert(value, self._detailed_start) |
− | table.insert(value, format{self._nickname_template, nickname = Formatting:inline_block(Formatting:format_stat(nickname))}) | + | table.insert(value, Formatting:inline_block(format{self._nickname_template, |
| + | nick = Formatting:format_stat(nick), |
| + | japanese_nick = Formatting:format_stat(ship:japanese_nick())})) |
| table.insert(value, self._detailed_end) | | table.insert(value, self._detailed_end) |
| end | | end |
− | return {values = {value = table.concat(value)}, bg_color = self._transparent, text_align = self._center_align} | + | return {values = {value = Formatting:inline_block(table.concat(value), nil, self._name_style)}, bg_color = self._transparent, text_align = self._center_align} |
| end | | end |
| | | |
Line 138: |
Line 144: |
| end | | end |
| return {values = {value = Formatting:format_stat(torpedo_max)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo_max, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good, self._args.torpedo_bad), text_align = self._center_align} | | return {values = {value = Formatting:format_stat(torpedo_max)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo_max, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good, self._args.torpedo_bad), text_align = self._center_align} |
| + | end |
| + | |
| + | function EliteShipsKai:night_battle(ship) |
| + | local firepower_max = ship:firepower_max() |
| + | if firepower_max == false then |
| + | firepower_max = ship:firepower() |
| + | end |
| + | local torpedo_max = ship:torpedo_max() |
| + | if torpedo_max == false then |
| + | torpedo_max = ship:torpedo() |
| + | end |
| + | local night_battle = firepower_max |
| + | if not firepower_max then |
| + | night_battle = torpedo_max |
| + | elseif torpedo_max then |
| + | night_battle = night_battle + torpedo_max |
| + | end |
| + | return {values = {value = Formatting:format_stat(night_battle)}, bg_color = self:get_bg_color(self._cell_color.night_battle, night_battle, self._args.night_battle_operator, self._args.night_battle_outstanding, self._args.night_battle_good, self._args.night_battle_bad), text_align = self._center_align} |
| + | end |
| + | |
| + | function EliteShipsKai:range(ship) |
| + | local range = ship:range() |
| + | return {values = {value = Formatting:format_range(range)}, bg_color = self:get_bg_color(self._cell_color.range, range, self._args.range_operator, self._args.range_outstanding, self._args.range_good, self._args.range_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 152: |
Line 181: |
| if asw_max == false then | | if asw_max == false then |
| asw_max = ship:asw() | | asw_max = ship:asw() |
| + | return {values = {value = Formatting:format_stat(asw_max)}, bg_color = self:get_bg_color(self._cell_color.asw, asw_max, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good, self._args.asw_bad), text_align = self._center_align} |
| end | | end |
− | return {values = {value = Formatting:format_stat(asw_max)}, bg_color = self:get_bg_color(self._cell_color.asw, asw_max, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good, self._args.asw_bad), text_align = self._center_align} | + | return {values = {value = Formatting:tooltip(Formatting:format_stat(asw_max), format{self._kekkon_max_template, value = Formatting:format_stat(ship:asw_leveled(180))})}, bg_color = self:get_bg_color(self._cell_color.asw, asw_max, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good, self._args.asw_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 160: |
Line 190: |
| if los_max == false then | | if los_max == false then |
| los_max = ship:los() | | los_max = ship:los() |
| + | return {values = {value = Formatting:format_stat(los_max)}, bg_color = self:get_bg_color(self._cell_color.los, los_max, self._args.los_operator, self._args.los_outstanding, self._args.los_good, self._args.los_bad), text_align = self._center_align} |
| end | | end |
− | return {values = {value = Formatting:format_stat(los_max)}, bg_color = self:get_bg_color(self._cell_color.los, los_max, self._args.los_operator, self._args.los_outstanding, self._args.los_good, self._args.los_bad), text_align = self._center_align} | + | return {values = {value = Formatting:tooltip(Formatting:format_stat(los_max), format{self._kekkon_max_template, value = Formatting:format_stat(ship:los_leveled(180))})}, bg_color = self:get_bg_color(self._cell_color.los, los_max, self._args.los_operator, self._args.los_outstanding, self._args.los_good, self._args.los_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 172: |
Line 203: |
| function EliteShipsKai:hp(ship) | | function EliteShipsKai:hp(ship) |
| local hp = ship:hp() | | local hp = ship:hp() |
− | return {values = {value = Formatting:format_stat(hp)}, bg_color = self:get_bg_color(self._cell_color.hp, hp, self._args.hp_operator, self._args.hp_outstanding, self._args.hp_good, self._args.hp_bad), text_align = self._center_align} | + | local hp_married = ship:hp_married() |
| + | if hp_married then |
| + | local hp_mod_married = ship:hp_mod_married() |
| + | return {values = {value = Formatting:tooltip(Formatting:format_stat(hp), format{ |
| + | self._kekkon_template, |
| + | value = hp_mod_married and hp_mod_married > 0 and Formatting:format_stat_with_max(hp_married, hp_married + hp_mod_married) or Formatting:format_stat(hp_married) |
| + | })}, bg_color = self:get_bg_color(self._cell_color.hp, hp, self._args.hp_operator, self._args.hp_outstanding, self._args.hp_good, self._args.hp_bad), text_align = self._center_align} |
| + | else |
| + | return {values = {value = Formatting:format_stat(hp)}, bg_color = self:get_bg_color(self._cell_color.hp, hp, self._args.hp_operator, self._args.hp_outstanding, self._args.hp_good, self._args.hp_bad), text_align = self._center_align} |
| + | end |
| end | | end |
| | | |
Line 187: |
Line 227: |
| if evasion_max == false then | | if evasion_max == false then |
| evasion_max = ship:evasion() | | evasion_max = ship:evasion() |
| + | return {values = {value = Formatting:format_stat(evasion_max)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion_max, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good, self._args.evasion_bad), text_align = self._center_align} |
| end | | end |
− | return {values = {value = Formatting:format_stat(evasion_max)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion_max, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good, self._args.evasion_bad), text_align = self._center_align} | + | return {values = {value = Formatting:tooltip(Formatting:format_stat(evasion_max), format{self._kekkon_max_template, value = Formatting:format_stat(ship:evasion_leveled(180))})}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion_max, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good, self._args.evasion_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 234: |
Line 275: |
| end | | end |
| return {values = {value = ""}, bg_color = self._transparent, class = self._detailed_class} | | return {values = {value = ""}, bg_color = self._transparent, class = self._detailed_class} |
− | end
| |
− |
| |
− | function EliteShipsKai:process_item_key(item_key)
| |
− | local split = mw.ustring.find(item_key, '/')
| |
− | local ship_base_name, ship_suffix
| |
− | if split == nil then
| |
− | ship_base_name = item_key
| |
− | else
| |
− | ship_base_name = mw.ustring.sub(item_key, 1, split - 1)
| |
− | ship_suffix = mw.ustring.sub(item_key, split + 1, -1)
| |
− | end
| |
− | return ship_base_name, ship_suffix
| |
| end | | end |
| | | |
Line 255: |
Line 284: |
| | | |
| function EliteShipsKai:create_table_prep() | | function EliteShipsKai:create_table_prep() |
| + | self._columns = {} |
| + | for _, column in ipairs(self._base_columns) do |
| + | table.insert(self._columns, column) |
| + | end |
| if self._args.reference_type then | | if self._args.reference_type then |
| self._reference_types = {} | | self._reference_types = {} |
Line 260: |
Line 293: |
| self._reference_types[tonumber(reference_type)] = true | | self._reference_types[tonumber(reference_type)] = true |
| end | | end |
− | end
| + | end |
| + | if self._args.night_battle then |
| + | table.insert(self._columns, 7, "night_battle") |
| + | end |
| + | if self._args.range then |
| + | table.insert(self._columns, self._args.night_battle and 16 or 15, "range") |
| + | end |
| end | | end |
| | | |
| function EliteShipsKai:append_custom_row(custom_row_key) | | function EliteShipsKai:append_custom_row(custom_row_key) |
− | table.insert(self._rows, | + | table.insert(self._rows, self._row_starter) |
− | format{self._column_cell_templates["!"] or self._cell,
| + | table.insert(self._rows, |
− | class = self._detailed_class,
| + | format{self._column_cell_templates["!"] or self._cell, |
− | extra_style = "",
| + | class = "", |
− | colspan = #self._columns, rowspan = 1,
| + | colspan = #self._columns, rowspan = 1, |
− | text_align = self._args[self._custom_row_prefix .. custom_row_key .. self._text_align_suffix] or self._start_align,
| + | text_align = self._args[self._custom_row_prefix .. custom_row_key .. self._text_align_suffix] or self._start_align, |
− | bg_color = self._args[self._custom_row_prefix .. custom_row_key .. self._bg_color_suffix] or self._transparent,
| |
− | values = {
| |
− | value = self._args[self._custom_row_prefix .. custom_row_key .. self._content_suffix] or "",
| |
− | },
| |
− | }
| |
− | )
| |
− | table.insert(self._rows, | |
− | format{self._column_cell_templates["!"] or self._cell, | |
− | class = self._simple_class, | |
− | colspan = #self._columns - self._detailed_columns, rowspan = 1, | |
− | extra_style = self._display_none_style,
| |
− | text_align = self._args[self._custom_row_prefix .. custom_row_key .. self._text_align_suffix] or self._start_align, | |
| bg_color = self._args[self._custom_row_prefix .. custom_row_key .. self._bg_color_suffix] or self._transparent, | | bg_color = self._args[self._custom_row_prefix .. custom_row_key .. self._bg_color_suffix] or self._transparent, |
| values = { | | values = { |
Line 292: |
Line 319: |
| function EliteShipsKai:create_header() | | function EliteShipsKai:create_header() |
| local header_icons = { | | local header_icons = { |
− | remodel = MiscIcons.remodel, | + | remodel = StatIcons.remodel, |
| firepower = StatIcons.firepower, | | firepower = StatIcons.firepower, |
| torpedo = StatIcons.torpedo, | | torpedo = StatIcons.torpedo, |
Line 303: |
Line 330: |
| evasion = StatIcons.evasion, | | evasion = StatIcons.evasion, |
| speed = StatIcons.speed, | | speed = StatIcons.speed, |
| + | range = StatIcons.range, |
| aircraft = StatIcons.aircraft, | | aircraft = StatIcons.aircraft, |
| fuel = ResourceIcons.fuel, | | fuel = ResourceIcons.fuel, |
Line 310: |
Line 338: |
| header_icons[key] = Formatting:format_image{value, caption = Formatting:format_stat_name(key)} | | header_icons[key] = Formatting:format_image{value, caption = Formatting:format_stat_name(key)} |
| end | | end |
− | self._header = format(self._header_template, header_icons) | + | self._header = format(format{ |
| + | self._header_template, |
| + | night_battle_header_cell = self._args.night_battle and self._night_battle_header_cell or "", |
| + | range_header_cell = self._args.range and self._range_header_cell or "" |
| + | }, header_icons) |
| end | | end |
| | | |
| return EliteShipsKai | | return EliteShipsKai |