• 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
no edit summary
Line 1: Line 1: −
local U = require('Module:Utils')
+
local U = require('Module:Core')
 +
 
 +
local ShipList = {}
 +
 
 +
function ShipList.findID(frame)
 +
    for id, data in pairs(ShipList.KanmusuData) do
 +
        if ShipList.KanmusuData[id].name[3] == frame.args[1] then
 +
        return id
 +
        end
 +
    end
 +
    return "NotInDB"
 +
end
 +
 
 +
function ShipList.getSortedIDList()
 +
    local IDList = {}
 +
    for id, data in pairs(ShipList.KanmusuData) do
 +
        IDList[#IDList + 1] = id
 +
        local x = #IDList
 +
        while x > 1 and IDList[x] < IDList[x - 1] do
 +
            IDList[x - 1], IDList[x] = IDList[x], IDList[x - 1]
 +
            x = x - 1
 +
        end
 +
    end
 +
    return IDList
 +
end
 +
 
 +
function ShipList.TotalAircraft(frame)
 +
    local shipID = frame.args[1]
 +
    -- if tonumber(shipID) == nil then
 +
    --    shipID = ShipList.findID(frame)
 +
    -- end
 +
    local ship = ShipList.KanmusuData[shipID]
 +
    local total = 0
 +
    if ship.aircraft ~= "" then
 +
    for i, planes in pairs(ship.aircraft) do
 +
    if ship.aircraft[i] == nil or ship.aircraft[i] == "" then
 +
    total = total + 0 
 +
else
 +
total = total + ship.aircraft[i]
 +
end
 +
end
 +
end
 +
    return total
 +
end
 +
 
 +
function ShipList.getWikiPage(id)
 +
    --finding name of wiki page of ship
 +
    shipname = ShipList.KanmusuData[id]["name"][3]
 +
    pagename = shipname
 +
    if string.sub(id,1,-2) == "Mist" then  -- fleet of fog check
 +
    if string.sub(id, -1) == '1' then
 +
    pagename = 'Iona_(fog)'
 +
    elseif string.sub(id, -1) == '2' then
 +
    pagename = 'Takao_(fog)'
 +
    elseif string.sub(id, -1) == '3' then
 +
    pagename = 'Haruna_(fog)'
 +
else
 +
pagename = 'Fleet of Fog'
 +
end
 +
else
 +
shipbasename = mw.text.split(shipname, '%s')[1]
 +
--Prinz/Graf/Teste check (for ship names that are 2 or more words)
 +
if mw.text.split(shipname, '%s')[2] ~= nil and not (mw.text.split(shipname, '%s')[2] == "Kai" or
 +
mw.text.split(shipname, '%s')[2] == "A" or mw.text.split(shipname, '%s')[2] == "Zwei" or
 +
mw.text.split(shipname, '%s')[2] == "Drei" or mw.text.split(shipname, '%s')[2] == "Due") then
 +
shipbasename = shipbasename .. ' ' .. mw.text.split(shipname, '%s')[2]
 +
end
 +
pagename = shipbasename
 +
end
 +
return pagename
 +
end
 +
 
 +
ShipList.KanmusuData = mw.loadData('Module:Data/Ship')
 +
 
 +
local shipdb = ShipList
    
local shipmodule = {}
 
local shipmodule = {}
local shipdb = require("Module:ShipDatabase")
+
 
 
shipmodule.data = shipdb.KanmusuData
 
shipmodule.data = shipdb.KanmusuData
   Line 24: Line 98:  
function shipmodule.KanmusuInfo(frame) -- Kanmusu Info Template
 
function shipmodule.KanmusuInfo(frame) -- Kanmusu Info Template
 
     local shipNum = shipmodule.getIDNum(frame)
 
     local shipNum = shipmodule.getIDNum(frame)
   
     local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " doesn't have a database entry")
 
     local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " doesn't have a database entry")
   
   
     local upperTable = shipmodule.makeStatBox(frame)
 
     local upperTable = shipmodule.makeStatBox(frame)
     local DetailTable = shipmodule.EquipmentBox(frame) .. shipmodule.ModernizationBox(frame) .. shipmodule.getArtVoice(frame)  
