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 ResourceIcons = require('Module:ResourceIcons') | + | local ResourceIcons = require('Module:Data/Asset') |
| 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:StringInterpolation').format | + | local format = require('Module:Core').format |
| | | |
| local ShipListKai = BaseTable({ | | local ShipListKai = BaseTable({ |
− | _header_template = [[! No. | + | _table_start = [[{| class="wikitable" style="text-align:center"]], |
− | ! style="width: 100px;" | Name | + | _header_template = [[! style="position:sticky;top:0px" | No. |
− | ! style="width: 75px;" | Class | + | ! style="position:sticky;top:0px;width:100px" | Name |
− | ! Type | + | ! style="position:sticky;top:0px;width:75px" | Class |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightcoral;" | ${firepower} | + | ! style="position:sticky;top:0px" | Type |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightskyblue;" | ${torpedo} | + | ! style="position:sticky;top:0px;width:30px;background-color:lightcoral" | ${firepower} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: sandybrown;" | ${aa} | + | ! style="position:sticky;top:0px;width:30px;background-color:lightskyblue" | ${torpedo} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: #9C8FEE;" | ${asw} | + | ! style="position:sticky;top:0px;width:24px;background-color:slategrey" | ${firepower}${torpedo} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: aquamarine;" | ${los} | + | ! style="position:sticky;top:0px;width:30px;background-color:sandybrown" | ${aa} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: palegreen;" | ${luck} | + | ! style="position:sticky;top:0px;width:30px;background-color:#9C8FEE" | ${asw} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: pink;" | ${hp} | + | ! style="position:sticky;top:0px;white-space:nowrap;width:30px;background-color:#9C8FEE" | ${asw}+ |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: #F2E279;" | ${armor} | + | ! style="position:sticky;top:0px;width:30px;background-color:aquamarine" | ${los} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion} | + | ! style="position:sticky;top:0px;white-space:nowrap;width:30px;background-color:aquamarine" | ${los}+ |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: #72E6E6;" | ${speed} | + | ! style="position:sticky;top:0px;width:30px;background-color:palegreen" | ${luck} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: silver;" | ${aircraft} | + | ! style="position:sticky;top:0px;white-space:nowrap;width:30px;background-color:palegreen" | ${luck}+ |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightseagreen;" | ${range} | + | ! style="position:sticky;top:0px;width:30px;background-color:pink" | ${hp} |
− | ! style="width: 30px; text-align: center; vertixal-align: middle; background-color: forestgreen;" | ${fuel} | + | ! style="position:sticky;top:0px;width:30px;background-color:#F2E279" | ${armor} |
− | ! style="width: 30px; text-align: center; vertical-align: middle; background-color: darkgoldenrod;" | ${ammo} | + | ! style="position:sticky;top:0px;width:30px;background-color:violet" | ${evasion} |
− | ! style="text-align:left;" | Notes]], | + | ! style="position:sticky;top:0px;white-space:nowrap;width:30px;background-color:violet" | ${evasion}+ |
− | --! style="width: 250px; text-align: center; vertical-align: middle;" | Build / Remodel Info
| + | ! style="position:sticky;top:0px;width:30px;background-color:#72E6E6" | ${speed} |
| + | ! style="position:sticky;top:0px;width:30px;background-color:silver" | ${aircraft} |
| + | ! style="position:sticky;top:0px;width:30px;background-color:lightseagreen" | ${range} |
| + | ! style="position:sticky;top:0px;width:30px;background-color:forestgreen" | ${fuel} |
| + | ! style="position:sticky;top:0px;width:30px;background-color:darkgoldenrod" | ${ammo} |
| + | ! style="position:sticky;top:0px;width:250px" | Build / Remodel Info |
| + | ! style="position:sticky;top:0px" | Notes]], |
| _columns = { | | _columns = { |
| "id", | | "id", |
Line 35: |
Line 41: |
| "firepower", | | "firepower", |
| "torpedo", | | "torpedo", |
| + | "night_battle", |
| "aa", | | "aa", |
| "asw", | | "asw", |
| + | "asw_max", |
| "los", | | "los", |
| + | "los_max", |
| "luck", | | "luck", |
| + | "luck_max", |
| "hp", | | "hp", |
| "armor", | | "armor", |
| "evasion", | | "evasion", |
| + | "evasion_max", |
| "speed", | | "speed", |
| "aircraft", | | "aircraft", |
Line 47: |
Line 58: |
| "fuel", | | "fuel", |
| "ammo", | | "ammo", |
− | --"build", | + | "build", |
| "notes", | | "notes", |
| }, | | }, |
− | _empty_cell = [[| colspan="1" rowspan="1" |]], | + | _cell = [[| style="${text_align}" |${value}]], |
| + | _cell_simple = [[|${value}]], |
| _item_class = Ship, | | _item_class = Ship, |
− | _class_number_template = "${class_name}<br />#${class_number}", | + | _class_number_template = "${class_name}<br>#${class_number}", |
| _normal_construction = "Normal", | | _normal_construction = "Normal", |
| _large_ship_construction = "LSC", | | _large_ship_construction = "LSC", |
Line 60: |
Line 72: |
| _remodel_template = "${link} (Level ${level})", | | _remodel_template = "${link} (Level ${level})", |
| _unbuildable_label = "''Unbuildable''", | | _unbuildable_label = "''Unbuildable''", |
| + | _fragment_prefix = "shiplistkai", |
| + | _dash = "-", |
| }) | | }) |
| | | |
Line 69: |
Line 83: |
| table.insert(value, Formatting:format_stat(ship:japanese_name())) | | table.insert(value, Formatting:format_stat(ship:japanese_name())) |
| end | | end |
− | return {values = {value = table.concat(value, "<br />")}, bg_color = self._transparent, 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._dash))), self._fragment_prefix, table.concat(value, "<br>")), text_align = "text-align: " .. self._start_align} |
| end | | end |
| | | |
| function ShipListKai:id(ship) | | function ShipListKai:id(ship) |
− | return {values = {value = Formatting:format_stat(ship:id())}, | + | return {value = Formatting:format_stat(ship:true_id() or ship:id()), simple = true} |
− | bg_color = self._transparent,
| |
− | text_align = self._center_align,
| |
− | }
| |
| end | | end |
| | | |
Line 86: |
Line 97: |
| class_number = "??" | | class_number = "??" |
| end | | end |
− | return {values = {value = class_number and format{self._class_number_template, class_name = class_name, class_number = class_number} or class_name}, bg_color = self._transparent, text_align = self._start_align} | + | return {value = class_number and format{self._class_number_template, class_name = class_name, class_number = class_number} or class_name, text_align = "text-align: " .. self._start_align} |
| end | | end |
| | | |
| function ShipListKai:type(ship) | | function ShipListKai:type(ship) |
− | return {values = {value = Formatting:format_ship_code(ship:type())}, bg_color = self._transparent, text_align = self._start_align} | + | return {value = Formatting:format_ship_code(ship:type()), text_align = "text-align: " .. self._start_align} |
| end | | end |
| | | |
| function ShipListKai:firepower(ship) | | function ShipListKai:firepower(ship) |
− | return {values = {value = Formatting:format_stat(ship:firepower())}, bg_color = self._transparent, text_align = self._center_align} | + | local firepower_max = ship:firepower_max() |
| + | if firepower_max == false then |
| + | firepower_max = ship:firepower() |
| + | end |
| + | return {value = Formatting:format_stat(firepower_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:torpedo(ship) | | function ShipListKai:torpedo(ship) |
− | return {values = {value = Formatting:format_stat(ship:torpedo())}, bg_color = self._transparent, text_align = self._center_align} | + | local torpedo_max = ship:torpedo_max() |
| + | if torpedo_max == false then |
| + | torpedo_max = ship:torpedo() |
| + | end |
| + | return {value = Formatting:format_stat(torpedo_max), simple = true} |
| + | end |
| + | |
| + | function ShipListKai: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 {value = Formatting:format_stat(night_battle), simple = true} |
| end | | end |
| | | |
| function ShipListKai:aa(ship) | | function ShipListKai:aa(ship) |
− | return {values = {value = Formatting:format_stat(ship:aa())}, bg_color = self._transparent, text_align = self._center_align} | + | local aa_max = ship:aa_max() |
| + | if aa_max == false then |
| + | aa_max = ship:aa() |
| + | end |
| + | return {value = Formatting:format_stat(aa_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:asw(ship) | | function ShipListKai:asw(ship) |
− | return {values = {value = Formatting:format_stat(ship:asw())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:asw()), simple = true} |
| + | end |
| + | |
| + | function ShipListKai:asw_max(ship) |
| + | local asw_max = ship:asw_max() |
| + | if asw_max == false then |
| + | asw_max = ship:asw() |
| + | end |
| + | return {value = Formatting:format_stat(asw_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:los(ship) | | function ShipListKai:los(ship) |
− | return {values = {value = Formatting:format_stat(ship:los())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:los()), simple = true} |
| + | end |
| + | |
| + | function ShipListKai:los_max(ship) |
| + | local los_max = ship:los_max() |
| + | if los_max == false then |
| + | los_max = ship:los() |
| + | end |
| + | return {value = Formatting:format_stat(los_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:luck(ship) | | function ShipListKai:luck(ship) |
− | return {values = {value = Formatting:format_stat(ship:luck())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:luck()), simple = true} |
| + | end |
| + | |
| + | function ShipListKai:luck_max(ship) |
| + | local luck_max = ship:luck_max() |
| + | if luck_max == false then |
| + | luck_max = ship:luck() |
| + | end |
| + | return {value = Formatting:format_stat(luck_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:hp(ship) | | function ShipListKai:hp(ship) |
− | return {values = {value = Formatting:format_stat(ship:hp())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:hp()), simple = true} |
| end | | end |
| | | |
| function ShipListKai:armor(ship) | | function ShipListKai:armor(ship) |
− | return {values = {value = Formatting:format_stat(ship:armor())}, bg_color = self._transparent, text_align = self._center_align} | + | local armor_max = ship:armor_max() |
| + | if armor_max == false then |
| + | armor_max = ship:armor() |
| + | end |
| + | return {value = Formatting:format_stat(armor_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:evasion(ship) | | function ShipListKai:evasion(ship) |
− | return {values = {value = Formatting:format_stat(ship:evasion())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:evasion()), simple = true} |
| + | end |
| + | |
| + | function ShipListKai:evasion_max(ship) |
| + | local evasion_max = ship:evasion_max() |
| + | if evasion_max == false then |
| + | evasion_max = ship:evasion() |
| + | end |
| + | return {value = Formatting:format_stat(evasion_max), simple = true} |
| end | | end |
| | | |
| function ShipListKai:speed(ship) | | function ShipListKai:speed(ship) |
− | return {values = {value = Formatting:format_speed(ship:speed())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_speed(ship:speed()), simple = true} |
| end | | end |
| | | |
| function ShipListKai:aircraft(ship) | | function ShipListKai:aircraft(ship) |
− | return {values = {value = Formatting:format_stat(ship:total_space())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:total_space()), simple = true} |
| end | | end |
| | | |
| function ShipListKai:range(ship) | | function ShipListKai:range(ship) |
− | return {values = {value = Formatting:format_range(ship:range())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_range(ship:range()), simple = true} |
| end | | end |
| | | |
| function ShipListKai:fuel(ship) | | function ShipListKai:fuel(ship) |
− | return {values = {value = Formatting:format_stat(ship:fuel())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:fuel()), simple = true} |
| end | | end |
| | | |
| function ShipListKai:ammo(ship) | | function ShipListKai:ammo(ship) |
− | return {values = {value = Formatting:format_stat(ship:ammo())}, bg_color = self._transparent, text_align = self._center_align} | + | return {value = Formatting:format_stat(ship:ammo()), simple = true} |
| end | | end |
| | | |
Line 168: |
Line 245: |
| end | | end |
| else | | else |
− | remodel_from = Ship(self:process_item_key(remodel_from)) | + | remodel_from = Ship(remodel_from) |
− | table.insert(build_info, self._remodel_from_label .. format{self._remodel_template, link = Formatting:format_link(remodel_from:link()), level = ship:remodel_level()}) | + | local remodel_level = ship:remodel_level() |
| + | if ship:remodel_blueprint() or ship:remodel_catapult() then |
| + | remodel_level = table.concat({remodel_level, Formatting:format_remodel_items(ship:remodel_blueprint(), ship:remodel_catapult())}, " + ") |
| + | end |
| + | table.insert(build_info, self._remodel_from_label .. format{self._remodel_template, link = Formatting:fragment_link(tostring(remodel_from:api_id() or mw.ustring.lower(mw.ustring.gsub(remodel_from:name(), "%s+", self._dash))), self._fragment_prefix, remodel_from:name()), level = remodel_level}) |
| end | | end |
| | | |
| local remodel_to = ship:remodel_to() | | local remodel_to = ship:remodel_to() |
| if remodel_to then | | if remodel_to then |
− | remodel_to = Ship(self:process_item_key(remodel_to)) | + | local remodel_level |
− | table.insert(build_info, self._remodel_to_label .. format{self._remodel_template, link = Formatting:format_link(remodel_to:link()), level = remodel_to:remodel_level()}) | + | if remodel_to == ship:remodel_from() then |
| + | remodel_level = ship:remodel_to_level() |
| + | if ship:remodel_to_blueprint() or ship:remodel_to_catapult() then |
| + | remodel_level = table.concat({remodel_level, Formatting:format_remodel_items(ship:remodel_to_blueprint(), ship:remodel_to_catapult())}, " + ") |
| + | end |
| + | remodel_to = remodel_from |
| + | else |
| + | remodel_to = Ship(remodel_to) |
| + | remodel_level = remodel_to:remodel_level() |
| + | if remodel_to:remodel_blueprint() or remodel_to:remodel_catapult() then |
| + | remodel_level = table.concat({remodel_level, Formatting:format_remodel_items(remodel_to:remodel_blueprint(), remodel_to:remodel_catapult())}, " + ") |
| + | end |
| + | end |
| + | table.insert(build_info, self._remodel_to_label .. format{self._remodel_template, link = Formatting:fragment_link(tostring(remodel_to:api_id() or mw.ustring.lower(mw.ustring.gsub(remodel_to:name(), "%s+", self._dash))), self._fragment_prefix, remodel_to:name()), level = remodel_level}) |
| end | | end |
− | return {values = {value = table.concat(build_info, "<br />")}, bg_color = self._transparent, text_align = self._start_align} | + | return {value = table.concat(build_info, "<br>"), text_align = "text-align: " .. self._start_align} |
| end | | end |
| | | |
Line 183: |
Line 277: |
| local note = self._notes[ship] | | local note = self._notes[ship] |
| if note then | | if note then |
− | return {values = {value = note.note or ""}, bg_color = self._transparent, text_align = self._start_align} | + | return {value = note.note or "", text_align = "text-align: " .. self._start_align} |
| end | | end |
− | return {values = {value = ""}, bg_color = self._transparent, text_align = self._start_align} | + | return {value = "", text_align = "text-align: " .. self._start_align} |
| end | | end |
| | | |
− | function ShipListKai:process_item_key(item_key)
| + | ShipListKai.process_item_key = Ship.process_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
| |
| | | |
− | function BaseTable:build_rows()
| + | ShipListKai.build_rows = ShipListKai.build_rows_breaks_as_empty_rows |
− | for index, row_values in ipairs(self._data_rows) do
| |
− | table.insert(self._rows, self._row_starter)
| |
− | if row_values == "break" then
| |
− | for _, column in ipairs(self._columns) do
| |
− | table.insert(self._rows, self._empty_cell)
| |
− | end
| |
− | elseif row_values == "header" then
| |
− | table.insert(self._rows, self._header)
| |
− | elseif type(row_values) == "table" then
| |
− | for _, column in ipairs(self._columns) do
| |
− | if row_values[column] then
| |
− | table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
| |
− | end
| |
− | end
| |
− | else
| |
− | table.insert(self._rows,
| |
− | format{self._cell,
| |
− | colspan = #self._columns, rowspan = 1,
| |
− | text_align = self._args[self._custom_row_prefix .. row_values .. self._text_align_suffix] or self._start_align,
| |
− | bg_color = self._args[self._custom_row_prefix .. row_values .. self._bg_color_suffix] or self._transparent,
| |
− | values = {
| |
− | value = self._args[self._custom_row_prefix .. row_values .. self._content_suffix] or "",
| |
− | },
| |
− | }
| |
− | )
| |
− | end
| |
− | end
| |
− | end
| |
| | | |
| function ShipListKai:create_header() | | function ShipListKai:create_header() |
Line 235: |
Line 291: |
| torpedo = StatIcons.torpedo, | | torpedo = StatIcons.torpedo, |
| aa = StatIcons.aa, | | aa = StatIcons.aa, |
− | asw = StatIcons.asw, | + | asw = StatIcons.asw, |
| + | asw_max = StatIcons.asw, |
| los = StatIcons.los, | | los = StatIcons.los, |
| + | los_max = StatIcons.los, |
| luck = StatIcons.luck, | | luck = StatIcons.luck, |
| + | luck_max = StatIcons.luck, |
| hp = StatIcons.hp, | | hp = StatIcons.hp, |
| armor = StatIcons.armor, | | armor = StatIcons.armor, |
| evasion = StatIcons.evasion, | | evasion = StatIcons.evasion, |
| + | evasion_max = StatIcons.evasion, |
| speed = StatIcons.speed, | | speed = StatIcons.speed, |
| aircraft = StatIcons.aircraft, | | aircraft = StatIcons.aircraft, |