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

Difference between revisions of "Module:ShipDropTable"

From Kancolle Wiki
Jump to navigation Jump to search
m
 
(40 intermediate revisions by 6 users not shown)
Line 1: Line 1:
local p = {}
+
local U = require("Module:Core")
 +
local Ship = require("Module:Ship")
 +
local Formatting = require("Module:Formatting")
 +
local dropData = require("Module:Data/ShipDrop")
  
-- This disgusting module for shipdrops made by
+
local worlds = {
-- Remi_Scarlet
+
  {world = 1, maps = 6},
-- Please at least give some mention of credit if you want to modify/reuse/whatever. I don't actually care but it'd be nice of you.
+
  {world = 2, maps = 5},
-- I fucking hate lua.
+
  {world = 3, maps = 5},
 +
  {world = 7, maps = 5},
 +
  {world = 4, maps = 5},
 +
  {world = 5, maps = 5},
 +
  {world = 6, maps = 5},
 +
}
  
function p.formatShipDropTable(tableInfo)
+
local function formatShip(shipName)
    local order = {"1","2","3","4","5","6"}
+
  local ship = Ship(shipName)
    local worldOrder = {"World1", "World2", "World3", "World4", "World5", "World6"}
+
  local shipDropData = dropData[shipName] or {}
    local html = ""
+
  local result = {
     html = html .. "<tr><td>[[" .. tableInfo["ShipName"] .. "]]</td>"
+
     string.format(
    local style = {["1"] = 'background-color:#8ac',
+
      [=[<tr><td>[[%s]]</td><td%s>%s</td><td>[[%s]]</td><td>%s</td>]=],
                    ["2"] = 'background-color:#ace',
+
      shipName,
                    ["3"] = 'background-color:#0ff',
+
      ship:back() and string.format(' style="background-color:%s;color:black"', Formatting:format_ship_back(ship:back())) or "",
                    ["4"] = 'background-color:#bbb',
+
      Formatting:format_ship_rarity(ship:back()),
                    ["5"] = 'background-color:#fc0',
+
      Formatting:format_ship_code(ship:type()),
                    ["6"] = 'background-color:#ffaaff',
+
      U.pad(ship:id() or "???", 3, "0")
                    ["7"] = 'background-color:#ff55ff',
+
    )
                    ["8"] = 'background-color:#aa00aa; color:#fff'}
+
  }
    local rarity = tableInfo["Rarity"]
+
  for _, e in ipairs(worlds) do
     html = html .. "<td style=\"" .. style[rarity] .. ";\">" .. rarity .. "</td>"
+
     for map = 1, e.maps do
    html = html .. "<td>" .. tableInfo["No."] .. "</td>"
+
      local drop = shipDropData[string.format("%d-%d", e.world, map)]
    for i,world in pairs(worldOrder) do
+
      table.insert(result, string.format("<td%s>%s</td>", drop and ' style="background-color:#c8e6c9"' or "", drop and Formatting:tooltip2("✔️", drop, "; ") or ""))
        html = html .. "<td style='borders:none;background-color: #dddcb1'></td>"
+
    end
        for ii,map in pairs(order) do
+
  end
            local val = tableInfo[world][map]
+
  local remark =
            if val ~= nil then
+
     ship:buildable() and (ship:buildable_lsc() and "Buildable" or "Buildable (no LSC)") or (ship:buildable_lsc() and "LSC only" or "Unbuildable")
                html = html .. "<td style=\"" .. val["style"] .. "\">" .. val["drop"] .. "</td>"
+
  table.insert(result, string.format("<td>%s</td></tr>", remark))
            end
+
  return table.concat(result)
        end
 
    end
 
     html = html .. "<td style='borders:none;background-color: #dddcb1'></td>"
 
    html = html .. "<td>" .. tableInfo["Remarks"] .. "</td>"
 
    html = html .. "</tr>"
 
    return html
 
 
end
 
end
  
function p.returnShipDrop(frame)
+
local function render(frame)
    local dropList = {}
