Module:EquipmentListKai

local BaseData = require('Module:BaseData') local Equipment = require('Module:Equipment') local Formatting = require('Module:Formatting')

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

local EquipmentListKai = BaseData{ _table_start = {| class="wikitable", _row_starter = "|-", _header_template = Notes, _column_header_cell_template = "!${value}", _column_cell_templates = { },	_icons = { firepower = "${stat_icons.firepower}", torpedo = "${stat_icons.torpedo}", bombing = "${stat_icons.bombing}", aa = "${stat_icons.aa}", asw = "${stat_icons.asw}", los = "${stat_icons.los}", armor = "${stat_icons.armor}", accuracy = "${stat_icons.accuracy}", evasion = "${stat_icons.evasion}", range = "${stat_icons.range}", },	_comparison_columns = { "id", "stars", "name", "firepower", "torpedo", "bombing", "aa", "asw", "los", "armor", "accuracy", "evasion", "range", "compatibility", "buildable", "notes", },	_columns = { "id", "stars", "name", "stats", "compatibility", "buildable", "notes", },	_cell_color = { firepower = "#F0C0C0", torpedo = "#C0E4FA", aa = "#F4CAA6", asw = "#C5BEEE", los = "#CCFFEE", luck = "#C9FBC9", hp = "#FFD9DF", armor = "#F2ECC2", evasion = "#EEBEEE", speed = "#B8E6E6", aircraft = "#D9D9D9", fuel = "#94E094", ammo = "palegoldenrod", },	_cell = ${values.value}, _transparent = "transparent", _notes_suffix = "_notes", _stats_column_label = "Stats", _table_end = |}, }

function EquipmentListKai:Table(args) return self{ _args = args, }:create_table end

function EquipmentListKai:id(equipment) return {values = {value = Formatting:format_stat(equipment:id)}, bg_color = self._transparent} end

function EquipmentListKai:stars(equipment) return {values = {value = Formatting:format_stat(equipment:stars)}, bg_color = self._transparent} end

function EquipmentListKai:name(equipment) return {values = {value = Formatting:format_link(equipment:link)}, bg_color = self._transparent} end

function EquipmentListKai:stats(equipment) return {values = {value = Formatting:format_stat("placeholder")}, bg_color = self._transparent} end

function EquipmentListKai:compatibility(equipment) return {values = {value = Formatting:format_stat("placeholder2")}, bg_color = self._transparent} end

function EquipmentListKai:buildable(equipment) return {values = {value = Formatting:format_stat(equipment:buildable)}, bg_color = self._transparent} end

function EquipmentListKai:notes(equipment) return {values = {value = ""}, bg_color = self._transparent} end

function EquipmentListKai:create_table local equipment_list = {} self._notes = {} for index, equipment_name in ipairs(self._args) do		table.insert(equipment_list, Equipment(equipment_name)) local note = self._args[equipment_name .. self._notes_suffix] if note then self._notes[equipment_name] = note end end

local rows = {self._table_start} local header

if self._args.comparison == "true" then --create comparison table else local header = format{self._header_template, stat_columns = format{self._column_header_cell_template, value = self._stats_column_label}} table.insert(rows, header) local data_rows = {}

for _, equipment in ipairs(equipment_list) do			local row_values = {} for _, column in ipairs(self._columns) do				row_values[column] = self[column](self, equipment) row_values[column].rowspan = 1 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 end table.insert(rows, self._row_starter) table.insert(rows, header) table.insert(rows, self._table_end) return table.concat(rows, "\n") end

function EquipmentListKai.test(frame) local args = getArgs{frame = frame} return EquipmentListKai:Table(args) end

return EquipmentListKai