• 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 31: Line 31:  
end
 
end
   −
-- The ship infobox stuff...
+
-- The ship infobox stuff, legacy
   −
local function renderStats(ship, shipNum)
+
local function renderStats(ship)
 
   local shipName = ship.name[3]
 
   local shipName = ship.name[3]
 
   local CardImg = '<div class="top-image">[[File:Ship Card ' .. shipName .. ".png|218x300px|link=]]</div>"
 
   local CardImg = '<div class="top-image">[[File:Ship Card ' .. shipName .. ".png|218x300px|link=]]</div>"
Line 43: Line 43:  
   local Banners =
 
   local Banners =
 
     '<td colspan="3" class="double-image" style="width:240px;height:60px">' .. BannerImg .. BannerDmgImg .. "</td>"
 
     '<td colspan="3" class="double-image" style="width:240px;height:60px">' .. BannerImg .. BannerDmgImg .. "</td>"
   local sortNo = ship.sortno or U.split(shipNum, "-")[1] or "?"
+
   local sortNoText = ship.no and (ship.no < 1000 and ship.no or formatTooltip(ship.id, ship.no)) or ship.id
   local row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNo .. "</th>" .. Banners .. "</tr>"
+
   local row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNoText .. "</th>" .. Banners .. "</tr>"
 
   -- Formatting Japanese
 
   -- Formatting Japanese
 
   local kanji, form
 
   local kanji, form
Line 88: Line 88:  
   local JaName = ""
 
   local JaName = ""
 
   if
 
   if
     shipNum == "147" or shipNum == "311" or shipNum == "312" or shipNum == "313" or shipNum == "313a" or
+
     ship.name[3] == "Verniy" or ship.name[3] == "Gangut" or ship.name[3] == "Oktyabrskaya Revolyutsiya" or ship.name[3] == "Tashkent" or ship.name[3] == "Tashkent Kai" or ship.name[3] == "Gangut Dva"
      shipNum == "316"
+
   then -- Russian ship markup
   then --Russian ship markup
   
     JaName =
 
     JaName =
 
       '<ruby lang="ru"><rb>' ..
 
       '<ruby lang="ru"><rb>' ..
Line 112: Line 111:  
     ship.type
 
     ship.type
 
   local row2 = '<tr><th colspan="2">' .. JaName .. '</th><th colspan="2">' .. ship.name[3] .. "</th></tr>"
 
   local row2 = '<tr><th colspan="2">' .. JaName .. '</th><th colspan="2">' .. ship.name[3] .. "</th></tr>"
   local row3 = '<tr><td colspan="4" style="text-align: center;">' .. ship.class .. " Class " .. shipType .. "</td></tr>"
+
  local class_string = ship.display_class and formatTooltip(ship.class, "Game library: " .. ship.display_class) or ship.class
 +
   local row3 = '<tr><td colspan="4" style="text-align: center;">' .. class_string .. " " .. shipType .. "</td></tr>"
 
   local row4 =
 
   local row4 =
 
     '<tr><td colspan="4"><hr style="border: 0; height: 1px; background-image: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));" /></td></tr>'
 
     '<tr><td colspan="4"><hr style="border: 0; height: 1px; background-image: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));" /></td></tr>'
Line 138: Line 138:  
   end
 
   end
 
   local FPinfo =
 
   local FPinfo =
     statLabel .. "FP [[File:IcoAtk.png|Firepower]]</th>" .. statBox .. ship["fp"][1] .. "→" .. ship["fp"][2] .. "</td>"
+
     statLabel .. "FP [[File:IcoAtk.png|18px|Firepower]]</th>" .. statBox .. ship["fp"][1] .. "→" .. ship["fp"][2] .. "</td>"
 
   local row5 = "<tr>" .. HPinfo .. FPinfo .. "</tr>"
 
   local row5 = "<tr>" .. HPinfo .. FPinfo .. "</tr>"
 
   -- Armor & Torpedo
 
   -- Armor & Torpedo
