• 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:EliteShipsKai"

From Kancolle Wiki
Jump to navigation Jump to search
com>Ckwng
m (concat with spaces)
com>Ckwng
Line 1: Line 1:
 +
local BaseTable = require('Module:BaseTable')
 +
local Formatting = require('Module:Formatting')
 +
local MiscIcons = require('Module:MiscIcons')
 
local ResourceIcons = require('Module:ResourceIcons')
 
local ResourceIcons = require('Module:ResourceIcons')
 +
local Ship = require('Module:Ship')
 
local StatIcons = require('Module:StatIcons')
 
local StatIcons = require('Module:StatIcons')
local MiscIcons = require('Module:MiscIcons')
+
 
local BaseData = require('Module:BaseData')
 
local Ship = require('Module:Ship')
 
local Formatting = require('Module:Formatting')
 
 
local format = require('Module:StringInterpolation').format
 
local format = require('Module:StringInterpolation').format
  
local EliteShipsKai = BaseData({
+
local EliteShipsKai = BaseTable({
_table_start = [[{| class="wikitable"]],
 
_row_starter = "|-",
 
 
_header_template = [[!No.
 
_header_template = [[!No.
 
!Name
 
!Name
Line 52: Line 51:
 
"notes",
 
"notes",
 
},
 
},
_cell_color = {
 
},
 
_good_stat_color = "#ffff40",
 
_outstanding_stat_color = "#73ff4d",
 
_cell = [[| colspan="1" rowspan="${rowspan}" style="text-align:center; background-color: ${bg_color};" |${values.value}]],
 
_table_end = [[|}]],
 
_rowspan_suffix = "_rowspan",
 
_bg_color_suffix = "_bg_color",
 
_outstanding_suffix = "_outstanding",
 
_good_suffix = "_good",
 
_operator_suffix = "_operator",
 
_notes_suffix = "_notes",
 
_highlight_suffix = "_highlight",
 
_transparent = "transparent",
 
 
_no_remodel_level = "-",
 
_no_remodel_level = "-",
_emphasis_template = "'''${value}'''",
+
_item_class = Ship,
_operators = {
 
["<"] = function(x,y) return x < y end,
 
[">"] = function(x,y) return x > y end,
 
}
 
 
})
 
})
 
function EliteShipsKai:get_bg_color(default, value, operator, outstanding, good)
 
if not value then
 
return default or self._transparent
 
end
 
local comparison = self._operators[operator or ">"]
 
if outstanding and comparison(value, tonumber(outstanding)) then
 
return self._outstanding_stat_color
 
elseif good and comparison(value, tonumber(good)) then
 
return self._good_stat_color
 
else
 
return default or self._transparent
 
end
 
end
 
 
function EliteShipsKai:get_emphasis(value, formatted, operator, good)
 
local comparison = self._operators[operator or ">"]
 
if value and good and comparison(value, tonumber(good)) then
 
return format{self._emphasis_template, value = formatted}
 
end
 
return formatted
 
end
 
  
 
function EliteShipsKai:name(ship)
 
function EliteShipsKai:name(ship)
Line 114: Line 73:
 
end
 
end
  
function EliteShipsKai:class(ship, args)
+
function EliteShipsKai:class(ship)
 
local class = ship:class()
 
local class = ship:class()
 
local ship_type = ship:type()
 
local ship_type = ship:type()
 
local value = class:base_name()
 
local value = class:base_name()
local reference_type = args.reference_type
+
local reference_type = self._args.reference_type
 
local show_type
 
local show_type
 
if reference_type then
 
if reference_type then
Line 131: Line 90:
 
end
 
end
  
function EliteShipsKai:remodel(ship, args)
+
function EliteShipsKai:remodel(ship)
 
local remodel_level = ship:remodel_level()
 
local remodel_level = ship:remodel_level()
return {values = {value = Formatting:format_stat(remodel_level == false and self._no_remodel_level or remodel_level)}, bg_color = self:get_bg_color(self._cell_color.remodel, remodel_level, args.remodel_level_operator, args.remodel_level_outstanding, args.remodel_level_good)}
+
return {values = {value = Formatting:format_stat(remodel_level == false and self._no_remodel_level or remodel_level)}, bg_color = self:get_bg_color(self._cell_color.remodel, remodel_level, self._args.remodel_level_operator, self._args.remodel_level_outstanding, self._args.remodel_level_good)}
 
end
 
end
  
function EliteShipsKai:firepower(ship, args)
+
function EliteShipsKai:firepower(ship)
 
local firepower_max = ship:firepower_max()
 
local firepower_max = ship:firepower_max()
 
if firepower_max == false then
 
if firepower_max == false then
 
firepower_max = ship:firepower()
 
firepower_max = ship:firepower()
 
end
 
end
return {values = {value = Formatting:format_stat(firepower_max)}, bg_color = self:get_bg_color(self._cell_color.firepower, firepower_max, args.firepower_operator, args.firepower_outstanding, args.firepower_good)}
+
return {values = {value = Formatting:format_stat(firepower_max)}, bg_color = self:get_bg_color(self._cell_color.firepower, firepower_max, self._args.firepower_operator, self._args.firepower_outstanding, self._args.firepower_good)}
 
end
 
end
  
function EliteShipsKai:torpedo(ship, args)
+
function EliteShipsKai:torpedo(ship)
 
local torpedo_max = ship:torpedo_max()
 
local torpedo_max = ship:torpedo_max()
 
if torpedo_max == false then
 
if torpedo_max == false then
 
torpedo_max = ship:torpedo()
 
torpedo_max = ship:torpedo()
 
end
 
end
return {values = {value = Formatting:format_stat(torpedo_max)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo_max, args.torpedo_operator, args.torpedo_outstanding, args.torpedo_good)}
+
return {values = {value = Formatting:format_stat(torpedo_max)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo_max, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good)}
 
end
 
end
  
function EliteShipsKai:aa(ship, args)
+
function EliteShipsKai:aa(ship)
 
local aa_max = ship:aa_max()
 
local aa_max = ship:aa_max()
 
if aa_max == false then
 
if aa_max == false then
 
aa_max = ship:aa()
 
aa_max = ship:aa()
 
end
 
end
return {values = {value = Formatting:format_stat(aa_max)}, bg_color = self:get_bg_color(self._cell_color.aa, aa_max, args.aa_operator, args.aa_outstanding, args.aa_good)}
+
return {values = {value = Formatting:format_stat(aa_max)}, bg_color = self:get_bg_color(self._cell_color.aa, aa_max, self._args.aa_operator, self._args.aa_outstanding, self._args.aa_good)}
 
end
 
end
  
function EliteShipsKai:asw(ship, args)
+
function EliteShipsKai:asw(ship)
 
local asw_max = ship:asw_max()
 
local asw_max = ship:asw_max()
 
if asw_max == false then
 
if asw_max == false then
 
asw_max = ship:asw()
 
asw_max = ship:asw()
 
end
 
end
return {values = {value = Formatting:format_stat(asw_max)}, bg_color = self:get_bg_color(self._cell_color.asw, asw_max, args.asw_operator, args.asw_outstanding, args.asw_good)}
+
return {values = {value = Formatting:format_stat(asw_max)}, bg_color = self:get_bg_color(self._cell_color.asw, asw_max, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good)}
 
end
 
end
  
function EliteShipsKai:los(ship, args)
+
function EliteShipsKai:los(ship)
 
local los_max = ship:los_max()
 
local los_max = ship:los_max()
 
if los_max == false then
 
if los_max == false then
 
los_max = ship:los()
 
los_max = ship:los()
 
end
 
end
return {values = {value = Formatting:format_stat(los_max)}, bg_color = self:get_bg_color(self._cell_color.los, los_max, args.los_operator, args.los_outstanding, args.los_good)}
+
return {values = {value = Formatting:format_stat(los_max)}, bg_color = self:get_bg_color(self._cell_color.los, los_max, self._args.los_operator, self._args.los_outstanding, self._args.los_good)}
 
end
 
end
  
function EliteShipsKai:luck(ship, args)
+
function EliteShipsKai:luck(ship)
 
local luck = ship:luck()
 
local luck = ship:luck()
 
local luck_max = ship:luck_max()
 
local luck_max = ship:luck_max()
return {values = {luck = Formatting:format_stat(luck), luck_max = self:get_emphasis(luck_max, Formatting:format_stat(luck_max), args.luck_max_operator, args.luck_max_good)}, bg_color = self:get_bg_color(self._cell_color.luck, luck, args.luck_operator, args.luck_outstanding, args.luck_good)}
+
return {values = {luck = Formatting:format_stat(luck), luck_max = self:get_emphasis(luck_max, Formatting:format_stat(luck_max), self._args.luck_max_operator, self._args.luck_max_good)}, bg_color = self:get_bg_color(self._cell_color.luck, luck, self._args.luck_operator, self._args.luck_outstanding, self._args.luck_good)}
 
end
 
end
  
function EliteShipsKai:hp(ship, args)
+
function EliteShipsKai:hp(ship)
 
local hp = ship:hp()
 
local hp = ship:hp()
return {values = {value = Formatting:format_stat(hp)}, bg_color = self:get_bg_color(self._cell_color.hp, hp, args.hp_operator, args.hp_outstanding, args.hp_good)}
+
return {values = {value = Formatting:format_stat(hp)}, bg_color = self:get_bg_color(self._cell_color.hp, hp, self._args.hp_operator, self._args.hp_outstanding, self._args.hp_good)}
 
end
 
end
  
function EliteShipsKai:armor(ship, args)
+
function EliteShipsKai:armor(ship)
 
local armor_max = ship:armor_max()
 
local armor_max = ship:armor_max()
 
if armor_max == false then
 
if armor_max == false then
 
armor_max = ship:armor()
 
armor_max = ship:armor()
 
end
 
end
return {values = {value = Formatting:format_stat(armor_max)}, bg_color = self:get_bg_color(self._cell_color.armor, armor_max, args.armor_operator, args.armor_outstanding, args.armor_good)}
+
return {values = {value = Formatting:format_stat(armor_max)}, bg_color = self:get_bg_color(self._cell_color.armor, armor_max, self._args.armor_operator, self._args.armor_outstanding, self._args.armor_good)}
 
end
 
end
  
function EliteShipsKai:evasion(ship, args)
+
function EliteShipsKai:evasion(ship)
 
local evasion_max = ship:evasion_max()
 
local evasion_max = ship:evasion_max()
 
if evasion_max == false then
 
if evasion_max == false then
 
evasion_max = ship:evasion()
 
evasion_max = ship:evasion()
 
end
 
end
return {values = {value = Formatting:format_stat(evasion_max)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion_max, args.evasion_operator, args.evasion_outstanding, args.evasion_good)}
+
return {values = {value = Formatting:format_stat(evasion_max)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion_max, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good)}
 
end
 
end
  
function EliteShipsKai:speed(ship, args)
+
function EliteShipsKai:speed(ship)
 
local speed = ship:speed()
 
local speed = ship:speed()
return {values = {value = Formatting:format_speed(speed)}, bg_color = self:get_bg_color(self._cell_color.speed, speed, args.speed_operator, args.speed_outstanding, args.speed_good)}
+
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)}
 
