- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:ShipInfoKai"
Jump to navigation
Jump to search
com>Ckwng |
com>Ckwng |
||
Line 71: | Line 71: | ||
| colspan="5" style="text-align: center; background-color: LightSkyBlue;"|'''Stock Equipment''' | | colspan="5" style="text-align: center; background-color: LightSkyBlue;"|'''Stock Equipment''' | ||
| style="text-align: center; background-color: LightSkyBlue; width: 50px;" | '''Space''' | | style="text-align: center; background-color: LightSkyBlue; width: 50px;" | '''Space''' | ||
+ | ${slot_details} | ||
|- | |- | ||
− | ${ | + | | colspan="6" style="text-align: center; background-color: LightSkyBlue;"|'''Modernization Bonus''' |
+ | |- | ||
+ | | colspan="6" style="text-align: center;"| ${modernization} | ||
|}]], | |}]], | ||
} | } | ||
Line 220: | Line 223: | ||
end | end | ||
return table.concat(slots) | return table.concat(slots) | ||
+ | end | ||
+ | |||
+ | function ShipInfoKai:modernization(ship) | ||
+ | return Formatting:format_stat_bonuses(ship:modernization()) | ||
end | end | ||
Line 244: | Line 251: | ||
labels[k] = Formatting:format_stat_name(k) | labels[k] = Formatting:format_stat_name(k) | ||
end | end | ||
− | |||
vars.icons = icons | vars.icons = icons | ||
vars.labels = labels | vars.labels = labels | ||
Line 270: | Line 276: | ||
vars.slots = self:slots(ship) | vars.slots = self:slots(ship) | ||
vars.slot_details = self:slot_details(ship) | vars.slot_details = self:slot_details(ship) | ||
+ | vars.modernization = self:modernization(ship) | ||
return format(self._template, vars) | return format(self._template, vars) | ||
end | end | ||
return ShipInfoKai | return ShipInfoKai |
Revision as of 10:36, 22 February 2015
Documentation for this module may be created at Module:ShipInfoKai/doc
local Ship = require('Module:Ship')
local StatIcons = require('Module:StatIcons')
local Formatting = require('Module:Formatting')
local format = require('Module:StringInterpolation').format
local ShipInfoKai = {
_catbomb = "Catbomb.png|300px",
_unbuildable = "''Unbuildable''",
_remodel_level = "'''Remodel Level'''",
_build_time = "'''Build Time'''",
_default_slot_num = 4,
_id_1 = "%s",
_id_2 = "%s (%s)",
_stat_1 = "%d",
_stat_2 = "%d (%d)",
_normal_construction = "Normal",
_large_ship_construction = "LSC",
_kekkon_max_template = "Maximum after marriage: ${value}",
_slot_template = [[|- align=center style="background-color: whitesmoke; line-height: 1.1;"
| style="width: 36px; height: 36px; background-color: ${color};${extra_style}" | ${icon}
| colspan="4" style="width: 190px;" | ${equipment}
| style="width: 50px;" | ${slot_size}
]],
_image_template = "[[File:%s]]",
_template = [[{|style="border: 1px solid darkgray; width: 320px;"
|-
|colspan="6" style="text-align: center; background-color: ${top_bg_color};${top_extra_style}"|<p style="font-size:20px">'''${name}'''</p>
<p style="font-size:15px">'''No.${id} ${japanese_name}'''</p>
<p>'''${class} ${type}'''</p>
|-
| align=center colspan="6" | ${image}
|-
| colspan="6" style="text-align: center; background-color: LightSkyBlue;"|'''Statistics'''
|-
| colspan="2" style="width: 88px;" | ${icons.hp} ${labels.hp}
| style="width: 66px;" | '''${hp}'''
| style="width: 88px;" | ${icons.firepower} ${labels.firepower}
| colspan="2" style="width: 60px;" | '''${firepower}'''
|-
| colspan="2" style="width: 88px;" | ${icons.armor} ${labels.armor}
| style="width: 66px;" | '''${armor}'''
| style="width: 88px;" | ${icons.torpedo} ${labels.torpedo}
| colspan="2" style="width: 66px;" | '''${torpedo}'''
|-
| colspan="2" style="width: 88px;" | ${icons.evasion} ${labels.evasion}
| style="width: 66px;" | '''${evasion}'''
| style="width: 88px;" | ${icons.aa} ${labels.aa}
| colspan="2" style="width: 66px;" | '''${aa}'''
|-
| colspan="2" style="width: 88px;" | ${icons.aircraft} ${labels.aircraft}
| style="width: 66px;" | '''${aircraft}'''
| style="width: 88px;" | ${icons.asw} ${labels.asw}
| colspan="2" style="width: 66px;" | '''${asw}'''
|-
| colspan="2" style="width: 88px;" | ${icons.speed} ${labels.speed}
| style="width: 66px;" | '''${speed}'''
| style="width: 88px;" | ${icons.los} ${labels.los}
| colspan="2" style="width: 66px;" | '''${los}'''
|-
| colspan="2" style="width: 88px;" | ${icons.range} ${labels.range}
| style="width: 66px;" | '''${range}'''
| style="width: 88px;" | ${icons.luck} ${labels.luck}
| colspan="2" style="width: 66px;" | '''${luck}'''
|-
| colspan="5" style="text-align: center; background-color: LightSkyBlue;"|${build_remodel_header}
| style="text-align: center; background-color: LightSkyBlue; width: 50px;" | '''Slots'''
|-
| colspan="5" style="text-align: center;"|${build_remodel_info}
| align=center style="width: 50px;" |${slots}
|-
| colspan="5" style="text-align: center; background-color: LightSkyBlue;"|'''Stock Equipment'''
| style="text-align: center; background-color: LightSkyBlue; width: 50px;" | '''Space'''
${slot_details}
|-
| colspan="6" style="text-align: center; background-color: LightSkyBlue;"|'''Modernization Bonus'''
|-
| colspan="6" style="text-align: center;"| ${modernization}
|}]],
}
function ShipInfoKai:bg_color(ship)
local rarity = ship:rarity()
return Formatting:format_ship_back(rarity), Formatting:extra_style_background_image(rarity and rarity > 7, rarity and rarity > 6)
end
function ShipInfoKai:name(ship)
return Formatting:format_link(ship:link())
end
function ShipInfoKai:japanese_name(ship)
return Formatting:tooltip(Formatting:format_stat(ship:japanese_name()), Formatting:format_stat(ship:reading()))
end
function ShipInfoKai:id(ship)
return Formatting:format_stat_with_max(ship:id(), ship:true_id())
end
function ShipInfoKai:class(ship)
local class = ship:class()
return Formatting:format_stat(class and class:name())
end
function ShipInfoKai:type(ship)
return Formatting:format_ship_type(ship:type())
end
function ShipInfoKai:image(ship)
return Formatting:format_image{ship:card()}
end
function ShipInfoKai:hp(ship)
local hp = Formatting:format_stat(ship:hp())
local hp_max = ship:hp_max()
if hp_max then
return Formatting:tooltip(hp, format{self._kekkon_max_template, value = Formatting:format_stat(hp_max)})
end
return hp
end
function ShipInfoKai:firepower(ship)
return Formatting:format_stat_with_max(ship:firepower(), ship:firepower_max())
end
function ShipInfoKai:armor(ship)
return Formatting:format_stat_with_max(ship:armor(), ship:armor_max())
end
function ShipInfoKai:torpedo(ship)
return Formatting:format_stat_with_max(ship:torpedo(), ship:torpedo_max())
end
function ShipInfoKai:evasion(ship)
return Formatting:format_stat_with_max(ship:evasion(), ship:evasion_max())
end
function ShipInfoKai:aa(ship)
return Formatting:format_stat_with_max(ship:aa(), ship:aa_max())
end
function ShipInfoKai:aircraft(ship)
return Formatting:format_stat(ship:total_space())
end
function ShipInfoKai:asw(ship)
return Formatting:format_stat_with_max(ship:asw(), ship:asw_max())
end
function ShipInfoKai:speed(ship)
return Formatting:format_speed(ship:speed())
end
function ShipInfoKai:los(ship)
return Formatting:format_stat_with_max(ship:los(), ship:los_max())
end
function ShipInfoKai:range(ship)
return Formatting:format_range(ship:range())
end
function ShipInfoKai:luck(ship)
return Formatting:format_stat_with_max(ship:luck(), ship:luck_max())
end
function ShipInfoKai:build_remodel_header(ship)
return ship:remodel_level() and self._remodel_level or self._build_time
end
function ShipInfoKai:build_remodel_info(ship)
local remodel_level = ship:remodel_level()
if remodel_level then
return Formatting:format_remodel_level_and_cost(remodel_level, ship:remodel_cost(), ship:remodel_blueprint())
else
local buildable = ship:buildable()
local buildable_lsc = ship:buildable_lsc()
if buildable or buildable_lsc then
local buildable_methods = {}
if buildable then
table.insert(buildable_methods, self._normal_construction)
end
if buildable_lsc then
table.insert(buildable_methods, self._large_ship_construction)
end
return Formatting:format_stat_with_max(Formatting:seconds_to_hms(ship:build_time() * 60), table.concat(buildable_methods, ", "))
else
return self._unbuildable
end
end
end
function ShipInfoKai:slots(ship)
return Formatting:format_stat(ship:slots())
end
function ShipInfoKai:slot_details(ship)
local slots = {}
local num_of_slots = ship:slots()
local slots_to_show
if num_of_slots then
slots_to_show = math.max(self._default_slot_num, num_of_slots)
else
slots_to_show = self._default_slot_num
end
for i = 1, slots_to_show do
local equipment, size, icon, color, equipment_type
if num_of_slots and i > num_of_slots then
equipment, size, icon, color, equipment_type = "- Locked -", "-", "", 0, false
else
equipment, size = ship:slot(i)
if equipment then
icon = equipment:icon()
color = equipment:back()
equipment_type = equipment:type()
equipment = Formatting:format_link(equipment:link())
else
icon = false
color = 0
equipment = equipment == false and "- Unequipped -" or Formatting:format_stat(equipment)
equipment_type = false
end
icon = Formatting:format_image{Formatting:format_equipment_icon(icon), caption = Formatting:format_equipment_type(equipment_type)}
end
table.insert(slots, format{self._slot_template, icon = icon, equipment = equipment, slot_size = Formatting:format_stat(size), color = Formatting:format_equipment_back(color), extra_style = Formatting:extra_style_background_image(false, color >= 4)})
end
return table.concat(slots)
end
function ShipInfoKai:modernization(ship)
return Formatting:format_stat_bonuses(ship:modernization())
end
function ShipInfoKai:Infobox(name, model)
local ship = Ship(name, model)
local vars = {}
local icons = {
hp = StatIcons.hp,
firepower = StatIcons.firepower,
armor = StatIcons.armor,
torpedo = StatIcons.torpedo,
evasion = StatIcons.evasion,
aa = StatIcons.aa,
aircraft = StatIcons.aircraft,
asw = StatIcons.asw,
speed = StatIcons.speed,
los = StatIcons.los,
range = StatIcons.range,
luck = StatIcons.luck,
}
local labels = {}
for k,v in pairs(icons) do
icons[k] = Formatting:format_image{v}
labels[k] = Formatting:format_stat_name(k)
end
vars.icons = icons
vars.labels = labels
vars.top_bg_color, vars.top_extra_style = self:bg_color(ship)
vars.name = self:name(ship)
vars.id = self:id(ship)
vars.japanese_name = self:japanese_name(ship)
vars.class = self:class(ship)
vars.type = self:type(ship)
vars.image = self:image(ship)
vars.hp = self:hp(ship)
vars.firepower = self:firepower(ship)
vars.armor = self:armor(ship)
vars.torpedo = self:torpedo(ship)
vars.evasion = self:evasion(ship)
vars.aa = self:aa(ship)
vars.aircraft = self:aircraft(ship)
vars.asw = self:asw(ship)
vars.speed = self:speed(ship)
vars.los = self:los(ship)
vars.range = self:range(ship)
vars.luck = self:luck(ship)
vars.build_remodel_header = self:build_remodel_header(ship)
vars.build_remodel_info = self:build_remodel_info(ship)
vars.slots = self:slots(ship)
vars.slot_details = self:slot_details(ship)
vars.modernization = self:modernization(ship)
return format(self._template, vars)
end
return ShipInfoKai