• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Module:EliteShipsKaiSortable

From Kancolle Wiki
Revision as of 11:15, 30 May 2019 by がか (talk | contribs)
Jump to navigation Jump to search

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

local EliteShipsKai = require('Module:EliteShipsKai')
local Formatting = require('Module:Formatting')

local EliteShipsKaiSortable = EliteShipsKai{
	_table_start = [[{| class="wikitable sortable typography-xl-optout"]],
	_header_template = [[!No.
!Name
!Class
! style="white-space:nowrap;" | ${remodel}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: lightcoral;" | ${firepower}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: lightskyblue;" | ${torpedo}
${night_battle_header_cell}! style="width: 24px; text-align: center; vertical-align: middle; background-color: sandybrown;" | ${aa}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: #9C8FEE;" | ${asw}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: aquamarine;" | ${los}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: palegreen;" | ${luck}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: palegreen;" | ${luck}+
! style="width: 24px; text-align: center; vertical-align: middle; background-color: pink;" | ${hp}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: #F2E279;" | ${armor}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: violet;" | ${evasion}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: #72E6E6;" | ${speed}
${range_header_cell}! style="width: 24px; text-align: center; vertical-align: middle; background-color: silver;" data-sort-type="number" | ${aircraft}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: forestgreen;" | ${fuel}
! style="width: 24px; text-align: center; vertical-align: middle; background-color: darkgoldenrod;" | ${ammo}
! class="toggle-target-eliteshipskai-detail" style="text-align:left;" | Notes]],
	_column_cell_templates = {
		id = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;${extra_style}" |${values.value}]],
		notes = [[| class="${class}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" |<small>${values.value}</small>]],
		["!"] = [[| class="${class}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;${extra_style}" |${values.value}]]
	},
	_base_columns = { --gets copied to self._columns in create_table_prep so we can mutate it. Don't mutate base_columns!
		"id",
		"name",
		"class",
		"remodel",
		"firepower",
		"torpedo", --night_battle is added after this depending on args in create_table_prep. If adding columns please preserve this behaviour.
		"aa",
		"asw",
		"los",
		"luck",
		"luck_max",
		"hp",
		"armor",
		"evasion",
		"speed",
		"aircraft",
		"fuel",
		"ammo",
		"notes",
	},
}
 
function EliteShipsKaiSortable:luck(ship)
	local luck = ship:luck()
	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, self._args.luck_bad), text_align = self._center_align}
end
 
function EliteShipsKaiSortable:luck_max(ship)
	local luck_max = ship:luck_max()
	return {values = {value = self:get_emphasis(luck_max, Formatting:format_stat(luck_max), self._args.luck_max_operator, self._args.luck_max_good)}, bg_color = self._transparent, text_align = self._center_align}
end

EliteShipsKaiSortable.create_data_rows = EliteShipsKaiSortable.create_data_rows_plain

return EliteShipsKaiSortable