Line 6: |
Line 6: |
| local Tabber = require('Module:Tabber') | | local Tabber = require('Module:Tabber') |
| | | |
− | local format = require('Module:StringInterpolation').format | + | local U = require('Module:Core') |
| + | local format = U.format |
| | | |
| local EquipmentInfoKai = BaseData{ | | local EquipmentInfoKai = BaseData{ |
| _template = [[{|class="${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 380px; background-color: #fafafa;${float}" | | _template = [[{|class="${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 380px; background-color: #fafafa;${float}" |
| |- | | |- |
− | | colspan="2" style="position: relative; padding: 1px 40px; text-align: center; background-color: ${back};${extra_style};" title="${rarity}" | <div style="position: absolute; right: 5px;">${edit_link}</div> | + | | colspan="2" id="kc-eq-namecard" style="position: relative; padding: 10px 40px; text-align: center; background-color: ${back};${extra_style};" title="${rarity}" | <div id="kc-eq-edit-link" style="position: absolute; right: 5px;">${edit_link}</div> |
− | <p style="font-size: 20px;">'''${name}'''</p>${localized_name} | + | <div id="kc-eq-en-name" style="font-size: 20px; margin:0 0 4px 0;">'''${name}'''</div> |
− | <p>'''No.${id} ${japanese_name}'''</p> | + | ${localized_name} |
| + | <div id="kc-eq-jp-entry" style="margin:4px 0 0 0;">'''No.${id} ${japanese_name}'''</div> |
| |- | | |- |
− | | colspan="2" style="text-align: center; background-color: whitesmoke;" | | + | | colspan="2" id="kc-eq-statscard" style="text-align: center; background-color: whitesmoke;" | |
− | <div>${icon} <b>${eq_type}</b>${fit_group}<br /> | + | <div id="kc-eq-category" style="margin:0 0 4px 0;">${icon} <b>${eq_type}</b>${eq_group}</div> |
− | <b>Effects: ${effects}</b>${flight_stats}</div> | + | <div id="kc-eq-effects" style="margin:4px 0;"><b>Effects: ${effects}</b></div> |
− | <p>'''Scrap value: ${scrap}''' (${buildable})</p>${alternative_names}
| + | ${flight_stats} |
− | |-
| + | <div id="kc-eq-scrap" style="margin:4px 0 0 0;">'''Scrap value: ${scrap}''' (${buildable})</div> |
− | | colspan="2" style="text-align: center;" | ${card}
| + | ${alternative_names} |
| |- | | |- |
− | | colspan="2" style="text-align: center; background-color: LightSkyBlue;" | '''Refittable Class''' | + | | colspan="2" id="kc-eq-pictures" style="text-align: center;" | ${card} |
− | ${compatibility_details} | + | |- |
| + | | colspan="2" id="kc-eq-fits" style="text-align: center; background-color: LightSkyBlue;" | '''Refittable Ship Types''' |
| + | ${compatibility_details}${bonus_details} |
| |}]], | | |}]], |
| + | _bonus_header = [=[|- |
| + | | colspan="2" id="kc-eq-bonus" style="text-align: center; background-color: LightSkyBlue;" | '''Bonus'''${category}]=], |
| + | _bonus_row = [=[|- |
| + | | style="width: 190px; text-align: center;" | ${text} |
| + | | style="width: 190px; text-align: center;" | ${stats}]=], |
| --|- | | --|- |
| --| colspan="2" style="text-align: center; padding: 0px;" | <div class="mw-collapsible mw-collapsed"> | | --| colspan="2" style="text-align: center; padding: 0px;" | <div class="mw-collapsible mw-collapsed"> |
Line 35: |
Line 44: |
| _row_starter = "|-", | | _row_starter = "|-", |
| _compatibility_cell = [[| style="width: 190px; text-align: center; background-color: ${bg_color};" | ${label}]], | | _compatibility_cell = [[| style="width: 190px; text-align: center; background-color: ${bg_color};" | ${label}]], |
− | _localized_name_template = "<p>''${localized_name}''</p>", | + | _lbas_compatibility_row = [=[|- |
− | _flight_stats_template = [[<br/><b>Combat Radius: ${combat_radius}</b> (Deployment Cost: ${deployment_cost})]], | + | | colspan="2" style="text-align: center; background-color: LightSkyBlue;" | '''[[LBAS]] Plane''']=], |
| + | _localized_name_template = [[<div id="kc-eq-local-name" style="margin:4px 0;">${localized_name}</div>]], |
| + | _flight_stats_template = [[<div id="kc-eq-flights"><b>Combat Radius: ${combat_radius}</b> (Deployment Cost: ${deployment_cost})</div>]], |
| _alternative_names_template = [[ | | _alternative_names_template = [[ |
| |- | | |- |
− | | colspan="2" style="text-align: center; padding: 0px;" | <div class="mw-collapsible mw-collapsed" style="background-color: lightgrey; margin: 0px;">''Alternate names''<div class="mw-collapsible-content" style="background-color: whitesmoke;"> | + | | colspan="2" id="kc-eq-altnames" style="text-align: center; padding: 0px;" | <div class="mw-collapsible mw-collapsed" style="background-color: lightgrey; margin: 0px;">''Alternate names''<div class="mw-collapsible-content" style="background-color: whitesmoke;"> |
| ${names} | | ${names} |
| </div></div>]], | | </div></div>]], |
Line 45: |
Line 56: |
| -- _collapsed_content_row = [[<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${content}</div>]], | | -- _collapsed_content_row = [[<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${content}</div>]], |
| _alternative_name_template = [[<div style="display: inline-block; vertical-align: middle;"><small>''${label}:''</small></div> <div style="display: inline-block; vertical-align: middle;"><small>''${name}<br />${japanese_name}''</small></div>]], | | _alternative_name_template = [[<div style="display: inline-block; vertical-align: middle;"><small>''${label}:''</small></div> <div style="display: inline-block; vertical-align: middle;"><small>''${name}<br />${japanese_name}''</small></div>]], |
− | _fit_group_template = " (${fit_group})", | + | _eq_group_template = " (${eq_group})", |
| _fit_group_tooltip = "Fit group based on experimental findings", | | _fit_group_tooltip = "Fit group based on experimental findings", |
| + | _concentrated_label = "Concentrated", |
| + | _air_radar_label = "Air Radar", |
| + | _high_angle_label = "High-angle", |
| + | _plus_fire_director_label = " + Fire Director", |
| _library_name_label = "Library name", | | _library_name_label = "Library name", |
| _list_name_label = "List name", | | _list_name_label = "List name", |
Line 58: |
Line 73: |
| _float_style_template = "float: ${float};", | | _float_style_template = "float: ${float};", |
| _shown_ship_types = { | | _shown_ship_types = { |
− | 2, 3, | + | 1, 2, |
− | 21, 4, | + | 3, 4, |
− | 5, 6, | + | 5, 21, |
− | 8, 9, | + | 6, 8, |
− | 10, 7, | + | 9, 10, |
− | 11, 18, | + | 7, 11, |
| + | 18, 16, |
| 13, 14, | | 13, 14, |
− | 20, 16, | + | 20, 22, |
− | 22, 19, | + | 19, 17 |
− | 17, false
| |
| }, | | }, |
| _fields = { | | _fields = { |
Line 86: |
Line 101: |
| "crafting", | | "crafting", |
| "compatibility_details", | | "compatibility_details", |
| + | "bonus_details", |
| }, | | }, |
| } | | } |
Line 122: |
Line 138: |
| | | |
| function EquipmentInfoKai:flight_stats() | | function EquipmentInfoKai:flight_stats() |
− | local eq_type = self._equipment:type()
| + | if self._equipment:is_lbas_plane() then |
− | if eq_type == 6 or eq_type == 7 or eq_type == 8 or eq_type == 9 or eq_type == 11 or eq_type == 10 or eq_type == 41 or eq_type == 45 or eq_type == 47 or eq_type == 48 or eq_type == 94 then
| + | self._vars.flight_stats = format{self._flight_stats_template, combat_radius = Formatting:format_stat(self._equipment:combat_radius()), deployment_cost = Formatting:format_resources(self._equipment:deployment_cost())} |
− | self._vars.flight_stats = format{self._flight_stats_template, combat_radius = Formatting:format_stat(self._equipment:combat_radius()), deployment_cost = Formatting:format_resources(self._equipment:deployment_cost())}
| + | else |
− | else
| + | self._vars.flight_stats = "" |
− | self._vars.flight_stats = ""
| + | end |
− | end
| |
| end | | end |
| | | |
Line 213: |
Line 228: |
| function EquipmentInfoKai:eq_type() | | function EquipmentInfoKai:eq_type() |
| local eq_type = self._equipment:type() | | local eq_type = self._equipment:type() |
− | self._vars.eq_type = Formatting:format_equipment_type(eq_type) | + | self._vars.eq_type = Formatting:format_equipment_type(self._equipment:type()) |
| local album_type = self._equipment:album_type() | | local album_type = self._equipment:album_type() |
| if album_type then | | if album_type then |
| self._vars.eq_type = Formatting:tooltip(self._vars.eq_type, album_type) | | self._vars.eq_type = Formatting:tooltip(self._vars.eq_type, album_type) |
| end | | end |
| + | self._vars.eq_group = "" |
| if eq_type == 3 or eq_type == 38 then | | if eq_type == 3 or eq_type == 38 then |
− | self._vars.fit_group = format{self._fit_group_template, fit_group = Formatting:tooltip(Formatting:format_stat(self._equipment:gun_fit_group()), self._fit_group_tooltip)} | + | self._vars.eq_group = format{self._eq_group_template, eq_group = Formatting:tooltip(Formatting:format_stat(self._equipment:gun_fit_group()), self._fit_group_tooltip)} |
| + | elseif eq_type == 21 then |
| + | local aa = self._equipment:aa() |
| + | if aa and aa >= 9 then |
| + | self._vars.eq_group = format{self._eq_group_template, eq_group = self._concentrated_label} |
| + | end |
| + | elseif eq_type == 12 or eq_type == 13 or eq_type == 93 then |
| + | local aa = self._equipment:aa() |
| + | if aa and aa >= 2 then |
| + | self._vars.eq_group = format{self._eq_group_template, eq_group = self._air_radar_label} |
| + | end |
| else | | else |
− | self._vars.fit_group = "" | + | local icon = self._equipment:icon() |
| + | if icon and icon == 16 then |
| + | local aa = self._equipment:aa() |
| + | local eq_group = self._high_angle_label |
| + | if aa and aa >= 8 then |
| + | eq_group = eq_group .. self._plus_fire_director_label |
| + | end |
| + | self._vars.eq_group = format{self._eq_group_template, eq_group = eq_group} |
| + | end |
| end | | end |
| end | | end |
Line 295: |
Line 329: |
| table.insert(result, format{self._compatibility_cell, bg_color = Formatting:format_equipment_compatibility(compatibility), label = ship_label}) | | table.insert(result, format{self._compatibility_cell, bg_color = Formatting:format_equipment_compatibility(compatibility), label = ship_label}) |
| --table.insert(result, format{self._compatibility_cell, bg_color = Formatting:format_equipment_compatibility_color(compatibility), label = ship_label}) | | --table.insert(result, format{self._compatibility_cell, bg_color = Formatting:format_equipment_compatibility_color(compatibility), label = ship_label}) |
| + | end |
| + | if self._equipment:is_lbas_plane() then |
| + | table.insert(result, self._lbas_compatibility_row) |
| end | | end |
| self._vars.compatibility_details = table.concat(result, "\n") | | self._vars.compatibility_details = table.concat(result, "\n") |
| + | end |
| + | |
| + | local function format_bonus_text(desc) |
| + | local with_formats = { |
| + | ["Radar"] = "[[File:Radar.png|link=Radar|Radar with accuracy ≥ 3]]", |
| + | ["SRadar"] = "[[File:Radar.png|link=Radar|Surface Radar with accuracy ≥ 3]]", |
| + | ["ARadar"] = "[[File:Radar.png|link=Radar|Air Radar with accuracy ≥ 3]]", |
| + | ["53Torpedo"] = "[[File:Torpedo.png|link=53cm Twin Torpedo Mount|53cm Twin Torpedo Mount]]", |
| + | ["61Torpedo"] = "[[File:Torpedo.png|link=Category:Equipment fits with 12.7cm Single High-angle Gun Mount (Late Model)|Fits with 61cm Triple Torpedo Mount and 61cm Triple (Oxygen) Torpedo Mount only]]", |
| + | } |
| + | local with = desc._with and with_formats[desc._with] and " " .. with_formats[desc._with] or "" |
| + | local count = desc._count and " " .. Formatting:tooltip("×" .. desc._count, "amount of equipment") or "" |
| + | local text = desc._ship and |
| + | string.format("[[%s]]%s", desc._ship, count) or |
| + | desc._class and |
| + | string.format( |
| + | "[[:Category:%s Class|%s Class]]%s%s", |
| + | desc._class, |
| + | desc._class, |
| + | desc._suffix and " " .. desc._suffix or "", |
| + | count |
| + | ) or |
| + | "??" |
| + | return text, with |
| + | end |
| + | |
| + | local function format_bonus_stat(desc, stat) |
| + | return type(desc[stat]) == "table" and |
| + | Formatting:tooltip(U.isum(desc[stat]), U.ijoin(U.imap(desc[stat], function(e) return "+" .. e end), " ")) or |
| + | desc[stat] or |
| + | false |
| + | end |
| + | |
| + | function EquipmentInfoKai:bonus_details() |
| + | --[=[ |
| + | local result = { format{self._bonus_header, category = U.category("Equipment with stat bonuses") } } |
| + | for _, ship in ipairs(U.isort(U.keys(self._equipment._bonus or {}))) do |
| + | local s = self._equipment._bonus[ship] or {} |
| + | table.insert(result, format{ |
| + | self._bonus_row, |
| + | text = string.sub(ship, 1, 1) == "@" and string.sub(ship, 2) or ("[[" .. ship .. "]]"), |
| + | stats = Formatting:format_stat_bonuses({ |
| + | firepower = s._firepower or false, |
| + | bombing = s._bombing or false, |
| + | torpedo = s._torpedo or false, |
| + | aa = s._aa or false, |
| + | armor = s._armor or false, |
| + | asw = s._asw or false, |
| + | shelling_accuracy = s._shelling_accuracy or false, |
| + | torpedo_accuracy = s._torpedo_accuracy or false, |
| + | evasion = s._evasion or false, |
| + | los = s._los or false, |
| + | speed = s._speed or false, |
| + | luck = s._luck or false, |
| + | range = s._range or false, |
| + | special = s._special or false, |
| + | }) |
| + | }) |
| + | end |
| + | local text, with, prevText |
| + | for _, desc in ipairs(self._equipment._bonuses or {}) do |
| + | text, with = format_bonus_text(desc) |
| + | table.insert(result, format{ |
| + | self._bonus_row, |
| + | text = text ~= prevText and text .. with or with, |
| + | stats = Formatting:format_stat_bonuses({ |
| + | firepower = format_bonus_stat(desc, "_firepower"), |
| + | bombing = format_bonus_stat(desc, "_bombing"), |
| + | torpedo = format_bonus_stat(desc, "_torpedo"), |
| + | aa = format_bonus_stat(desc, "_aa"), |
| + | armor = format_bonus_stat(desc, "_armor"), |
| + | asw = format_bonus_stat(desc, "_asw"), |
| + | shelling_accuracy = format_bonus_stat(desc, "_shelling_accuracy"), |
| + | torpedo_accuracy = format_bonus_stat(desc, "_torpedo_accuracy"), |
| + | evasion = format_bonus_stat(desc, "_evasion"), |
| + | los = format_bonus_stat(desc, "_los"), |
| + | speed = format_bonus_stat(desc, "_speed"), |
| + | luck = format_bonus_stat(desc, "_luck"), |
| + | range = format_bonus_stat(desc, "_range"), |
| + | special = format_bonus_stat(desc, "_special"), |
| + | }) |
| + | }) |
| + | prevText = text |
| + | end |
| + | ]=]-- |
| + | self._vars.bonus_details = "" -- #result > 1 and ("\n" .. table.concat(result, "\n")) or "" |
| end | | end |
| | | |
Line 318: |
Line 441: |
| | | |
| function EquipmentInfoKai:create_item() | | function EquipmentInfoKai:create_item() |
− | if self._args.name then | + | self._equipment = Equipment(self._args[1], self._enemy) |
− | self._equipment = Equipment(self._args.name, self._args.model)
| |
− | else
| |
− | self._equipment = Equipment(self._args[1])
| |
− | end
| |
| end | | end |
| | | |
Line 331: |
Line 450: |
| function EquipmentInfoKai:create_infobox_prep() | | function EquipmentInfoKai:create_infobox_prep() |
| self._vars = {} | | self._vars = {} |
− | local table_classes = {"infobox", "infobox-left"} | + | local table_classes = {"infobox", "infobox-left", "infobox-equipment"} |
| if self._args.classes then | | if self._args.classes then |
| table.insert(table_classes, self._args.classes) | | table.insert(table_classes, self._args.classes) |