end
 
end
  
function EliteShipsKai:aircraft(ship, args)
+
function EliteShipsKai:aircraft(ship)
 
local aircraft = ship:total_space()
 
local aircraft = ship:total_space()
 
local slots = {}
 
local slots = {}
Line 214: Line 173:
 
for i = 1, ship:slots() do
 
for i = 1, ship:slots() do
 
_, size = ship:slot(i)
 
_, size = ship:slot(i)
table.insert(slots, self:get_emphasis(size, Formatting:format_stat(size), args.aircraft_slot_operator, args.aircraft_slot_good))
+
table.insert(slots, self:get_emphasis(size, Formatting:format_stat(size), self._args.aircraft_slot_operator, self._args.aircraft_slot_good))
 
end
 
end
 
end
 
end
return {values = {value = Formatting:format_detailed_aircraft(aircraft, slots)}, bg_color = self:get_bg_color(self._cell_color.aircraft, aircraft, args.aircraft_operator, args.aircraft_outstanding, args.aircraft_good)}
+
return {values = {value = Formatting:format_detailed_aircraft(aircraft, slots)}, bg_color = self:get_bg_color(self._cell_color.aircraft, aircraft, self._args.aircraft_operator, self._args.aircraft_outstanding, self._args.aircraft_good)}
 