+
     local DetailTable = shipmodule.EquipmentBox(frame) .. '<table style="width: 100%">' .. shipmodule.ModernizationBox(frame) .. shipmodule.getArtVoice(frame) .. '</table>'
 
   
     local shipInfoBox = '<div style="display: inline-block; vertical-align: top;"><table style="{{border-radius|10px 10px 10px 10px}} border: 1px solid #aaaaaa; min-width: 495px">'
 
     local shipInfoBox = '<div style="display: inline-block; vertical-align: top;"><table style="{{border-radius|10px 10px 10px 10px}} border: 1px solid #aaaaaa; min-width: 495px">'
 
     shipInfoBox = shipInfoBox .. '<tr><td>' .. upperTable .. '</td></tr>'
 
     shipInfoBox = shipInfoBox .. '<tr><td>' .. upperTable .. '</td></tr>'
 
     shipInfoBox = shipInfoBox .. '<tr><td>' .. DetailTable .. '</td></tr></table></div>' .. shipmodule.createCategories(frame)
 
     shipInfoBox = shipInfoBox .. '<tr><td>' .. DetailTable .. '</td></tr></table></div>' .. shipmodule.createCategories(frame)
   
     return shipInfoBox
 
     return shipInfoBox
 
end
 
end
Line 41: Line 111:     
     local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " doesn't have a database entry")
 
     local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " doesn't have a database entry")
-- Top half of infobox
+
 
    -- Cards & Banners
+
local shipName = shipInfo.name[3]
    local cardImgFile = '{{#setmainimage:KanMusu' .. shipNum .. 'Card.png}}'
+
     local CardImg = '<div style="text-align: center; width: 218px; height:300px;">[[File:{{#setmainimage:Ship Card ' .. shipName .. '.png}}|218x300px|' .. shipName .. ' Card]]</div>'
     local CardImg = '<div style="text-align: center; width: 218px; height:300px;">[[File:' .. cardImgFile .. '|218x300px|' .. shipmodule.data[shipNum]["name"][3] .. ' Card]]</div>'
+
     local CardDmgImg = '<div style="text-align: center; width: 218px; height:300px;">[[File:Ship Card ' .. shipName .. ' Damaged.png|218x300px|' .. shipName .. ' Damaged Card]]</div>'
     local CardDmgImg = '<div style="text-align: center; width: 218px; height:300px;">[[File:KanMusu' .. shipNum .. 'CardDmg.png|218x300px|' .. shipmodule.data[shipNum]["name"][3] .. ' Damaged Card]]</div>'
+
     local BannerImg = '<div style="text-align: center; width: 160px; height:40px;">[[File:Ship Banner ' .. shipName .. '.png|160px|' .. shipName .. ' Banner|class=imageCenter]]</div>'
     local BannerImg = '<div style="text-align: center; width: 160px; height:40px;">[[File:KanMusu' .. shipNum .. 'Banner.png|160px|' .. shipmodule.data[shipNum]["name"][3] .. ' Banner|class=imageCenter]]</div>'
+
     local BannerDmgImg = '<div style="text-align: center; width: 160px; height:40px;">[[File:Ship Banner ' .. shipName .. ' Damaged.png|160px|' .. shipName .. ' Damaged Banner|class=imageCenter]]</div>'
     local BannerDmgImg = '<div style="text-align: center; width: 160px; height:40px;">[[File:KanMusu' .. shipNum .. 'BannerDmg.png|160px|' .. shipmodule.data[shipNum]["name"][3] .. ' Damaged Banner|class=imageCenter]]</div>'
      
     local Cards = '<td rowspan="10" style="text-align: center; width: 218px; height:300px;">' .. frame:extensionTag('slideshow', CardImg .. CardDmgImg, {
 
     local Cards = '<td rowspan="10" style="text-align: center; width: 218px; height:300px;">' .. frame:extensionTag('slideshow', CardImg .. CardDmgImg, {
Line 56: Line 125:  
     }) .. '</td>'
 
     }) .. '</td>'
   −
     local row1 = '<tr>' .. Cards .. '<th style="text-align: center;">' .. shipNum .. '</th>' .. Banners .. '</tr>'
+
    local sortNo = shipInfo.sortno or U.split(shipNum, '-')[1] or '?'
 +
     local row1 = '<tr>' .. Cards .. '<th style="text-align: center;">' .. sortNo .. '</th>' .. Banners .. '</tr>'
    
     -- Formatting Japanese
 
     -- Formatting Japanese
Line 202: Line 272:  
     end
 
     end
   −
local numRows = U.isize(shipmodule.data[shipNum]["equip"])
+
local numRows = math.max(4, U.isize(shipmodule.data[shipNum]["equip"]))
 
     local equipTable = ''
 
     local equipTable = ''
 
     for i = 1, numRows, 1 do
 
     for i = 1, numRows, 1 do