Line 144: Line 144:  
     statLabel ..
 
     statLabel ..
 
     "ARM [[File:IcoArmor.png|Armor]]</th>" .. statBox .. ship["armor"][1] .. "→" .. ship["armor"][2] .. "</td>"
 
     "ARM [[File:IcoArmor.png|Armor]]</th>" .. statBox .. ship["armor"][1] .. "→" .. ship["armor"][2] .. "</td>"
   local Torpedoinfo = statLabel .. "TORP [[File:IcoTorpedo.png|Torpedo]]</th>" .. statBox
+
   local Torpedoinfo = statLabel .. "TORP[[File:IcoTorpedo.png|Torpedo]]</th>" .. statBox
 
   if ship["torpedo"] == 0 then
 
   if ship["torpedo"] == 0 then
 
     Torpedoinfo = Torpedoinfo .. ship["torpedo"]
 
     Torpedoinfo = Torpedoinfo .. ship["torpedo"]
Line 281: Line 281:  
     remodelinfo =
 
     remodelinfo =
 
       string.format(
 
       string.format(
       "[[File:IcoSteel.png|18px|Steel]] %d [[File:IcoAmmo.png|18px|Ammo]] %d",
+
       "[[File:IcoAmmo.png|18px|Ammo]] %d [[File:IcoSteel.png|18px|Steel]] %d",
       ship.remodelreq[1],
+
       ship.remodelreq[2],
       ship.remodelreq[2]
+
       ship.remodelreq[1]
 
     )
 
     )
 
     if ship.remodelbp then
 
     if ship.remodelbp then
Line 306: Line 306:  
           string.format("[[File:Item Icon Action Report.png|25px|Action Report|link=Action Report]] %d", ship.remodelar)
 
           string.format("[[File:Item Icon Action Report.png|25px|Action Report|link=Action Report]] %d", ship.remodelar)
 
     end
 
     end
     if ship.remodeldevmat or ship.remodelconmat or ship.remodelgunmat or ship.remodelairmat then
+
     if ship.remodeldevmat or ship.remodelconmat or ship.remodelgunmat or ship.remodelairmat or ship.remodelarmmat or ship.remodelboiler or ship.remodelscrew then
 
       remodelinfo = remodelinfo .. "<br>"
 
       remodelinfo = remodelinfo .. "<br>"
 
     end
 
     end
Line 352: Line 352:  
             ship.remodelboiler
 
             ship.remodelboiler
 
           )
 
           )
 +
    end
 +
    if ship.remodelscrew then
 +
      remodelinfo =
 +
        remodelinfo .. " " .. string.format("[[File:Item Icon Improvement Material.png|18px|Improvement Material|link=Improvement]] %d", ship.remodelscrew)
 
     end
 
     end
 
   end
 
   end
Line 409: Line 413:  
     "Unknown"
 
     "Unknown"
 
   return RscHeader ..
 
   return RscHeader ..
     "Artist</th>" .. RscData .. illustrator .. "</td>" .. RscHeader .. "Seiyuu</th>" .. RscData .. voiceactor .. "</td>"
+
     "Illustrator</th>" .. RscData .. illustrator .. "</td>" .. RscHeader .. "Seiyuu</th>" .. RscData .. voiceactor .. "</td>"
 
end
 
end
    
local function renderCategories(ship)
 
local function renderCategories(ship)
   local categories = "[[Category:Ships]][[Category:" .. ship["class"] .. " Class]][[Category:" .. ship["type"] .. "s]]"
+
   local categories = "[[Category:Ships]][[Category:" .. ship["class"] .. "]][[Category:" .. ship["type"] .. "s]]"
 
   if ship["artist"] ~= "Unknown" and ship["artist"] ~= "" then
 
   if ship["artist"] ~= "Unknown" and ship["artist"] ~= "" then
 
     categories = categories .. "[[Category:" .. ship["artist"] .. "]]"
 
     categories = categories .. "[[Category:" .. ship["artist"] .. "]]"
Line 421: Line 425:  
   end
 
   end
 
   return categories
 
   return categories
 +
end
 +
 +
local function renderReversion(ship) --Copy paste mess by Chocolatecravinghobo. Shows information/cost for models that remodel/revert to a previous remodel
 +
  --- Souya hardcode fix
 +
  if ship["reversionto"] == "Souya " then
 +