end
 
end
  
function EliteShipsKai:fuel(ship, args)
+
function EliteShipsKai:fuel(ship)
 
local fuel = ship:fuel()
 
local fuel = ship:fuel()
return {values = {value = Formatting:format_stat(fuel)}, bg_color = self:get_bg_color(self._cell_color.fuel, fuel, args.fuel_operator, args.fuel_outstanding, args.fuel_good)}
+
return {values = {value = Formatting:format_stat(fuel)}, bg_color = self:get_bg_color(self._cell_color.fuel, fuel, self._args.fuel_operator, self._args.fuel_outstanding, self._args.fuel_good)}
 
end
 
end
  
function EliteShipsKai:ammo(ship, args)
+
function EliteShipsKai:ammo(ship)
 
local ammo = ship:ammo()
 
local ammo = ship:ammo()
return {values = {value = Formatting:format_stat(ammo)}, bg_color = self:get_bg_color(self._cell_color.ammo, ammo, args.ammo_operator, args.ammo_outstanding, args.ammo_good)}
+
return {values = {value = Formatting:format_stat(ammo)}, bg_color = self:get_bg_color(self._cell_color.ammo, ammo, self._args.ammo_operator, self._args.ammo_outstanding, self._args.ammo_good)}
 
end
 
end
  
