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

Changes

Jump to navigation Jump to search
Form combining...gattai!
Line 57: Line 57:  
_available_color = "#aaebaa",
 
_available_color = "#aaebaa",
 
_small_icon_size = "24x24px",
 
_small_icon_size = "24x24px",
 +
_combined_names_template = "${text}<small> (${combined_text})</small>",
 
}
 
}
   Line 95: Line 96:  
end
 
end
 
end
 
end
local ships_to_skip = {[true] = true}
+
local combined_ships = {}
 
local indexes_to_delete = {}
 
local indexes_to_delete = {}
 +
local ship_names = {}
 
for index, ship in ipairs(ships) do
 
for index, ship in ipairs(ships) do
if not ships_to_skip[ship] then
+
if ship ~= true then
 
local remodel_from = ship_data[ship]:remodel_from()
 
local remodel_from = ship_data[ship]:remodel_from()
 
if ship_data[remodel_from] then
 
if ship_data[remodel_from] then
Line 108: Line 110:  
end
 
end
 
if identical then
 
if identical then
ships_to_skip[ship] = true
   
table.insert(indexes_to_delete, index)
 
table.insert(indexes_to_delete, index)
 +
-- The text to add when combining with a less remodelled form.
 +
local combined_name
 +
if ship_data[remodel_from]:base_name() == ship_data[ship]:base_name() then
 +
-- The ship has the same base name as the preceding form,
 +
-- so we only need to add the suffix.
 +
combined_name = ship_data[ship]:display_suffix()
 +
else
 +
-- The ship has a different base name as the preceding form,
 +
-- so we need to add the full name.
 +
combined_name = ship_data[ship]:name()
 +
end
 +
-- Find the most basic form
 +
while combined_ships[remodel_from] do
 +
remodel_from = combined_ships[remodel_from]
 +
end
 +
-- Leave a marker that we combined this form with another form
 +
combined_ships[ship] = remodel_from
 +
-- Prevent nil errors
 +
if not ship_names[remodel_from] then
 +
ship_names[remodel_from] = {}
 +
end
 +
-- Add the combine text to a table so it can be displayed with the most basic form later
 +
table.insert(ship_names[remodel_from], combined_name)
 +
if ship_names[ship] then
 +
-- If this form has had other forms combined with it, add those forms' text too
 +
-- This order of operations should keep the combined text readable.
 +
for _, suffix in ipairs(ship_names[ship]) do
 +
table.insert(ship_names[remodel_from], suffix)
 +
end
 +
ship_names[ship] = nil
 +
end
 
end
 
end
 
end
 
end
Line 119: Line 151:  
end
 
end
 
for _, stars in ipairs(item:improvement_brackets(product)) do
 
for _, stars in ipairs(item:improvement_brackets(product)) do
table.insert(result, {item = item, product = product, stars = stars, ships = ships, ship_data = ship_data, availability = availability, resources = item:improvement_resources(false, product, stars), resources_x = item:improvement_resources(true, product, stars)})
+
table.insert(result, {item = item, product = product, stars = stars, ships = ships, ship_data = ship_data, ship_names = ship_names, availability = availability, resources = item:improvement_resources(false, product, stars), resources_x = item:improvement_resources(true, product, stars)})
 
end
 
end
 
end
 
end
Line 234: Line 266:  
for index, ship in ipairs(row_data.ships) do
 
for index, ship in ipairs(row_data.ships) do
 
if ship ~= true then
 
if ship ~= true then
table.insert(ships, Formatting:format_link(row_data.ship_data[ship]:link()))
+
link, text, section = row_data.ship_data[ship]:link()
 +
if row_data.ship_names[ship] then
 +
text = format{self._combined_names_template, text = text or link, combined_text = table.concat(row_data.ship_names[ship], "/")}
 +
end
 +
table.insert(ships, Formatting:format_link(link, text, section))
 
else
 
else
 
table.insert(ships, "Any")
 
table.insert(ships, "Any")
Anonymous user

Navigation menu