- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Changes
Jump to navigation
Jump to search
Created page with "local BaseTable = require('Module:BaseTable') local Equipment = require('Module:Equipment') local Formatting = require('Module:Formatting') local ResourceIcons = require('Modu..."
local BaseTable = require('Module:BaseTable')
local Equipment = require('Module:Equipment')
local Formatting = require('Module:Formatting')
local ResourceIcons = require('Module:ResourceIcons')
local Ship = require('Module:Ship')
local format = require('Module:StringInterpolation').format
local ImprovementTableKai = BaseTable{
_item_class = Equipment,
_header_template = [[
! style="text-align: center; padding: 5px;" | Improvement Cost: ${resources}
! style="text-align: center; padding: 5px;" | ★
! style="text-align: center; padding: 5px;" | ${devmat}
! style="text-align: center; padding: 5px;" | ${screw}
! style="text-align: center; padding: 5px;" | S
! style="text-align: center; padding: 5px;" | M
! style="text-align: center; padding: 5px;" | T
! style="text-align: center; padding: 5px;" | W
! style="text-align: center; padding: 5px;" | T
! style="text-align: center; padding: 5px;" | F
! style="text-align: center; padding: 5px;" | S
! style="text-align: center; padding: 5px;" | Helper Ship]],
_column_cell_templates = {
name = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.name}<br />${values.icon} ${values.japanese_name}]]
},
_columns = {
"input_output",
"improvement_level",
"development_material",
"improvement_material",
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"helper_ships",
},
_improvement_brackets = {
0,
6,
10
},
_consumed_equipment_label = "Consumes: ${list}",
_produced_equipment_label = "Produces: 1x ${icon}${name}",
_equipment_item = "${count}x ${icon}${name}",
_unavailable_color = "#f99",
_available_color = "#aaebaa",
}
function ImprovementTableKai:create_items_post()
self._custom_rows = {}
local result = {}
if #self._items == 1 then
self._single_item = true
end
for _, item in ipairs(self._items) do
local products = item:improvement_products()
if products then
if self._single_item then
self._title_row = format{[[|+ ${icon}{$name}]], icon = Formatting:format_image{Formatting:format_equipment_icon(equipment:icon())}, name = Formatting:format_link(equipment:link())}
else
self._custom_rows[item:name()] = format{[[| colspan="12" style="text-align: center; padding:5px 5px 5px 5px;" | ${icon}${name}]], icon = Formatting:format_image{Formatting:format_equipment_icon(equipment:icon())}, name = Formatting:format_link(equipment:link())}
table.insert(result, item:name())
end
for _, product in ipairs(products) do
local ships = item:improvement_ships(product)
local availability = {}
for _, ship in ipairs(ships) do
table.insert(availability, item:improvement_availability(product, ship))
end
for _, stars in ipairs(self._improvement_brackets) do
table.insert(result, {item = item, product = product, stars = stars, ships = ships, availability = availability, resources = item:improvement_resources(false, product, stars), resources_x = item:improvement_resources(true, product, stars)})
end
end
end
end
end
function ImprovementTableKai:input_output(row_data)
local value = "-"
if row_data.resources then
local result = {}
local consumed_equipment_table = row_data.resources.equipment
local consumed_equipment = {}
for equip, count in pairs(consumed_equipment_table) do
local equipment = equip and Equipment(equip) or row_data.item
table.insert(consumed_equipment, format{self._equipment_item, count = count, icon = Formatting:format_equipment_icon_simple(equipment:icon()), name = Formatting:format_link(equipment:link())})
end
table.insert(result, format{self._consumed_equipment_label, list = table.concat(consumed_equipment, "<br />")})
if row_data.stars == self._improvement_brackets[#self._improvement_brackets] and row_data.product then
local product = Equipment(row_data.product)
table.insert(result, format{self._produced_equipment_label, icon = Formatting:format_equipment_icon_simple(product:icon()), name = Formatting:format_link(product:link())})
end
value = table.concat(result, "<br />")
end
return {values = {value = value}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:improvement_level(row_data)
return {values = {value = row_data.stars}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:development_material(row_data)
return {values = {value = format{self._material_cell_content, normal = row_data.resources.development_material, slider = row_data.resources_x.development_material}}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:improvement_material(row_data)
return {values = {value = format{self._material_cell_content, normal = row_data.resources.improvement_material, slider = row_data.resources_x.improvement_material}}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:sunday(row_data)
return self:availability(row_data, "Sunday")
end
function ImprovementTableKai:monday(row_data)
return self:availability(row_data, "Monday")
end
function ImprovementTableKai:tuesday(row_data)
return self:availability(row_data, "Tuesday")
end
function ImprovementTableKai:wednesday(row_data)
return self:availability(row_data, "Wednesday")
end
function ImprovementTableKai:thursday(row_data)
return self:availability(row_data, "Thursday")
end
function ImprovementTableKai:friday(row_data)
return self:availability(row_data, "Friday")
end
function ImprovementTableKai:saturday(row_data)
return self:availability(row_data, "Saturday")
end
function ImprovementTableKai:availability(row_data, day)
local availability = {}
local bg_color = self._unavailable_color
for index, ship in ipairs(row_data.ships) do
if row_data.availability[ship][day] then
bg_color = self._available_color
table.insert(availability, mw.ustring.sub(ship:name(), 1, 2))
else
table.insert(availability, " ")
end
end
return {values = {value = table.concat(availability, "<br />")}, bg_color = bg_color, text_align = self._center_align}
end
function ImprovementTableKai:helper_ships(row_data)
local ships = {}
for index, ship in ipairs(row_data.ships) do
table.insert(ships, Formatting:format_link(ship:link()))
end
return {values = {value = table.concat(ships, "<br />")}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:start_rows()
if self._single_item then
self._rows = {self._table_start, self._title_row, self._header}
else
self._rows = {self._table_start, self._header}
end
end
function ImprovementTableKai:create_header()
local header_icons = {
fuel = ResourceIcons.fuel,
ammo = ResourceIcons.ammo,
steel = ResourceIcons.steel,
bauxite = ResourceIcons.bauxite,
devmat = ResourceIcons.devmat,
screw = ResourceIcons.screw,
}
for key, value in pairs(header_icons) do
header_icons[key] = Formatting:format_image{value, caption = Formatting:format_stat_name(key)}
end
self._header = format{self._header_template, stat_columns = format{self._column_header_cell_template, value = self._stats_column_label}}
end
return ImprovementTableKai
local Equipment = require('Module:Equipment')
local Formatting = require('Module:Formatting')
local ResourceIcons = require('Module:ResourceIcons')
local Ship = require('Module:Ship')
local format = require('Module:StringInterpolation').format
local ImprovementTableKai = BaseTable{
_item_class = Equipment,
_header_template = [[
! style="text-align: center; padding: 5px;" | Improvement Cost: ${resources}
! style="text-align: center; padding: 5px;" | ★
! style="text-align: center; padding: 5px;" | ${devmat}
! style="text-align: center; padding: 5px;" | ${screw}
! style="text-align: center; padding: 5px;" | S
! style="text-align: center; padding: 5px;" | M
! style="text-align: center; padding: 5px;" | T
! style="text-align: center; padding: 5px;" | W
! style="text-align: center; padding: 5px;" | T
! style="text-align: center; padding: 5px;" | F
! style="text-align: center; padding: 5px;" | S
! style="text-align: center; padding: 5px;" | Helper Ship]],
_column_cell_templates = {
name = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.name}<br />${values.icon} ${values.japanese_name}]]
},
_columns = {
"input_output",
"improvement_level",
"development_material",
"improvement_material",
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"helper_ships",
},
_improvement_brackets = {
0,
6,
10
},
_consumed_equipment_label = "Consumes: ${list}",
_produced_equipment_label = "Produces: 1x ${icon}${name}",
_equipment_item = "${count}x ${icon}${name}",
_unavailable_color = "#f99",
_available_color = "#aaebaa",
}
function ImprovementTableKai:create_items_post()
self._custom_rows = {}
local result = {}
if #self._items == 1 then
self._single_item = true
end
for _, item in ipairs(self._items) do
local products = item:improvement_products()
if products then
if self._single_item then
self._title_row = format{[[|+ ${icon}{$name}]], icon = Formatting:format_image{Formatting:format_equipment_icon(equipment:icon())}, name = Formatting:format_link(equipment:link())}
else
self._custom_rows[item:name()] = format{[[| colspan="12" style="text-align: center; padding:5px 5px 5px 5px;" | ${icon}${name}]], icon = Formatting:format_image{Formatting:format_equipment_icon(equipment:icon())}, name = Formatting:format_link(equipment:link())}
table.insert(result, item:name())
end
for _, product in ipairs(products) do
local ships = item:improvement_ships(product)
local availability = {}
for _, ship in ipairs(ships) do
table.insert(availability, item:improvement_availability(product, ship))
end
for _, stars in ipairs(self._improvement_brackets) do
table.insert(result, {item = item, product = product, stars = stars, ships = ships, availability = availability, resources = item:improvement_resources(false, product, stars), resources_x = item:improvement_resources(true, product, stars)})
end
end
end
end
end
function ImprovementTableKai:input_output(row_data)
local value = "-"
if row_data.resources then
local result = {}
local consumed_equipment_table = row_data.resources.equipment
local consumed_equipment = {}
for equip, count in pairs(consumed_equipment_table) do
local equipment = equip and Equipment(equip) or row_data.item
table.insert(consumed_equipment, format{self._equipment_item, count = count, icon = Formatting:format_equipment_icon_simple(equipment:icon()), name = Formatting:format_link(equipment:link())})
end
table.insert(result, format{self._consumed_equipment_label, list = table.concat(consumed_equipment, "<br />")})
if row_data.stars == self._improvement_brackets[#self._improvement_brackets] and row_data.product then
local product = Equipment(row_data.product)
table.insert(result, format{self._produced_equipment_label, icon = Formatting:format_equipment_icon_simple(product:icon()), name = Formatting:format_link(product:link())})
end
value = table.concat(result, "<br />")
end
return {values = {value = value}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:improvement_level(row_data)
return {values = {value = row_data.stars}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:development_material(row_data)
return {values = {value = format{self._material_cell_content, normal = row_data.resources.development_material, slider = row_data.resources_x.development_material}}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:improvement_material(row_data)
return {values = {value = format{self._material_cell_content, normal = row_data.resources.improvement_material, slider = row_data.resources_x.improvement_material}}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:sunday(row_data)
return self:availability(row_data, "Sunday")
end
function ImprovementTableKai:monday(row_data)
return self:availability(row_data, "Monday")
end
function ImprovementTableKai:tuesday(row_data)
return self:availability(row_data, "Tuesday")
end
function ImprovementTableKai:wednesday(row_data)
return self:availability(row_data, "Wednesday")
end
function ImprovementTableKai:thursday(row_data)
return self:availability(row_data, "Thursday")
end
function ImprovementTableKai:friday(row_data)
return self:availability(row_data, "Friday")
end
function ImprovementTableKai:saturday(row_data)
return self:availability(row_data, "Saturday")
end
function ImprovementTableKai:availability(row_data, day)
local availability = {}
local bg_color = self._unavailable_color
for index, ship in ipairs(row_data.ships) do
if row_data.availability[ship][day] then
bg_color = self._available_color
table.insert(availability, mw.ustring.sub(ship:name(), 1, 2))
else
table.insert(availability, " ")
end
end
return {values = {value = table.concat(availability, "<br />")}, bg_color = bg_color, text_align = self._center_align}
end
function ImprovementTableKai:helper_ships(row_data)
local ships = {}
for index, ship in ipairs(row_data.ships) do
table.insert(ships, Formatting:format_link(ship:link()))
end
return {values = {value = table.concat(ships, "<br />")}, bg_color = self._transparent, text_align = self._center_align}
end
function ImprovementTableKai:start_rows()
if self._single_item then
self._rows = {self._table_start, self._title_row, self._header}
else
self._rows = {self._table_start, self._header}
end
end
function ImprovementTableKai:create_header()
local header_icons = {
fuel = ResourceIcons.fuel,
ammo = ResourceIcons.ammo,
steel = ResourceIcons.steel,
bauxite = ResourceIcons.bauxite,
devmat = ResourceIcons.devmat,
screw = ResourceIcons.screw,
}
for key, value in pairs(header_icons) do
header_icons[key] = Formatting:format_image{value, caption = Formatting:format_stat_name(key)}
end
self._header = format{self._header_template, stat_columns = format{self._column_header_cell_template, value = self._stats_column_label}}
end
return ImprovementTableKai