function EliteShipsKai:notes(ship, args)
+
function EliteShipsKai:notes(ship)
local note = args.notes[ship]
+
local note = self._notes[ship]
 
if note then
 
if note then
 
local bg_color
 
local bg_color
Line 246: Line 205:
 
end
 
end
  
function EliteShipsKai:compare_values(val1, val2)
+
function EliteShipsKai:process_item_key(item_key)
if #val1 == #val2 then
+
local split = mw.ustring.find(item_key, '/')
for value_type, value in pairs(val1) do
+
local ship_base_name, ship_suffix
if value ~= val2[value_type] then
+
if split == nil then
return false
+
ship_base_name = item_key
end
 
end
 
 
else
 
else
return false
+
ship_base_name = mw.ustring.sub(item_key, 1, split - 1)
 +
ship_suffix = mw.ustring.sub(item_key, split + 1, -1)
 
end
 
end
return true
+
return ship_base_name, ship_suffix
 
end
 
end
  
function EliteShipsKai:Table(args)
+
function EliteShipsKai:create_header()
--Process requested ships
 
local ships = {}
 
args.notes = {}
 
for index, ship_name in ipairs(args) do
 
if ship_name == "-" then
 
ships[index] = "break"
 
elseif ship_name == "#" then
 
ships[index] = "header"
 
else
 
local split = mw.ustring.find(ship_name, '/')
 
local ship_base_name, ship_suffix
 
if split == nil then
 
ship_base_name = ship_name
 
else
 
ship_base_name = mw.ustring.sub(ship_name, 1, split - 1)
 
ship_suffix = mw.ustring.sub(ship_name, split + 1, -1)
 
end
 
local ship = Ship:create(ship_base_name, ship_suffix)
 