+
  local args = frame.args
    dropList["Nagato"] = {
 
        ["ShipName"] = "Nagato",
 
        ["Rarity"] = "7",
 
        ["No."] = "001",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Mutsu"] = {
 
        ["ShipName"] = "Mutsu",
 
        ["Rarity"] = "7",
 
        ["No."] = "002",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "O", ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Ise"] = {
 
        ["ShipName"] = "Ise",
 
        ["Rarity"] = "5",
 
        ["No."] = "003",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "O",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Hyuuga"] = {
 
        ["ShipName"] = "Hyuuga",
 
        ["Rarity"] = "5",
 
        ["No."] = "004",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "O",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Yukikaze"] = {
 
        ["ShipName"] = "Yukikaze",
 
        ["Rarity"] = "6",
 
        ["No."] = "005",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Akagi"] = {
 
        ["ShipName"] = "Akagi",
 
        ["Rarity"] = "6",
 
        ["No."] = "006",
 
        ["Remarks"] = "''Quest ''",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Kaga"] = {
 
        ["ShipName"] = "Kaga",
 
        ["Rarity"] = "5",
 
        ["No."] = "007",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "X", ["style"] = ""},
 
        },
 
        ["World3"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["4"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World4"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "O", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "O",  ["style"] = ""},
 
        },
 
        ["World5"] = {
 
            ["1"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["2"] = {  ["drop"] = "X", ["style"] = "background-color: #7df83a; "},
 
            ["3"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["5"] = {  ["drop"] = "",  ["style"] = ""},
 
        },
 
        ["World6"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "",  ["style"] = ""},
 
        }
 
    }
 
    dropList["Souryuu"] = {
 
        ["ShipName"] = "Souryuu",
 
        ["Rarity"] = "5",
 
        ["No."] = "008",
 
        ["Remarks"] = "",
 
        ["World1"] = {
 
            ["1"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["2"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["3"] = {  ["drop"] = "",  ["style"] = ""},
 
            ["4"] = {  ["drop"] = "X", ["style"] = "background-color: #ecea4c; "},
 
            ["5"] = {  ["drop"] = "O", ["style"] = ""},
 
            ["6"] = {  ["drop"] = "",  ["style"] = ""}
 
        },
 
        ["World2"] = {
 
            ["1"] = {  ["drop"] = "O", ["style"] = "background-color: #ecea4c; "},
 
            ["2"] = {  ["drop"] = "
 
 
     end
 
     end
     html = html .. "</table>"
+
  end
    return html
+
  table.insert(result, "</tr>")
 +
  for _, shipName in ipairs(args[1] == "all" and U.sort(U.keys(dropData)) or args) do
 +
     table.insert(result, formatShip(shipName))
 +
  end
 +
  table.insert(result, [[</table></div>]])
 +
  return table.concat(result)
 
end
 
end
  
return p
+
return { returnShipDrop = render }

Latest revision as of 11:15, 23 January 2023

Documentation for this module may be created at Module:ShipDropTable/doc

local U = require("Module:Core")
local Ship = require("Module:Ship")
local Formatting = require("Module:Formatting")
local dropData = require("Module:Data/ShipDrop")

local worlds = {
  {world = 1, maps = 6},
  {world = 2, maps = 5},
  {world = 3, maps = 5},
  {world = 7, maps = 5},
  {world = 4, maps = 5},
  {world = 5, maps = 5},
  {world = 6, maps = 5},
}

local function formatShip(shipName)
  local ship = Ship(shipName)
  local shipDropData = dropData[shipName] or {}
  local result = {
    string.format(
      [=[<tr><td>[[%s]]</td><td%s>%s</td><td>[[%s]]</td><td>%s</td>]=],
      shipName,
      ship:back() and string.format(' style="background-color:%s;color:black"', Formatting:format_ship_back(ship:back())) or "",
      Formatting:format_ship_rarity(ship:back()),
      Formatting:format_ship_code(ship:type()),
      U.pad(ship:id() or "???", 3, "0")
    )
  }
  for _, e in ipairs(worlds) do
    for map = 1, e.maps do
      local drop = shipDropData[string.format("%d-%d", e.world, map)]
      table.insert(result, string.format("<td%s>%s</td>", drop and ' style="background-color:#c8e6c9"' or "", drop and Formatting:tooltip2("✔️", drop, "; ") or ""))
    end
  end
  local remark =
    ship:buildable() and (ship:buildable_lsc() and "Buildable" or "Buildable (no LSC)") or (ship:buildable_lsc() and "LSC only" or "Unbuildable")
  table.insert(result, string.format("<td>%s</td></tr>", remark))
  return table.concat(result)
end

local function render(frame)
  local args = frame.args
  local result = {[[<div style="overflow-x:auto"><table class="wikitable sortable" style="text-align:center;width:100%">]]}
  table.insert(result, "<tr>")
  for _, cell in ipairs({"Ship", "Rarity", "Type", "No."}) do
    table.insert(result, string.format([[<th rowspan="2">%s</th>]], cell))
  end
  for _, e in ipairs(worlds) do
    table.insert(result, string.format([=[<th colspan="%s">[[World %s]]</th>]=], e.maps, e.world))
  end
  table.insert(result, [[<th rowspan="2">Remarks</th></tr><tr>]])
  for _, e in ipairs(worlds) do
    for map = 1, e.maps do
      table.insert(result, string.format([=[<th>[[%s-%s|%s]]</th>]=], e.world, map, map))
    end
  end
  table.insert(result, "</tr>")
  for _, shipName in ipairs(args[1] == "all" and U.sort(U.keys(dropData)) or args) do
    table.insert(result, formatShip(shipName))
  end
  table.insert(result, [[</table></div>]])
  return table.concat(result)
end

return { returnShipDrop = render }