- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Module:EquipmentInfoKai
Revision as of 07:40, 4 June 2015 by com>Ckwng (Typo)
Documentation for this module may be created at Module:EquipmentInfoKai/doc
local Equipment = require('Module:Equipment')
local Formatting = require('Module:Formatting')
local format = require('Module:StringInterpolation').format
local EquipmentInfoKai = {
_template = [[{|style="border: 1px solid darkgray; width: 400px;"
|-
| colspan="2" style="position: relative; padding: 1px 40px; text-align: center; background-color: ${back};${extra_style};"|<div style="position: absolute; right: 5px;">${edit_link}</div>
<p style="font-size: 25px">'''${name}'''</p>${localized_name}
<p style="font-size: 20px">'''No.${id} ${japanese_name}'''</p>
|-
| colspan="2" style="text-align: center; background-color: whitesmoke;"|
'''${icon} ${eq_type}'''
<b>Effects: ${effects}</b>
'''Scrap value: ${scrap}'''${alternative_names}
|-
| colspan="2" style="text-align: center;" | ${card}
|-
| colspan="2" style="text-align: center; background-color: LightSkyBlue;" | '''Refittable Class'''
${compatibility_details}
|}]],
_row_starter = "|-",
_compatibility_cell = [[| style="width: 200px; text-align: center; background-color: ${bg_color};" | ${label}]],
_localized_name_template = "<p>''${localized_name}''</p>",
_alternative_names_template = [[
|-
<div class="mw-collapsible mw-collapsed" style="background-color: lightgrey;">''Alternate names''<div class="mw-collapsible-content" style="background-color: whitesmoke;">
${names}
</div></div>]],
_alternative_name_template = [[<p><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></p>]],
_library_name_label = "Library name",
_list_name_label = "List name",
_comparison_name_label = "Comparison name",
_equipment_data_documentation = "Template:EquipmentDataDocumentation/EditIntro",
_edit_link_text = "Edit",
_empty_card = "Empty equipment card slot.png",
_shown_ship_types = {
2,
3,
--
21,
4,
--
5,
6,
--
8,
9,
--
10,
7,
--
11,
18,
--
13,
14,
--
20,
16,
--
17,
19,
}
}
function EquipmentInfoKai:edit_link(equipment_data_module)
return Formatting:format_edit_link(equipment_data_module, self._edit_link_text, self._equipment_data_documentation)
end
function EquipmentInfoKai:back(equipment)
return Formatting:format_equipment_back(equipment:back())
end
function EquipmentInfoKai:extra_style(equipment)
local back = equipment:back()
return Formatting:extra_style_background_image(false, back and back >= 4)
end
function EquipmentInfoKai:name(equipment)
return Formatting:format_link(equipment:link())
end
function EquipmentInfoKai:localized_name(equipment)
local localized_name = equipment:localized_name()
if localized_name then
return format{self._localized_name_template, localized_name = localized_name}
end
return ""
end
function EquipmentInfoKai:alternative_names(equipment)
local alternative_names = {}
local list_name = equipment:list_name()
local library_name = equipment:library_name()
local comparison_name = equipment:comparison_name()
if list_name then
local list_japanese_name = equipment:list_japanese_name()
local list_reading = equipment:list_reading()
if list_reading ~= false then
list_japanese_name = tostring(Formatting:japanese_text{Formatting:format_stat(list_japanese_name), Formatting:format_stat(list_reading)})
end
local list_localized_name = equipment:list_localized_name()
if list_localized_name then
list_name = Formatting:tooltip(Formatting:format_stat(list_name), Formatting:format_stat(list_localized_name))
else
list_name = Formatting:format_stat(list_name)
end
table.insert(alternative_names, format{self._alternative_name_template, label = self._list_name_label, name = list_name, japanese_name = list_japanese_name})
end
if library_name then
local library_japanese_name = equipment:library_japanese_name()
local library_reading = equipment:library_reading()
if library_reading ~= false then
library_japanese_name = tostring(Formatting:japanese_text{Formatting:format_stat(library_japanese_name), Formatting:format_stat(library_reading)})
end
local library_localized_name = equipment:library_localized_name()
if library_localized_name then
library_name = Formatting:tooltip(Formatting:format_stat(library_name), Formatting:format_stat(library_localized_name))
else
library_name = Formatting:format_stat(library_name)
end
table.insert(alternative_names, format{self._alternative_name_template, label = self._library_name_label, name = library_name, japanese_name = library_japanese_name})
end
if comparison_name then
local comparison_japanese_name = equipment:comparison_japanese_name()
local comparison_reading = equipment:comparison_reading()
if comparison_reading ~= false then
comparison_japanese_name = tostring(Formatting:japanese_text{Formatting:format_stat(comparison_japanese_name), Formatting:format_stat(comparison_reading)})
end
local comparison_localized_name = equipment:comparison_localized_name()
if comparison_localized_name then
comparison_name = Formatting:tooltip(Formatting:format_stat(comparison_name), Formatting:format_stat(comparison_localized_name))
else
comparison_name = Formatting:format_stat(comparison_name)
end
table.insert(alternative_names, format{self._alternative_name_template, label = self._comparison_name_label, name = comparison_name, japanese_name = comparison_japanese_name})
end
if #alternative_names == 0 then
return ""
end
return format{self._alternative_names_template, names = table.concat(alternative_names, "\n")}
end
function EquipmentInfoKai:id(equipment)
return Formatting:format_stat(equipment:id())
end
function EquipmentInfoKai:japanese_name(equipment)
return tostring(Formatting:japanese_text{Formatting:format_stat(equipment:japanese_name()), Formatting:format_stat(equipment:reading())})
end
function EquipmentInfoKai:icon(equipment)
return Formatting:format_image{Formatting:format_equipment_icon(equipment:icon())}
end
function EquipmentInfoKai:eq_type(equipment)
return Formatting:tooltip(Formatting:format_equipment_type(equipment:type()), Formatting:format_equipment_rarity(equipment:rarity()))
end
function EquipmentInfoKai:effects(equipment)
return Formatting:format_stat_bonuses{
firepower = equipment:firepower(),
bombing = equipment:bombing(),
torpedo = equipment:torpedo(),
aa = equipment:aa(),
armor = equipment:armor(),
asw = equipment:asw(),
shelling_accuracy = equipment:shelling_accuracy(),
torpedo_accuracy = equipment:torpedo_accuracy(),
evasion = equipment:evasion(),
los = equipment:los(),
speed = Formatting:format_speed(equipment:speed()),
luck = equipment:luck(),
range = Formatting:format_range(equipment:range()),
special = equipment:special(),
}
end
function EquipmentInfoKai:scrap(equipment)
return Formatting:format_resources(equipment:scrap())
end
function EquipmentInfoKai:card(equipment)
local card = equipment:card()
if card == false then
card = self._empty_card
end
local card_name = equipment:card_name()
if card_name then
local card_caption = {}
local card_local = equipment:card_localized_name()
if card_local ~= false then
table.insert(card_caption, Formatting:format_stat_with_max(card_name, card_local))
else
table.insert(card_caption, card_name)
end
table.insert(card_caption, "/")
table.insert(card_caption, Formatting:format_stat_with_max(equipment:card_japanese_name(), equipment:card_reading()))
return Formatting:format_image{card,
caption = table.concat(card_caption)
}
end
return Formatting:format_image{card}
end
function EquipmentInfoKai:compatibility_details(equipment)
local result = {}
for index, ship_type in ipairs(self._shown_ship_types) do
if index % 2 == 1 then
table.insert(result, self._row_starter)
end
local compatibility, note = equipment:equippable(ship_type)
local ship_label = Formatting:format_ship_type(ship_type)
if note then
ship_label = Formatting:tooltip(ship_label, note)
end
table.insert(result, format{self._compatibility_cell, bg_color = Formatting:format_equipment_compatibility(compatibility), label = ship_label})
end
return table.concat(result, "\n")
end
function EquipmentInfoKai:Infobox(name)
local equipment = Equipment(name)
local equipment_data_module = Equipment:get_module(name)
return format{self._template,
edit_link = self:edit_link(equipment_data_module),
back = self:back(equipment),
extra_style = self:extra_style(equipment),
name = self:name(equipment),
localized_name = self:localized_name(equipment),
alternative_names = self:alternative_names(equipment),
id = self:id(equipment),
japanese_name = self:japanese_name(equipment),
icon = self:icon(equipment),
eq_type = self:eq_type(equipment),
effects = self:effects(equipment),
scrap = self:scrap(equipment),
card = self:card(equipment),
compatibility_details = self:compatibility_details(equipment),
}
end
return EquipmentInfoKai