• 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:Core')
 
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 37: 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 277: Line 350:  
         remodelinfo = string.format('[[File:IcoSteel.png|18px|Steel]] %d [[File:IcoAmmo.png|18px|Ammo]] %d', shipInfo.remodelreq[1], shipInfo.remodelreq[2])
 
         remodelinfo = string.format('[[File:IcoSteel.png|18px|Steel]] %d [[File:IcoAmmo.png|18px|Ammo]] %d', shipInfo.remodelreq[1], shipInfo.remodelreq[2])
 
         if shipInfo.remodelbp then
 
         if shipInfo.remodelbp then
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoBlueprint.png|25px|Blueprint|link=Blueprints]] %d', shipInfo.remodelbp)
+
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon Remodel Blueprint.png|25px|Blueprint|link=Blueprints]] %d', shipInfo.remodelbp)
 
         end
 
         end
 
         if shipInfo.remodelcatapult then
 
         if shipInfo.remodelcatapult then
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoCatapult.png|25px|Prototype Flight Deck Catapult]] %d', shipInfo.remodelcatapult)
+
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon Prototype Flight Deck Catapult.png|25px|Prototype Flight Deck Catapult]] %d', shipInfo.remodelcatapult)
 
         end
 
         end
 
         if shipInfo.remodelar then
 
         if shipInfo.remodelar then
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoActionReport.png|25px|Action Report]] %d', shipInfo.remodelar)
+
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:Item Icon Action Report.png|25px|Action Report]] %d', shipInfo.remodelar)
 
         end
 
         end
 
         if shipInfo.remodeldevmat or shipInfo.remodelconmat or shipInfo.remodelgunmat or shipInfo.remodelairmat then
 
         if shipInfo.remodeldevmat or shipInfo.remodelconmat or shipInfo.remodelgunmat or shipInfo.remodelairmat then
Line 295: Line 368:  
         end
 
         end
 
         if shipInfo.remodelgunmat then
 
         if shipInfo.remodelgunmat then
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoGunmat.png|18px|New Model Gun Mount Improvement Material]] %d', shipInfo.remodelgunmat)
+
           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
 
         end
 
         if shipInfo.remodelairmat then
 
         if shipInfo.remodelairmat then
           remodelinfo = remodelinfo .. ' ' .. string.format('[[File:IcoAirmat.png|18px|New Model Aerial Armament Material]] %d', shipInfo.remodelairmat)
+
           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 521: Line 597:  
x = firstID + i
 
x = firstID + i
 
shipID = numToID(x)
 
shipID = numToID(x)
if shipmodule.data[shipID] == nil then
+
if not shipmodule.data[shipID] then
 
wikipage = wikipage .. "[[File:blank.png|150px]]"
 
wikipage = wikipage .. "[[File:blank.png|150px]]"
 
else
 
else
wikipage = wikipage .. "[[File:KanMusu" .. shipID .. "Card.png|150px|link=" .. shipdb.getWikiPage(shipID) .. "]]"
+
local shipName = shipmodule.data[shipID].name[3]
 +
wikipage = wikipage .. "[[File:Ship Card " .. shipName .. ".png|150px|link=" .. shipdb.getWikiPage(shipID) .. "]]"
 
end
 
end
 
if x % 5 == 0 then
 
if x % 5 == 0 then
cssedit, gkautomate
6,916

edits

Navigation menu