- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Module:EquipmentComparisonKai
Revision as of 10:53, 25 March 2015 by com>Ckwng
Documentation for this module may be created at Module:EquipmentComparisonKai/doc
local Equipment = require('Module:Equipment')
local EquipmentListKai = require('Module:EquipmentListKai')
local Formatting = require('Module:Formatting')
local StatIcons = require('Module:StatIcons')
local format = require('Module:StringInterpolation').format
local EquipmentComparisonKai = EquipmentListKai{
_columns = {
"id",
"stars",
"name",
"equipment_type",
"firepower",
"torpedo",
"bombing",
"aa",
"asw",
"los",
"luck",
"armor",
"shelling_accuracy",
"evasion",
"speed",
"range",
"compatibility",
"buildable",
"notes",
},
_stat_columns = {
"firepower",
"torpedo",
"bombing",
"aa",
"asw",
"los",
"luck",
"armor",
"shelling_accuracy",
"evasion",
"speed",
"range",
},
_stats_column_label = "Stats",
}
function EquipmentComparisonKai:firepower(equipment)
local firepower = equipment:firepower()
if firepower ~= false then
self._shown_stats.firepower = true
else
firepower = 0
end
return {values = {value = Formatting:format_stat(firepower)}, bg_color = self:get_bg_color(self._cell_color.firepower, firepower, self._args.firepower_operator, self._args.firepower_outstanding, self._args.firepower_good), text_align = self._center_align}
end
function EquipmentComparisonKai:torpedo(equipment)
local torpedo = equipment:torpedo()
if torpedo ~= false then
self._shown_stats.torpedo = true
else
torpedo = 0
end
return {values = {value = Formatting:format_stat(torpedo)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good), text_align = self._center_align}
end
function EquipmentComparisonKai:bombing(equipment)
local bombing = equipment:bombing()
if bombing ~= false then
self._shown_stats.bombing = true
else
bombing = 0
end
return {values = {value = Formatting:format_stat(bombing)}, bg_color = self:get_bg_color(self._cell_color.bombing, bombing, self._args.bombing_operator, self._args.bombing_outstanding, self._args.bombing_good), text_align = self._center_align}
end
function EquipmentComparisonKai:aa(equipment)
local aa = equipment:aa()
if aa ~= false then
self._shown_stats.aa = true
else
aa = 0
end
return {values = {value = Formatting:format_stat(aa)}, bg_color = self:get_bg_color(self._cell_color.aa, aa, self._args.aa_operator, self._args.aa_outstanding, self._args.aa_good), text_align = self._center_align}
end
function EquipmentComparisonKai:asw(equipment)
local asw = equipment:asw()
if asw ~= false then
self._shown_stats.asw = true
else
asw = 0
end
return {values = {value = Formatting:format_stat(asw)}, bg_color = self:get_bg_color(self._cell_color.asw, asw, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good), text_align = self._center_align}
end
function EquipmentComparisonKai:los(equipment)
local los = equipment:los()
if los ~= false then
self._shown_stats.los = true
else
los = 0
end
return {values = {value = Formatting:format_stat(los)}, bg_color = self:get_bg_color(self._cell_color.los, los, self._args.los_operator, self._args.los_outstanding, self._args.los_good), text_align = self._center_align}
end
function EquipmentComparisonKai:luck(equipment)
local luck = equipment:luck()
if luck ~= false then
self._shown_stats.luck = true
else
luck = 0
end
return {values = {value = Formatting:format_stat(luck)}, bg_color = self:get_bg_color(self._cell_color.luck, luck, self._args.luck_operator, self._args.luck_outstanding, self._args.luck_good), text_align = self._center_align}
end
function EquipmentComparisonKai:armor(equipment)
local armor = equipment:armor()
if armor ~= false then
self._shown_stats.armor = true
else
armor = 0
end
return {values = {value = Formatting:format_stat(armor)}, bg_color = self:get_bg_color(self._cell_color.armor, armor, self._args.armor_operator, self._args.armor_outstanding, self._args.armor_good), text_align = self._center_align}
end
function EquipmentComparisonKai:shelling_accuracy(equipment)
local shelling_accuracy = equipment:shelling_accuracy()
if shelling_accuracy ~= false then
self._shown_stats.shelling_accuracy = true
else
shelling_accuracy = 0
end
return {values = {value = Formatting:format_stat(shelling_accuracy)}, bg_color = self:get_bg_color(self._cell_color.shelling_accuracy, shelling_accuracy, self._args.shelling_accuracy_operator, self._args.shelling_accuracy_outstanding, self._args.shelling_accuracy_good), text_align = self._center_align}
end
function EquipmentComparisonKai:evasion(equipment)
local evasion = equipment:evasion()
if evasion ~= false then
self._shown_stats.evasion = true
else
evasion = 0
end
return {values = {value = Formatting:format_stat(evasion)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good), text_align = self._center_align}
end
function EquipmentComparisonKai:speed(equipment)
local speed = equipment:speed()
if speed ~= false then
self._shown_stats.speed = true
else
speed = 0
end
return {values = {value = Formatting:format_speed(speed)}, bg_color = self:get_bg_color(self._cell_color.speed, speed, self._args.speed_operator, self._args.speed_outstanding, self._args.speed_good), text_align = self._center_align}
end
function EquipmentComparisonKai:range(equipment)
local range = equipment:range()
if range ~= false then
self._shown_stats.range = true
else
range = 0
end
return {values = {value = Formatting:format_range(range)}, bg_color = self:get_bg_color(self._cell_color.range, range, self._args.range_operator, self._args.range_outstanding, self._args.range_good), text_align = self._center_align}
end
function EquipmentComparisonKai:notes(equipment)
local note = self._notes[equipment]
if note then
local bg_color
if note.highlight == "outstanding" then
bg_color = self._outstanding_stat_color
elseif note.highlight == "good" then
bg_color = self._good_stat_color
else
bg_color = self._transparent
end
return {values = {value = note.note or ""}, bg_color = bg_color}
end
return {values = {value = ""}, bg_color = self._transparent}
end
function EquipmentComparisonKai:create_table_prep()
self._shown_stats = {}
end
EquipmentComparisonKai.create_data_rows = EquipmentComparisonKai.create_data_rows_merge_vertical
function EquipmentComparisonKai:create_header()
local stat_columns = {}
for _, column in ipairs(self._stat_columns) do
if self._shown_stats[column] then
table.insert(stat_columns, format{self._column_header_cell_template, value = Formatting:format_image{StatIcons[column], caption = Formatting:format_stat_name(column)}})
else
for _, row_values in ipairs(self._data_rows) do
row_values[column] = nil
end
end
end
self._header = format{self._header_template, stat_columns = table.concat(stat_columns, "\n")}
end
return EquipmentComparisonKai