Line 277: Line 347:     
     local remodelinfo = ''
 
     local remodelinfo = ''
     if shipInfo["remodelreq"] ~= "" then
+
     if shipInfo.remodelreq and shipInfo.remodelreq ~= '' then
         local steel = '[[File:IcoSteel.png|18px|Steel]] ' .. shipInfo["remodelreq"][1]
+
         remodelinfo = string.format('[[File:IcoSteel.png|18px|Steel]] %d [[File:IcoAmmo.png|18px|Ammo]] %d', shipInfo.remodelreq[1], shipInfo.remodelreq[2])
        local ammo = '[[File:IcoAmmo.png|18px|Ammo]] ' .. shipInfo["remodelreq"][2]
+
         if shipInfo.remodelbp then
         remodelinfo = steel .. ' ' .. ammo
+
          remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon Remodel Blueprint.png|25px|Blueprint|link=Blueprints]] %d', shipInfo.remodelbp)
        local items = shipmodule.RemodelBlueprintChk(shipInfo["remodelreq"][3], shipNum)
  −
        if items then
  −
            remodelinfo = remodelinfo .. ' ' .. items
   
         end
 
         end
         if shipInfo.remodeldevmat or shipInfo.remodelconmat then
+
        if shipInfo.remodelcatapult then
 +
          remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon Prototype Flight Deck Catapult.png|25px|Prototype Flight Deck Catapult]] %d', shipInfo.remodelcatapult)
 +
        end
 +
        if shipInfo.remodelar then
 +
          remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon Action Report.png|25px|Action Report]] %d', shipInfo.remodelar)
 +
        end
 +
         if shipInfo.remodeldevmat or shipInfo.remodelconmat or shipInfo.remodelgunmat or shipInfo.remodelairmat then
 
           remodelinfo = remodelinfo .. '<br>'
 
           remodelinfo = remodelinfo .. '<br>'
 
         end
 
         end
Line 293: Line 366:  
         if shipInfo.remodelconmat then
 
         if shipInfo.remodelconmat then
 
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoConmat.png|18px|Construction Material]] %d', shipInfo.remodelconmat)
 
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoConmat.png|18px|Construction Material]] %d', shipInfo.remodelconmat)
 +
        end
 +
        if shipInfo.remodelgunmat then
 +
          remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon New Model Gun Mount Improvement Material.png|18px|New Model Gun Mount Improvement Material]] %d', shipInfo.remodelgunmat)
 +
        end
 +
        if shipInfo.remodelairmat then
 +
          remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon New Model Aerial Armament Material.png|18px|New Model Aerial Armament Material]] %d', shipInfo.remodelairmat)
 +
        end
 +
        if shipInfo.remodelarmmat then
 +
          remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon New Model Armament Material.png|18px|New Model Armament Material]] %d', shipInfo.remodelarmmat)
 
         end
 
         end
 
     end
 
     end
Line 334: Line 416:  
     end
 
     end
 
     local row13 = '<tr>' .. RscHeader .. 'Modernization</th>' .. RscData2 .. modInfo .. '</td></tr>'
 
     local row13 = '<tr>' .. RscHeader .. 'Modernization</th>' .. RscData2 .. modInfo .. '</td></tr>'
     return '<table style="width: 100%">' .. row13 .. row11 .. row12 .. '</table>'
+
     -- return '<table style="width: 100%">' .. row13 .. row11 .. row12 .. '</table>'
 +
    return row13 .. row11 .. row12
 
end
 
end
    
function shipmodule.getArtVoice(frame)
 
function shipmodule.getArtVoice(frame)
 
     local shipNum = shipmodule.getIDNum(frame)
 
     local shipNum = shipmodule.getIDNum(frame)
   
     local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " doesn't have a database entry")
 
     local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " doesn't have a database entry")
    -- Artist & Voice Info
   
     local RscHeader = '<th style="width: 25%; white-space: nowrap; {{border-radius|12px 4px 4px 12px}} background-color: #3baef5; color: #ffffff; padding-left: 5px; padding-right: 5px; text-align: right;">'
 
     local RscHeader = '<th style="width: 25%; white-space: nowrap; {{border-radius|12px 4px 4px 12px}} background-color: #3baef5; color: #ffffff; padding-left: 5px; padding-right: 5px; text-align: right;">'
 
     local RscData = '<td style="width: 25%; white-space: nowrap; text-align: center;">'
 
     local RscData = '<td style="width: 25%; white-space: nowrap; text-align: center;">'
   
     local illustrator = ''
 
     local illustrator = ''
 
     local voiceactor = ''
 
     local voiceactor = ''
 
     if shipmodule.data[shipNum]["artist"] ~= "Unknown" and shipmodule.data[shipNum]["artist"] ~= "" then
 
     if shipmodule.data[shipNum]["artist"] ~= "Unknown" and shipmodule.data[shipNum]["artist"] ~= "" then
 
         illustrator = '[[:Category:' .. shipmodule.data[shipNum]["artist"] .. '|' .. shipmodule.data[shipNum]["artist"] .. ']]'
 
         illustrator = '[[:Category:' .. shipmodule.data[shipNum]["artist"] .. '|' .. shipmodule.data[shipNum]["artist"] .. ']]'
        --cat = cat .. '[[Category:' .. shipmodule.data[shipNum]["artist"] .. ']]'
   
     else
 
     else
 
         illustrator = 'Unknown'
 
         illustrator = 'Unknown'
