- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Module:ListOfSortable
Jump to navigation
Jump to search
Documentation for this module may be created at Module:ListOfSortable/doc
---
-- Automates generation of sortable table by designated class by looking at all ships within Module:Data/Ship
--
-- TODO: Get stats from Module:Data/Ship instead of relying on Module:ELiteShipsKai to retrieve from Module:Data/Ships/<ShipName>
-- TODO: Automate coloring without Module:EliteShipsKai
local U = require('Module:Core')
local template = {
footer = "}}",
header = [[{{EliteShipsKaiSortable]],
item = [=[|%s]=],
}
local function generateTable(shipClass, remodelSuffix, notes, coloring, ...)
local shipClass = shipClass or frame.args[1] or "??"
local success, data = U.loadData("Data/Ship")
if not success then return "No data for ships: " .. shipClass end
local result = { string.format(template.header) }
local suffix = {}
local index = 1
for k, v in pairs(remodelSuffix) do
suffix[index] = v
index = index + 1
end
for k, v in pairs(data) do
if v.type == shipClass and v.remodellv ~= '' then
local name = v.name[3]
local success = 0
for k, v in pairs(remodelSuffix) do
if success == 0 then
name,success = name:gsub("." .. v, "/" .. v)
end
end
if success == 0 then
name,success = name:gsub(".Kai", "/Kai")
end
table.insert(result, string.format(template.item, name))
end
end
for k, v in pairs(notes) do
table.insert(result, v)
end
for k, v in pairs(coloring) do
table.insert(result, v)
end
table.insert(result, template.footer)
return table.concat(result, "\n")
end
local function render(frame)
local shipClass = frame.args[1]
local remodelSuffix = frame.args[2]
local notes = frame.args[3]
local coloring = frame.args[4]
return generateTable(shipClass, remodelSuffix, notes, coloring)
end
local function test()
mw.log(generateTable("Destroyer", {"B Kai", "D Kai", "Mk.II", "Zwei"},
{"|Mikazuki/Kai_notes = Can equip [[Daihatsu Landing Craft|Daihatsu]]",
"|Mutsuki/Kai Ni_notes = 2nd remodel. Can equip [[Daihatsu Landing Craft|Daihatsu]]",
"|Kisaragi/Kai Ni_notes = 2nd remodel. Can equip [[Daihatsu Landing Craft|Daihatsu]]",
"|Satsuki/Kai Ni_notes = 2nd remodel. Can equip [[Daihatsu Landing Craft|Daihatsu]] & [[Special Type 2 Amphibious Landing Craft|Type 2 Landing Craft]]",
"|Fumizuki/Kai Ni_notes = 2nd remodel. Can equip [[Daihatsu Landing Craft|Daihatsu]] & [[Special Type 2 Amphibious Landing Craft|Type 2 Landing Craft]]"},
{"|remodel_level_good = 20",
"|remodel_level_outstanding = 15",
"|remodel_level_operator = <",
"|firepower_good = 56",
"|firepower_outstanding = 61",
"|torpedo_good = 83",
"|torpedo_outstanding = 89",
"|night_battle = true",
"|night_battle_good = 140",
"|night_battle_outstanding = 150",
"|aa_good = 64",
"|aa_outstanding = 74",
"|asw_good = 67",
"|asw_outstanding = 73",
"|los_good = 42",
"|los_outstanding = 49",
"|hp_good = 34",
"|hp_outstanding = 36",
"|armor_good = 50",
"|armor_outstanding = 58",
"|evasion_good = 92",
"|evasion_outstanding = 98",
"|aircraft_good = 1",
"|aircraft_outstanding = 1",
"|aircraft_slot_good = 1",
"|luck_good = 19",
"|luck_outstanding = 30",
"|luck_max_good = 80",
"|fuel_operator=<",
"|ammo_good = 20",
"|ammo_outstanding = 20",
"|ammo_operator = <",
"|reference_type = 2"}))
end
return { render = render, test = test }
-- TEST: p.test()