ship.reversionto = ship.reversionto .. "(AGS)"
 +
  end
 +
 
 +
  local reversionHeader = ""
 +
  local reversionStyle = ""
 +
  local reversionHeader =
 +
      '<th colspan="4" style="width: 75%; white-space: nowrap; {{border-radius|12px 12px 12px 12px}} background-color: #3baef5; color: #ffffff; vertical-align: baseline;"> Reversible to ' .. ship.reversionto .. "</th>"
 +
  local reversionStyle = '<td style="white-space: nowrap; text-align: center; vertical-align: baseline;">'
 +
  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;">'
 +
  -- Construction info
 +
  local reversionlvheader = ""
 +
  local reversionlvdata = ""
 +
  if ship["reversionlv"] ~= nil and ship["reversionlv"] ~= "" then
 +
    reversionlvheader = "Reversion Level"
 +
    reversionlvdata = ship["reversionlv"]
 +
  end
 +
  local reversioninfo = ""
 +
  if ship.reversionreq and ship.reversionreq ~= "" then
 +
    reversioninfo =
 +
      string.format(
 +
      "[[File:IcoAmmo.png|18px|Ammo]] %d [[File:IcoSteel.png|18px|Steel]] %d",
 +
      ship.reversionreq[2],
 +
      ship.reversionreq[1]
 +
    )
 +
    if ship.reversionbp then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format("[[File:Item Icon Remodel Blueprint.png|25px|Blueprint|link=Blueprints]] %d", ship.reversionbp)
 +
    end
 +
    if ship.reversioncatapult then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format(
 +
            "[[File:Item Icon Prototype Flight Deck Catapult.png|25px|Prototype Flight Deck Catapult|link=Prototype Flight Deck Catapult]] %d",
 +
            ship.reversioncatapult
 +
          )
 +
    end
 +
    if ship.reversionar then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format("[[File:Item Icon Action Report.png|25px|Action Report|link=Action Report]] %d", ship.reversionar)
 +
    end
 +
    if ship.reversiondevmat or ship.reversionconmat or ship.reversiongunmat or ship.reversionairmat or ship.reversionarmmat or ship.reversionboiler or ship.reversionscrew then
 +
      reversioninfo = reversioninfo .. "<br>"
 +
    end
 +
    if ship.reversiondevmat then
 +
      reversioninfo =
 +
        reversioninfo .. " " .. string.format("[[File:IcoDevmat.png|18px|Development Material]] %d", ship.reversiondevmat)
 +
    end
 +
    if ship.reversionconmat then
 +
      reversioninfo =
 +
        reversioninfo .. " " .. string.format("[[File:IcoConmat.png|18px|Construction Material]] %d", ship.reversionconmat)
 +
    end
 +
    if ship.reversiongunmat then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format(
 +
            "[[File:Item Icon New Model Gun Mount Improvement Material.png|18px|New Model Gun Mount Improvement Material|link=New Model Gun Development Material]] %d",
 +
            ship.reversiongunmat
 +
          )
 +
    end
 +
    if ship.reversionairmat then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format(
 +
            "[[File:Item Icon New Model Aerial Armament Material.png|18px|New Model Aerial Armament Material|link=New Model Aviation Development Material]] %d",
 +
            ship.reversionairmat
 +
          )
 +
    end
 +
    if ship.reversionarmmat then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format(
 +
            "[[File:Item Icon New Model Armament Material.png|18px|New Model Armament Material|link=New Model Armament Material]] %d",
 +
            ship.reversionarmmat
 +
          )
 +
    end
 +
    if ship.reversionboiler then
 +
      reversioninfo =
 +
        reversioninfo ..
 +
        " " ..
 +
          string.format(
 +
            "[[File:Item Icon New Model High Temperature High Pressure Boiler.png|18px|New Model High Temperature High Pressure Boiler|link=New Model High Temperature High Pressure Boiler]] %d",
 +
            ship.reversionboiler
 +
          )
 +
    end
 +
    if ship.reversionscrew then
 +
      reversioninfo = reversioninfo .. " " .. string.format(
 +
        "[[File:Item Icon Improvement Material.png|18px|Improvement Material|link=Improvement]] %d",
 +
        ship.reversionscrew
 +
      )
 +
    end
 +
  end
 +
  -- Reversion
 +
  local row14 = ""
 +
  local row15 = ""
 +
  if ship.reversionlv ~= "" then
 +
    row14 = "<tr>" .. reversionHeader .. "</tr>"-- .. reversionStyle
 +
    row15 =
 +
    "<tr>" ..
 +
      RscHeader ..
 +
        reversionlvheader ..
 +
          "</th>" ..
 +
            RscData ..
 +
              reversionlvdata .. "</td>" .. RscHeader .. "Reversion Req</th>" .. RscData .. reversioninfo .. "</td></tr>"
 +
  end
 +
  return row14 .. row15
 +