Line 356: Line 435:  
     if shipmodule.data[shipNum]["seiyuu"] ~= "Unknown" and shipmodule.data[shipNum]["seiyuu"] ~= "" then
 
     if shipmodule.data[shipNum]["seiyuu"] ~= "Unknown" and shipmodule.data[shipNum]["seiyuu"] ~= "" then
 
         voiceactor = '[[:Category:' .. shipmodule.data[shipNum]["seiyuu"] .. '|' .. shipmodule.data[shipNum]["seiyuu"] .. ']]'
 
         voiceactor = '[[:Category:' .. shipmodule.data[shipNum]["seiyuu"] .. '|' .. shipmodule.data[shipNum]["seiyuu"] .. ']]'
        --cat = cat .. '[[Category:' .. shipmodule.data[shipNum]["seiyuu"] .. ']]'
   
     else
 
     else
 
         voiceactor = 'Unknown'
 
         voiceactor = 'Unknown'
 
     end
 
     end
 
     voice = RscHeader .. 'Seiyuu</th>' .. RscData .. voiceactor .. '</td>'
 
     voice = RscHeader .. 'Seiyuu</th>' .. RscData .. voiceactor .. '</td>'
     local row14 = '<table style="width: 100%">' .. art .. voice .. '</table>'
+
     --local row14 = '<table style="width: 100%">' .. art .. voice .. '</table>'
     return row14
+
     return art .. voice
 
end
 
end
   Line 379: Line 457:  
     end
 
     end
 
return cat
 
return cat
end
  −
  −
local remodelItems = mw.loadData('Module:KanmusuModule/RemodelHardcode')
  −
  −
function shipmodule.RemodelBlueprintChk(blueprint, shipNum)
  −
  return remodelItems[tonumber(shipNum)] or remodelItems[tonumber(blueprint)]
   
end
 
end
   Line 504: Line 576:  
     strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["consumption"][2] .. '</td></tr>'
 
     strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["consumption"][2] .. '</td></tr>'
 
     return strings
 
     return strings
 +
end
 +
 +
local function numToID(num)
 +
return num < 10 and "00" .. num or num < 100 and "0" .. num or tostring(num)
 +
end
 +
 +
function shipmodule.CardList()
 +
firstID = 1
 +
maxID = -1
 +
for KanMusuID, KanMusuData in pairs(shipmodule.data) do
 +
if tonumber(KanMusuID) ~= nil and tonumber(KanMusuID) > maxID then
 +
maxID = tonumber(KanMusuID)
 +
end
 +
end
 +
IDRange = math.ceil(maxID / 10) * 10
 +
wikipage = ""
 +
while firstID < IDRange do
 +
wikipage = wikipage .. "<h2>No. " .. tostring(firstID) .. "-" .. tostring(firstID+9) .. "</h2>"
 +
for i = 0, 9 do
 +
x = firstID + i
 +
shipID = numToID(x)
 +
if not shipmodule.data[shipID] then
 +
wikipage = wikipage .. "[[File:blank.png|150px]]"
 +
else
 +
local shipName = shipmodule.data[shipID].name[3]
 +
wikipage = wikipage .. "[[File:Ship Card " .. shipName .. ".png|150px|link=" .. shipdb.getWikiPage(shipID) .. "]]"
 +
end
 +
if x % 5 == 0 then
 +
wikipage = wikipage .. "<br>"
 +
end
 +
end
 +
wikipage = wikipage .. "<br>"
 +
firstID = firstID + 10
 +
end
 +
return wikipage
 
end
 
end
    
return shipmodule
 
return shipmodule
cssedit, gkautomate
6,916

edits

Navigation menu