ships[index] = ship
 
local note = args[ship_name .. self._notes_suffix]
 
if note then
 
note = {note = note}
 
local note_highlight = args[ship_name .. self._notes_suffix .. self._highlight_suffix]
 
if note_highlight then
 
note.highlight = note_highlight
 
end
 
args.notes[ship] = note
 
end
 
end
 
end
 
 
 
 
local header_icons = {
 
local header_icons = {
 
remodel = MiscIcons.remodel,  
 
remodel = MiscIcons.remodel,  
Line 310: Line 237:
 
header_icons[key] = Formatting:format_image{value, caption = Formatting:format_stat_name(key)}
 
header_icons[key] = Formatting:format_image{value, caption = Formatting:format_stat_name(key)}
 
end
 
end
local header = format(self._header_template, header_icons)
+
self._header = format(self._header_template, header_icons)
 
 
local rows = {self._table_start, header}
 
 
 
local data_rows = {}
 
for index, ship in ipairs(ships) do
 
local row_values
 
if type(ship) == "string" then
 
row_values = ship
 
else
 
row_values = {}
 
for _, column in ipairs(self._columns) do
 
row_values[column] = self[column](self, ship, args)
 
end
 
if index > 1 then
 
for _, column in ipairs(self._columns) do
 
for i=index-1,1,-1 do
 
local previous_row = data_rows[i]
 
local previous_row_type = type(previous_row) ~= "string"
 
local previous_cell = previous_row_type and previous_row[column] or false
 
if previous_cell then
 
if self:compare_values(row_values[column].values, previous_cell.values) then
 
previous_cell.rowspan = previous_cell.rowspan + 1
 
row_values[column] = nil
 
else
 
row_values[column].rowspan = 1
 
end
 
break
 
elseif not previous_row_type then
 
row_values[column].rowspan = 1
 
break
 
end
 
end
 
end
 
else
 
for _, column in ipairs(self._columns) do
 
row_values[column].rowspan = 1
 
end
 
end
 
end
 
 
 
table.insert(data_rows, row_values)
 
end
 
 
 
for index, row_values in ipairs(data_rows) do
 
if row_values ~= "break" then
 
table.insert(rows, self._row_starter)
 
if row_values == "header" then
 
table.insert(rows, header)
 
else
 
for _, column in ipairs(self._columns) do
 
if row_values[column] then
 
table.insert(rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
 
end
 
end
 
end
 
end
 
end
 
 
 
table.insert(rows, self._row_starter)
 
table.insert(rows, header)
 
table.insert(rows, self._table_end)
 
return table.concat(rows, "\n")
 
 
end
 
end
  
 
return EliteShipsKai
 
return EliteShipsKai

Revision as of 20:26, 25 March 2015

Documentation for this module may be created at Module:EliteShipsKai/doc

local BaseTable = require('Module:BaseTable')
local Formatting = require('Module:Formatting')
local MiscIcons = require('Module:MiscIcons')
local ResourceIcons = require('Module:ResourceIcons')
local Ship = require('Module:Ship')
local StatIcons = require('Module:StatIcons')

local format = require('Module:StringInterpolation').format

local EliteShipsKai = BaseTable({
	_header_template = [[!No.
!Name
!Class
! style="white-space:nowrap;" | ${remodel}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightcoral;" | ${firepower}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: lightskyblue;" | ${torpedo}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: sandybrown;" | ${aa}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: #9C8FEE;" | ${asw}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: aquamarine;" | ${los}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: palegreen;" | ${luck}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: pink;" | ${hp}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: #F2E279;" | ${armor}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: #72E6E6;" | ${speed}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: silver;" | ${aircraft}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: forestgreen;" | ${fuel}
! style="width: 30px; text-align: center; vertical-align: middle; background-color: darkgoldenrod;" | ${ammo}
! style="text-align:left;" | Notes]],
	_column_cell_templates = {
		luck = [[| colspan="1" rowspan="${rowspan}" style="text-align:center; background-color: ${bg_color};" | ${values.luck}(${values.luck_max})]],
		id = [[| colspan="1" rowspan="${rowspan}" style="text-align:center; background-color: ${bg_color};${extra_style}" |${values.value}]]
	},
	_columns = {
		"id",
		"name",
		"class",
		"remodel",
		"firepower",
		"torpedo",
		"aa",
		"asw",
		"los",
		"luck",
		"hp",
		"armor",
		"evasion",
		"speed",
		"aircraft",
		"fuel",
		"ammo",
		"notes",
	},
	_no_remodel_level = "-",
	_item_class = Ship,
})

function EliteShipsKai:name(ship)
	local link, text, section = ship:link()
	local value = {Formatting:format_link(link, text, section)}
	local japanese_name = ship:japanese_name()
	if japanese_name and (text or link) ~= japanese_name then
		table.insert(value, Formatting:format_stat(ship:japanese_name()))
	end
	return {values = {value = table.concat(value, " ")}, bg_color = self._transparent}
end

function EliteShipsKai:id(ship)
	local back = ship:back()
	return {values = {value = ship:id()}, 
		bg_color = self._transparent, --Formatting:format_ship_back(back), 
		extra_style = "", --Formatting:extra_style_background_image(back and back > 7, back and back > 6) or ""
	}
end

function EliteShipsKai:class(ship)
	local class = ship:class()
	local ship_type = ship:type()
	local value = class:base_name()
	local reference_type = self._args.reference_type
	local show_type
	if reference_type then
		show_type = ship_type ~= tonumber(reference_type)
	else
		show_type = ship_type ~= class:base_type()
	end
	if show_type then
		value = Formatting:format_stat_with_detail(value, Formatting:format_ship_code(ship_type))
	end
	return {values = {value = value}, bg_color = self._transparent}
end

function EliteShipsKai:remodel(ship)
	local remodel_level = ship:remodel_level()
	return {values = {value = Formatting:format_stat(remodel_level == false and self._no_remodel_level or remodel_level)}, bg_color = self:get_bg_color(self._cell_color.remodel, remodel_level, self._args.remodel_level_operator, self._args.remodel_level_outstanding, self._args.remodel_level_good)}
end

function EliteShipsKai:firepower(ship)
	local firepower_max = ship:firepower_max()
	if firepower_max == false then
		firepower_max = ship:firepower()
	end
	return {values = {value = Formatting:format_stat(firepower_max)}, bg_color = self:get_bg_color(self._cell_color.firepower, firepower_max, self._args.firepower_operator, self._args.firepower_outstanding, self._args.firepower_good)}
end

function EliteShipsKai:torpedo(ship)
	local torpedo_max = ship:torpedo_max()
	if torpedo_max == false then
		torpedo_max = ship:torpedo()
	end
	return {values = {value = Formatting:format_stat(torpedo_max)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo_max, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good)}
end

function EliteShipsKai:aa(ship)
	local aa_max = ship:aa_max()
	if aa_max == false then
		aa_max = ship:aa()
	end
	return {values = {value = Formatting:format_stat(aa_max)}, bg_color = self:get_bg_color(self._cell_color.aa, aa_max, self._args.aa_operator, self._args.aa_outstanding, self._args.aa_good)}
end

function EliteShipsKai:asw(ship)
	local asw_max = ship:asw_max()
	if asw_max == false then
		asw_max = ship:asw()
	end
	return {values = {value = Formatting:format_stat(asw_max)}, bg_color = self:get_bg_color(self._cell_color.asw, asw_max, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good)}
end

function EliteShipsKai:los(ship)
	local los_max = ship:los_max()
	if los_max == false then
		los_max = ship:los()
	end
	return {values = {value = Formatting:format_stat(los_max)}, bg_color = self:get_bg_color(self._cell_color.los, los_max, self._args.los_operator, self._args.los_outstanding, self._args.los_good)}
end

function EliteShipsKai:luck(ship)
	local luck = ship:luck()
	local luck_max = ship:luck_max()
	return {values = {luck = Formatting:format_stat(luck), luck_max = self:get_emphasis(luck_max, Formatting:format_stat(luck_max), self._args.luck_max_operator, self._args.luck_max_good)}, bg_color = self:get_bg_color(self._cell_color.luck, luck, self._args.luck_operator, self._args.luck_outstanding, self._args.luck_good)}
end

function EliteShipsKai:hp(ship)
	local hp = ship:hp()
	return {values = {value = Formatting:format_stat(hp)}, bg_color = self:get_bg_color(self._cell_color.hp, hp, self._args.hp_operator, self._args.hp_outstanding, self._args.hp_good)}
end

function EliteShipsKai:armor(ship)
	local armor_max = ship:armor_max()
	if armor_max == false then
		armor_max = ship:armor()
	end
	return {values = {value = Formatting:format_stat(armor_max)}, bg_color = self:get_bg_color(self._cell_color.armor, armor_max, self._args.armor_operator, self._args.armor_outstanding, self._args.armor_good)}
end

function EliteShipsKai:evasion(ship)
	local evasion_max = ship:evasion_max()
	if evasion_max == false then
		evasion_max = ship:evasion()
	end
	return {values = {value = Formatting:format_stat(evasion_max)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion_max, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good)}
end

function EliteShipsKai:speed(ship)
	local speed = ship:speed()
	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)}
end

function EliteShipsKai:aircraft(ship)
	local aircraft = ship:total_space()
	local slots = {}
	if aircraft > 0 then
		for i = 1, ship:slots() do
			_, size = ship:slot(i)
			table.insert(slots, self:get_emphasis(size, Formatting:format_stat(size), self._args.aircraft_slot_operator, self._args.aircraft_slot_good))
		end
	end
	return {values = {value = Formatting:format_detailed_aircraft(aircraft, slots)}, bg_color = self:get_bg_color(self._cell_color.aircraft, aircraft, self._args.aircraft_operator, self._args.aircraft_outstanding, self._args.aircraft_good)}
end

function EliteShipsKai:fuel(ship)
	local fuel = ship:fuel()
	return {values = {value = Formatting:format_stat(fuel)}, bg_color = self:get_bg_color(self._cell_color.fuel, fuel, self._args.fuel_operator, self._args.fuel_outstanding, self._args.fuel_good)}
end

function EliteShipsKai:ammo(ship)
	local ammo = ship:ammo()
	return {values = {value = Formatting:format_stat(ammo)}, bg_color = self:get_bg_color(self._cell_color.ammo, ammo, self._args.ammo_operator, self._args.ammo_outstanding, self._args.ammo_good)}
end

function EliteShipsKai:notes(ship)
	local note = self._notes[ship]
	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 EliteShipsKai:process_item_key(item_key)
	local split = mw.ustring.find(item_key, '/')
	local ship_base_name, ship_suffix
	if split == nil then
		ship_base_name = item_key
	else
		ship_base_name = mw.ustring.sub(item_key, 1, split - 1)
		ship_suffix = mw.ustring.sub(item_key, split + 1, -1)
	end
	return ship_base_name, ship_suffix
end

function EliteShipsKai:create_header()
	local header_icons = {
		remodel = MiscIcons.remodel, 
		firepower = StatIcons.firepower, 
		torpedo = StatIcons.torpedo, 
		aa = StatIcons.aa, 
		asw = StatIcons.asw, 
		los = StatIcons.los, 
		luck = StatIcons.luck, 
		hp = StatIcons.hp, 
		armor = StatIcons.armor,
		evasion = StatIcons.evasion,
		speed = StatIcons.speed,
		aircraft = StatIcons.aircraft,
		fuel = ResourceIcons.fuel,
		ammo = ResourceIcons.ammo,
	}
	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, header_icons)
end

return EliteShipsKai