Line 1: |
Line 1: |
− | local BaseTable = require('Module:BaseTable') | + | local CardList = require('Module:CardList') |
| local Formatting = require('Module:Formatting') | | local Formatting = require('Module:Formatting') |
| local Ship = require('Module:Ship') | | local Ship = require('Module:Ship') |
| local ShipCardKai = require('Module:ShipCardKai') | | local ShipCardKai = require('Module:ShipCardKai') |
| | | |
− | local ShipCardListKai = BaseTable{ | + | local ShipCardListKai = CardList{ |
| _item_class = Ship, | | _item_class = Ship, |
− | _row_starter = "",
| |
− | _header_template = nil,
| |
− | _cell = [[${values.value}]],
| |
− | _columns = {
| |
− | "one",
| |
− | "two",
| |
− | "three",
| |
− | "four",
| |
− | "five",
| |
− | },
| |
| _blank = "Empty ship slot.png", | | _blank = "Empty ship slot.png", |
| _default_size = ShipCardKai._card_size, | | _default_size = ShipCardKai._card_size, |
Line 28: |
Line 18: |
| end | | end |
| return {values = {value = value}, bg_color = self._transparent, text_align = self._center_align} | | return {values = {value = value}, bg_color = self._transparent, text_align = self._center_align} |
− | end
| |
− |
| |
− | function BaseTable:create_table_prep()
| |
− | self._size = self._args.image_size or self._default_size
| |
− | end
| |
− |
| |
− | function ShipCardListKai:one(row)
| |
− | return self:card(row[1])
| |
− | end
| |
− |
| |
− | function ShipCardListKai:two(row)
| |
− | return self:card(row[2])
| |
− | end
| |
− |
| |
− | function ShipCardListKai:three(row)
| |
− | return self:card(row[3])
| |
− | end
| |
− |
| |
− | function ShipCardListKai:four(row)
| |
− | return self:card(row[4])
| |
− | end
| |
− |
| |
− | function ShipCardListKai:five(row)
| |
− | return self:card(row[5])
| |
− | end
| |
− |
| |
− | function ShipCardListKai:start_rows()
| |
− | self._rows = {}
| |
− | end
| |
− |
| |
− | function ShipCardListKai:finish_rows()
| |
− | return
| |
− | end
| |
− |
| |
− | function ShipCardListKai: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 ShipCardListKai:create_items()
| |
− | local count = 0
| |
− | local row = {}
| |
− | for index, item_key in ipairs(self._args) do
| |
− | if mw.ustring.sub(item_key, 1, 1) == "!" then
| |
− | local filled = #row
| |
− | if filled ~= 0 then
| |
− | for i=1, 5 - filled do
| |
− | table.insert(row, false)
| |
− | end
| |
− | table.insert(self._items, row)
| |
− | row = {}
| |
− | for i=1, filled do
| |
− | table.insert(row, false)
| |
− | end
| |
− | end
| |
− | table.insert(self._items, mw.ustring.sub(item_key, 2))
| |
− | else
| |
− | count = count + 1
| |
− | local item
| |
− | if item_key == "-" then
| |
− | item = false
| |
− | else
| |
− | item = self._item_class(self:process_item_key(item_key))
| |
− | end
| |
− | table.insert(row, item)
| |
− | if count % 5 == 0 then
| |
− | table.insert(self._items, row)
| |
− | row = {}
| |
− | end
| |
− | end
| |
− | end
| |
− | if #row > 0 then
| |
− | for i=1, 5 - #row do
| |
− | table.insert(row, false)
| |
− | end
| |
− | table.insert(self._items, row)
| |
− | end
| |
− | end
| |
− |
| |
− | function ShipCardListKai:create_data_rows()
| |
− | for _, item in ipairs(self._items) do
| |
− | local row_values
| |
− | if type(item) == "string" then
| |
− | row_values = item
| |
− | else
| |
− | row_values = {}
| |
− | for _, column in ipairs(self._columns) do
| |
− | row_values[column] = self[column](self, item)
| |
− | row_values[column].rowspan = 1
| |
− | row_values[column].colspan = 1
| |
− | end
| |
− | end
| |
− | table.insert(self._data_rows, row_values)
| |
− | end
| |
| end | | end |
| | | |
| return ShipCardListKai | | return ShipCardListKai |