end
 +
 +
 +
-- Converting to legacy data format
 +
 +
local ShipData = require("Module:Data/Ship")
 +
local shipsByNo = require("Module:Collection/ShipsByNo")
 +
local shipsById = require("Module:Collection/ShipsByApiId")
 +
local Ship = require("Module:Ship")
 +
 +
local function minMaxStats(a, b)
 +
  return a == nil and b == nil and {'??', '??'} or (a == false or a == 0) and (b == false or b == 0) and 0 or {a or '??', b or '??'}
 +
end
 +
 +
local function trueIsOne(x)
 +
  return x == true and 1 or x
 +
end
 +
 +
local function loadShipData(key)
 +
  local ship = Ship(shipsById[(U.find(shipsByNo, ShipData[key] or key, "name") or {}).id] or key)
 +
  local data = {}
 +
  data.id = ship:id() or '???'
 +
  data.no = ship:true_id()
 +
  data.name = {ship:japanese_name() or "", ship:reading() or "", ship:name() or ""}
 +
  local class = ship:class()
 +
  data.class = class and class:name() or "???"
 +
  data.display_class = ship._display_class
 +
  data.type = ship:formatted_type() or ""
 +
  data.spd = ship:formatted_speed() or ""
 +
  data.range = ship:formatted_range() or ""
 +
  data.rarity = ship:rarity() or ""
 +
  data.hp = minMaxStats(ship:hp(), ship:hp_max())
 +
  data.fp = minMaxStats(ship:firepower(), ship:firepower_max())
 +
  data.armor = minMaxStats(ship:armor(), ship:armor_max())
 +
  data.torpedo = minMaxStats(ship:torpedo(), ship:torpedo_max())
 +
  data.aa = minMaxStats(ship:aa(), ship:aa_max())
 +
  data.luck = minMaxStats(ship:luck(), ship:luck_max())
 +
  data.evasion = minMaxStats(ship:evasion(), ship:evasion_max())
 +
  data.asw = minMaxStats(ship:asw(), ship:asw_max())
 +
  data.los = minMaxStats(ship:los(), ship:los_max())
 +
  data.aircraft = {}
 +
  data.equip = {}
 +
  for _, v in ipairs(ship._equipment) do
 +
    table.insert(data.equip, (v.equipment == nil and '?' or v.equipment or '') .. (v.stars and string.format(' ★+%d', v.stars) or ''))
 +
    table.insert(data.aircraft, v.size or "")
 +
  end
 +
  data.artist = ship:artist() or ""
 +
  if data.artist == 'Shimada Humikane' then
 +
