Line 14: |
Line 14: |
| end | | end |
| | | |
− | local headerList = {} | + | local numTypes = {} |
| local validLabels = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} | | local validLabels = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} |
| local shipTypes = {"DD", "CL", "CA", "BB", "CV", "CVL", "AV", "SS", "AUX"} | | local shipTypes = {"DD", "CL", "CA", "BB", "CV", "CVL", "AV", "SS", "AUX"} |
| | | |
− | for i, ship in pairs(shipTypes) do | + | for i, letter in pairs(validLabels) do |
− | headerList[ship] = false | + | numTypes[letter] = 0 |
| end | | end |
| for x, node in pairs(validLabels) do | | for x, node in pairs(validLabels) do |
Line 25: |
Line 25: |
| for y, ship in pairs(shipTypes) do | | for y, ship in pairs(shipTypes) do |
| if drops[node][ship] ~= nil then | | if drops[node][ship] ~= nil then |
− | headerList[ship] = true | + | numTypes[node] = numTypes[node] + 1 |
| end | | end |
| end | | end |
Line 32: |
Line 32: |
| | | |
| local tablehtml = '<table class="mw-collapsible mw-collapsed wikitable" style="width:100%">' | | local tablehtml = '<table class="mw-collapsible mw-collapsed wikitable" style="width:100%">' |
| + | tablehtml = tablehtml .. '<tr><th style="width:50px;">Node</th><th colspan="2">Ship List</th></tr>' |
| | | |
− | -- Creating header --
| + | local classLink = {} |
− | local numCols = 0 | + | classLink["DD"] = '[[EliteDD|Destroyers]]' |
− | for i, ship in pairs(shipTypes) do | + | classLink["CL"] = '[[EliteCL|Light Cruisers]]' |
− | if headerList[ship] == true then
| + | classLink["CA"] = '[[EliteCA|Heavy Cruisers]]' |
− | numCols = numCols + 1
| + | classLink["BB"] = '[[EliteBB|Battleships]]' |
− | end
| + | classLink["CV"] = '[[EliteDD|Aircraft Carriers]]' |
− | end | + | classLink["CVL"] = '[[EliteDD|Light Aircraft Carriers]]' |
| + | classLink["AV"] = '[[EliteAV|Seaplane Tenders]]' |
| + | classLink["SS"] = '[[EliteSS|Submarines]]' |
| + | classLink["AUX"] = '[[Auxiliary Ships]]' |
| | | |
− | local headertext = {} | + | for x, node in pairs(validLabels) do |
− | headertext["DD"] = '[[EliteDD|Destroyers]]'
| + | if numTypes[node] > 0 then |
− | headertext["CL"] = '[[EliteCL|Light Cruisers]]'
| + | tablehtml = tablehtml .. '<tr><td style="text-align:center; font-size:18px; font-weight:bold;" ' |
− | headertext["CA"] = '[[EliteCA|Heavy Cruisers]]'
| + | tablehtml = tablehtml .. 'rowspan="' .. numTypes[node] .. '">' .. node .. '</td>' |
− | headertext["BB"] = '[[EliteBB|Battleships]]'
| |
− | headertext["CV"] = '[[EliteDD|Aircraft Carriers]]'
| |
− | headertext["CVL"] = '[[EliteDD|Light Aircraft Carriers]]'
| |
− | headertext["AV"] = '[[EliteAV|Seaplane Tenders]]'
| |
− | headertext["SS"] = '[[EliteSS|Submarines]]'
| |
− | headertext["AUX"] = '[[Auxiliary Ships]]'
| |
| | | |
− | if numCols == 0 then -- no valid entries
| + | remTypes = numTypes[node] - 1 |
− | tablehtml = tablehtml .. '<tr><th style="width:50px;">Node</th><th>Ship List</th></tr>'
| |
− | else
| |
− | tablehtml = tablehtml .. '<tr><th style="width:50px;" rowspan="2">Node</th><th colspan="' .. numCols .. '">Ship List</th></tr>'
| |
− | tablehtml = tablehtml .. '<tr>'
| |
− | for i, ship in pairs(shipTypes) do
| |
− | if headerList[ship] == true then | |
− | tablehtml = tablehtml .. '<th>' .. headertext[ship] .. '</th>'
| |
− | end
| |
− | end
| |
− | tablehtml = tablehtml .. '</tr>'
| |
− | end
| |
− |
| |
− | for x, node in pairs(validLabels) do
| |
− | if drops[node] ~= nil then
| |
− | tablehtml = tablehtml .. '<tr><td style="text-align:center; font-size:18px; font-weight:bold;">' .. node .. '</td>'
| |
| for y, ship in pairs(shipTypes) do | | for y, ship in pairs(shipTypes) do |
− | if headerList[ship] == true then | + | if drops[node][ship] ~= nil then |
− | tablehtml = tablehtml .. '<td>' | + | tablehtml = tablehtml .. '<td style="text-align:center; width:70px;">' .. classLink[ship] .. '</td>' |
− | if drops[node][ship] ~= nil then | + | tablehtml = tablehtml .. '<td>' .. drops[node][ship] .. '</td>' |
− | tablehtml = tablehtml .. drops[node][ship]
| + | end |
− | end | + | if remTypes > 0 then |
− | tablehtml = tablehtml .. '</td>' | + | tablehtml = tablehtml .. '</tr><tr>' |
| + | remTypes = remTypes - 1 |
| + | else |
| + | tablehtml = tablehtml .. '</tr>' |
| + | break |
| end | | end |
| end | | end |
− | tablehtml = tablehtml .. '</tr>'
| |
| end | | end |
| end | | end |
− |
| + | |
| tablehtml = tablehtml .. '</table>' | | tablehtml = tablehtml .. '</table>' |
| return tablehtml | | return tablehtml |