Changes

m
no edit summary
Line 4: Line 4:  
local Ship = require('Module:Ship')
 
local Ship = require('Module:Ship')
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
 +
local SortId = require('Module:DropList/Sort')
    
-- * Rarity definitions.
 
-- * Rarity definitions.
-- sync with http://kancolle.wikia.com/wiki/Template:DropList/doc
      
local rare_ships = {
 
local rare_ships = {
Line 37: Line 37:  
 
 
'Honolulu', 'Suzunami', 'Souya',
 
'Honolulu', 'Suzunami', 'Souya',
 +
 +
'Chougei', 'Conte di Cavour', 'Victorious', 'Kaiboukan No.30',
 +
 +
'Shounan', 'Scamp',
 +
 +
'Yawata Maru',
 +
 +
'Ume', 'Yamashio Maru', 'Fuyutsuki', 'Tamanami',
 +
 +
'Hayashio', 'I-201', 'Maryland', 'Kurahashi',
 +
 +
'Ukuru', 'Natsugumo', 'Langley', 'Brooklyn', 'Massachusetts', 'Ranger', 'Jean Bart',
 +
 +
'Yuugure', 'Heywood L. Edwards', 'Kumano Maru', 'Noumi', 'Tuscaloosa', 'No.101 Transport Ship',
 +
 +
'Kaiboukan No.22', 'Inagi', 'Shirakumo', 'Salmon', 'Asahi', 'C.Cappellini', 'Javelin', 'Nevada', 'Rodney',
 +
 +
'Drum', 'I-41', 'I-36', 'Heian Maru',
 
}
 
}
   Line 66: Line 84:  
['Hard']    = 'Hard+',
 
['Hard']    = 'Hard+',
 
['?']      = '?',
 
['?']      = '?',
['Regular'] = '',
+
['Regular'] = '✔️',
 
}
 
}
   Line 82: Line 100:  
local table_format = {
 
local table_format = {
 
-- header          = '{| class="article-table sortable center ${classes}" width="100%" style="text-align:center; line-height:15px;"\n!Type\n!<span style="border-bottom:1px dotted;">Ship<sup>[[Template:DropList/doc|?]]</sup></span>\n',
 
-- header          = '{| class="article-table sortable center ${classes}" width="100%" style="text-align:center; line-height:15px;"\n!Type\n!<span style="border-bottom:1px dotted;">Ship<sup>[[Template:DropList/doc|?]]</sup></span>\n',
     header          = '{| class="wikitable mw-collapsible mw-collapsed" width="50%" style="text-align:center"\n!colspan="100"|Ship drops\n|-\n!Type\n!Ship',
+
     header          = '{|class="wikitable mw-collapsible mw-collapsed" width="50%" style="text-align:center"\n!colspan="100"|Ship drops\n|-\n!Type\n!Ship<sup>[[Module:DropList|?]]</sup>\n',
 
header_node      = '!${node}\n',
 
header_node      = '!${node}\n',
header_boss_node = '!style="background-color:#FFCDD2;color:red;"|\'\'\'${node}\'\'\'\n',
+
header_boss_node = '!style="background-color:#FFCDD2;color:red"|\'\'\'${node}\'\'\'\n',
 
row              = '|-\n', -- class="toggle-target-droplist-non-rare-ship" style="display:none;"
 
row              = '|-\n', -- class="toggle-target-droplist-non-rare-ship" style="display:none;"
 
rare_row        = '|-\n',
 
rare_row        = '|-\n',
 
type_cell        = '|${type}\n',
 
type_cell        = '|${type}\n',
 
-- TODO: japanese tooltips
 
-- TODO: japanese tooltips
ship_cell        = '|[[${ship}|<span style="color:${color};">${ship}</span>]]\n',
+
ship_cell        = '|[[${ship}|<span style="color:${color}">${ship}</span>]]\n',
 
none_cell        = '|None\n',
 
none_cell        = '|None\n',
node_cell        = '|style="background-color:#${background_color};color:${color}"|${diff}\n',
+
node_cell        = '|style="background-color:#${background_color}${color}"|${diff}\n',
 
empty_cell      = '|\n',
 
empty_cell      = '|\n',
 
footer          = '|}\n',
 
footer          = '|}\n',
debugger        = [[{| style="width:100%;" align="center" cellspacing="0" class="article-table mw-collapsible mw-collapsed"
+
debugger        = [[{|style="width:100%" align="center" cellspacing="0" class="article-table mw-collapsible mw-collapsed"
 
!Notes
 
!Notes
 
|-
 
|-
Line 193: Line 211:  
ship = ship,
 
ship = ship,
 
rare = rare,
 
rare = rare,
 +
ignored = ignored,
 
regular = regular,
 
regular = regular,
 
ship_color = rarity_colors[ignored][rare],
 
ship_color = rarity_colors[ignored][rare],
 
type = Formatting:format_ship_code(ship_table._type) or '?',
 
type = Formatting:format_ship_code(ship_table._type) or '?',
 +
type_id = ship_table._type or 0,
 +
sort_id = SortId[ship_table._api_id] or 0,
 
nodes = {},
 
nodes = {},
 
})
 
})
Line 276: Line 297:  
table_format.node_cell,
 
table_format.node_cell,
 
background_color = node.color,
 
background_color = node.color,
color = node.s_only and 'red' or '',
+
color = node.s_only and ';color:red' or '',
 
diff = node.tooltip and Formatting:tooltip2(node.diff, node.tooltip:gsub("@", " / @@"), " / ", "@") or node.diff
 
diff = node.tooltip and Formatting:tooltip2(node.diff, node.tooltip:gsub("@", " / @@"), " / ", "@") or node.diff
 
} or table_format.empty_cell)
 
} or table_format.empty_cell)
Line 289: Line 310:  
})
 
})
 
end
 
end
 +
 +
    -- true when the first is less than the second (so that not comp(a[i+1],a[i]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead.
 +
 +
table.sort(tbl.rows, function(a, b)
 +
if a.type_id < b.type_id then
 +
return true
 +
elseif a.type_id == b.type_id then
 +
return a.sort_id < b.sort_id
 +
else
 +
return false
 +
end
 +
end)
   −
-- rows
   
for _, row in pairs(tbl.rows) do
 
for _, row in pairs(tbl.rows) do
-- TODO: Sort by type/name
   
if row.rare then
 
if row.rare then
 
add_row(row)
 
add_row(row)
Line 298: Line 329:  
end
 
end
 
for key, row in pairs(tbl.rows) do
 
for key, row in pairs(tbl.rows) do
-- TODO: Sort by type/name
+
if not row.rare and not row.ignored then
if not row.rare then
+
add_row(row)
 +
end
 +
end
 +
for key, row in pairs(tbl.rows) do
 +
if row.ignored then
 
add_row(row)
 
add_row(row)
 
end
 
end
34,834

edits