data.artist = 'Shimada Fumikane'
 +
  end
 +
  data.seiyuu = ship:voice_actor() or ""
 +
  data.buildtime = {
 +
    ship._build_time or "",
 +
    ship._buildable == true or false,
 +
    ship._buildable_lsc == true or false
 +
  }
 +
  data.remodellv = ship:remodel_level() or ""
 +
  data.consumption = {ship:fuel() or "", ship:ammo() or ""}
 +
  data.remodelreq = not ship._remodel_steel and not ship._remodel_ammo and '' or {ship._remodel_steel or 0, ship._remodel_ammo or 0}
 +
  data.dismantle = {
 +
    ship._scrap_fuel or 0,
 +
    ship._scrap_ammo or 0,
 +
    ship._scrap_steel or 0,
 +
    ship._scrap_baux or 0,
 +
  }
 +
  data.modernization = {
 +
    ship._firepower_mod or 0,
 +
    ship._torpedo_mod or 0,
 +
    ship._aa_mod or 0,
 +
    ship._armor_mod or 0,
 +
    ship._luck_mod or '',
 +
  }
 +
  data.remodelbp = trueIsOne(ship._remodel_blueprint)
 +
  data.remodelcatapult = trueIsOne(ship._remodel_catapult)
 +
  data.remodelar = trueIsOne(ship._remodel_report)
 +
  data.remodelgunmat = trueIsOne(ship._remodel_gunmat)
 +
  data.remodelairmat = trueIsOne(ship._remodel_airmat)
 +
  data.remodelarmmat = trueIsOne(ship._remodel_armament)
 +
  data.remodelboiler = trueIsOne(ship._remodel_boiler)
 +
  data.remodeldevmat = trueIsOne(ship._remodel_development_material)
 +
  data.remodelconmat = trueIsOne(ship._remodel_construction_material)
 +
  data.remodelscrew = trueIsOne(ship._remodel_screw)
 +
 
 +
  data.reversible = trueIsOne(ship._reversible)
 +
  data.reversionto = ship:remodel_to() or ""
 +
  data.reversionto = data.reversionto:gsub("/", " ")
 +
  data.reversionbp = trueIsOne(ship._remodel_to_blueprint)
 +
  data.reversionlv = ship:remodel_to_level() or ""
 +
  data.reversionreq = not ship._remodel_to_steel and not ship._remodel_to_ammo and '' or {ship._remodel_to_steel or 0, ship._remodel_to_ammo or 0}
 +
  data.reversionbp = trueIsOne(ship._remodel_to_blueprint)
 +
  data.reversioncatapult = trueIsOne(ship._remodel_to_catapult)
 +
  data.reversionar = trueIsOne(ship._remodel_to_report)
 +
  data.reversiongunmat = trueIsOne(ship._remodel_to_gunmat)
 +
  data.reversionairmat = trueIsOne(ship._remodel_to_airmat)
 +
  data.reversionarmmat = trueIsOne(ship._remodel_to_armament)
 +
  data.reversionboiler = trueIsOne(ship._remodel_to_boiler)
 +
  data.reversiondevmat = trueIsOne(ship._remodel_to_development_material)
 +
  data.reversionconmat = trueIsOne(ship._remodel_to_construction_material)
 +
  data.reversionscrew = trueIsOne(ship._remodel_to_screw)
 +
  return data
 
end
 
end
    
local function render(frame)
 
local function render(frame)
   local ShipData = mw.loadData("Module:Data/Ship")
+
   local ship = loadShipData(frame.args[1])
  local shipNum = frame.args[1]
  −
  local ship = ShipData[shipNum]
   
   return '<div style="display:inline-block;vertical-align:top"><table style="{{border-radius|10px 10px 10px 10px}} border:1px solid #aaaaaa;min-width:495px"><tr><td>' ..
 
   return '<div style="display:inline-block;vertical-align:top"><table style="{{border-radius|10px 10px 10px 10px}} border:1px solid #aaaaaa;min-width:495px"><tr><td>' ..
     renderStats(ship, shipNum) ..
+
     renderStats(ship) ..
 
       "</td></tr><tr><td>" ..
 
       "</td></tr><tr><td>" ..
 
         renderEquipment(ship) ..
 
         renderEquipment(ship) ..
 
           '<table style="width:100%">' ..
 
           '<table style="width:100%">' ..
 
             renderModernization(ship) ..
 
             renderModernization(ship) ..
               renderArtists(ship) .. "</table></td></tr></table></div>" .. renderCategories(ship)
+
               renderArtists(ship) ..
 +
            renderReversion(ship) .. "</table></td></tr></table></div>" .. renderCategories(ship)
 +
end
 +
 
 +
local function test()
 +
  return render({args = {"Brooklyn"}})
 
end
 
end
   −
return {KanmusuInfo = render}
+
-- print(p.test())
 +
 
 +
return {KanmusuInfo = render, test = test}
cssedit, gkautomate
6,926

edits

Navigation menu