Changes

m
no edit summary
Line 1: Line 1:  
local U = require("Module:Core")
 
local U = require("Module:Core")
 +
local DataCaps = require("Module:Data/Caps")
    
-- Some formatting
 
-- Some formatting
Line 28: Line 29:     
local function getMarriedHp(hp, maxHp)
 
local function getMarriedHp(hp, maxHp)
   return math.min(maxHp, hp + ({4, 4, 4, 5, 6, 7, 7, 8, 8, 9})[math.floor(hp / 10) + 1])
+
   return math.min(maxHp, hp + ({3, 4, 4, 5, 6, 7, 7, 8, 8, 9})[math.floor(hp / 10) + 1])
 +
end
 +
local function getScaledStat(baseStat, maxStat, level)
 +
  return math.floor((maxStat-baseStat) /99 * level + baseStat)
 +
end
 +
local function notNil(value)
 +
  return value ~= nil and value ~= "" and value ~= "??"
 
end
 
end
   Line 44: Line 51:  
     '<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 sortNoText = ship.no and (ship.no < 1000 and ship.no or formatTooltip(ship.id, ship.no)) or ship.id
 
   local sortNoText = ship.no and (ship.no < 1000 and ship.no or formatTooltip(ship.id, ship.no)) or ship.id
 +
  local MarriedMaxTemplate = "Maximum after marriage: ${value}"
 +
  local ASWModMaxTemplate = "${value} with ASW modernization"
 +
  local ASWMarriedMaxTemplate = "Maximum after marriage: ${value} (${valueM})"
 +
  local RemodelLevelStatValueText = "At remodel level: ${value}"
 
   local row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNoText .. "</th>" .. Banners .. "</tr>"
 
   local row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNoText .. "</th>" .. Banners .. "</tr>"
 
   -- Formatting Japanese
 
   -- Formatting Japanese
Line 123: Line 134:  
   local maxHp = ship["hp"][2]
 
   local maxHp = ship["hp"][2]
 
   local HPinfo
 
   local HPinfo
   if maxHp then
+
   if maxHp and maxHp ~= '??' then
 
     local marriedHp = getMarriedHp(hp, maxHp)
 
     local marriedHp = getMarriedHp(hp, maxHp)
 
     local maxModHp = math.min(hp + 2, maxHp)
 
     local maxModHp = math.min(hp + 2, maxHp)
Line 152: Line 163:  
   local row6 = "<tr>" .. Armorinfo .. Torpedoinfo .. "</tr>"
 
   local row6 = "<tr>" .. Armorinfo .. Torpedoinfo .. "</tr>"
 
   -- Evasion & AA
 
   -- Evasion & AA
   local Evasioninfo =
+
   local Evasioninfo = statLabel .. "EVA [[File:IcoEvasion.png|Evasion]]</th>" .. statBox
    statLabel ..
+
  if notNil(ship["evasion"][1]) and notNil(ship["evasion"][2]) then
    "EVA [[File:IcoEvasion.png|Evasion]]</th>" .. statBox .. ship["evasion"][1] .. "→" .. ship["evasion"][2] .. "</td>"
+
    if notNil(ship["remodellv"]) then
 +
      Evasioninfo = Evasioninfo .. formatTooltip(ship["evasion"][1], U.format{RemodelLevelStatValueText, value = getScaledStat(ship["evasion"][1], ship["evasion"][2], ship["remodellv"])}) .. "→"
 +
    else
 +
      Evasioninfo = Evasioninfo .. ship["evasion"][1] .. "→"
 +
    end
 +
    Evasioninfo = Evasioninfo .. formatTooltip(ship["evasion"][2], U.format{MarriedMaxTemplate, value = getScaledStat(ship["evasion"][1], ship["evasion"][2], DataCaps.ship_level)}) .. "</td>"
 +
  else
 +
  Evasioninfo = Evasioninfo .. ship["evasion"][1] .. "→" .. ship["evasion"][2]
 +
  end
 
   local AAinfo = statLabel .. "AA [[File:IcoAA.png|Anti-Air]]</th>" .. statBox
 
   local AAinfo = statLabel .. "AA [[File:IcoAA.png|Anti-Air]]</th>" .. statBox
 
   if ship["aa"] == 0 then
 
   if ship["aa"] == 0 then
Line 168: Line 187:  
   if ship["asw"] == 0 then
 
   if ship["asw"] == 0 then
 
     ASWinfo = ASWinfo .. ship["asw"]
 
     ASWinfo = ASWinfo .. ship["asw"]
 +
  elseif notNil(ship["asw"][1]) and notNil(ship["asw"][2]) then
 +
    if notNil(ship["remodellv"])  then
 +
      ASWinfo = ASWinfo .. formatTooltip(ship["asw"][1], U.format{RemodelLevelStatValueText, value = getScaledStat(ship["asw"][1], ship["asw"][2], ship["remodellv"])}) .. "→"
 +
    else
 +
      ASWinfo = ASWinfo .. ship["asw"][1] .. "→"
 +
    end
 +
    local marriedASW = getScaledStat(ship["asw"][1], ship["asw"][2], DataCaps.ship_level)
 +
      ASWinfo = ASWinfo .. formatTooltip(ship["asw"][2], U.format{ASWModMaxTemplate, value = ship["asw"][2]+9} .. ". " .. U.format{ASWMarriedMaxTemplate, value = marriedASW, valueM = marriedASW+9} )
 
   else
 
   else
    ASWinfo = ASWinfo .. ship["asw"][1] .. "→" .. ship["asw"][2]
+
      ASWinfo = ASWinfo .. ship["asw"][1] .. "→" .. ship["asw"][2]
 
   end
 
   end
 
   local row8 = "<tr>" .. Planeinfo .. ASWinfo .. "</tr>"
 
   local row8 = "<tr>" .. Planeinfo .. ASWinfo .. "</tr>"
 
   -- Speed & LOS
 
   -- Speed & LOS
 
   local Speedinfo = statLabel .. "SPD [[File:IcoSpeed.png|Speed]]</th>" .. statBox .. ship["spd"] .. "</td>"
 
   local Speedinfo = statLabel .. "SPD [[File:IcoSpeed.png|Speed]]</th>" .. statBox .. ship["spd"] .. "</td>"
   local LOSinfo =
+
   local LOSinfo = statLabel .. "LOS [[File:IcoLOS.png|Line of Sight]]</th>" .. statBox
    statLabel ..
+
  if notNil(ship["los"][1]) and notNil(ship["los"][2]) then
    "LOS [[File:IcoLOS.png|Line of Sight]]</th>" .. statBox .. ship["los"][1] .. "→" .. ship["los"][2] .. "</td>"
+
    if notNil(ship["remodellv"]) then
 +
      LOSinfo = LOSinfo .. formatTooltip(ship["los"][1], U.format{RemodelLevelStatValueText, value = getScaledStat(ship["los"][1], ship["los"][2], ship["remodellv"])}) .. "→"
 +
    else
 +
      LOSinfo = LOSinfo .. ship["los"][1] .. "→"
 +
    end
 +
    LOSinfo = LOSinfo .. formatTooltip(ship["los"][2], U.format{MarriedMaxTemplate, value = getScaledStat(ship["los"][1], ship["los"][2], DataCaps.ship_level)}) .. "</td>"
 +
  else
 +
  LOSinfo = LOSinfo .. ship["los"][1] .. "→" .. ship["los"][2]
 +
  end
 
   local row9 = "<tr>" .. Speedinfo .. LOSinfo .. "</tr>"
 
   local row9 = "<tr>" .. Speedinfo .. LOSinfo .. "</tr>"
 
   -- Range & Luck
 
   -- Range & Luck
Line 262: Line 297:  
   local constrheader = ""
 
   local constrheader = ""
 
   local constrdata = ""
 
   local constrdata = ""
   if ship["remodellv"] ~= nil and ship["remodellv"] ~= "" then
+
   if notNil(ship["remodellv"]) then
 
     constrheader = "Remodel Level"
 
     constrheader = "Remodel Level"
 
     constrdata = ship["remodellv"]
 
     constrdata = ship["remodellv"]
Line 271: Line 306:  
       string.format(
 
       string.format(
 
         "%s (%s)",
 
         "%s (%s)",
         formatBuildtime(ship.buildtime[1]),
+
         type(ship.buildtime[1]) == "number" and formatBuildtime(ship.buildtime[1]) or "??",
 
         ship.buildtime[2] and ship.buildtime[3] and "Normal, LSC" or ship.buildtime[2] and "Normal" or
 
         ship.buildtime[2] and ship.buildtime[3] and "Normal, LSC" or ship.buildtime[2] and "Normal" or
           ship.buildtime[3] and "LSC" or
+
           ship.buildtime[3] and "LSC" or "Unbuildable"
          "Unbuildable"
   
       )
 
       )
 
   end
 
   end
Line 306: Line 340:  
           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 or ship.remodelarmmat or ship.remodelboiler or ship.remodelscrew then
+
     if ship.remodeldevmat or ship.remodelconmat or ship.remodelgunmat or ship.remodelairmat or ship.remodelarmmat or ship.remodelboiler or ship.overseastech or ship.remodelscrew then
 
       remodelinfo = remodelinfo .. "<br>"
 
       remodelinfo = remodelinfo .. "<br>"
 
     end
 
     end
Line 351: Line 385:  
             "[[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",
 
             "[[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.remodelboiler
 
             ship.remodelboiler
 +
          )
 +
    end
 +
    if ship.overseastech then
 +
      remodelinfo =
 +
        remodelinfo ..
 +
        " " ..
 +
          string.format(
 +
            "[[File:Item Icon Latest Overseas Warship Technology.png|18px|Latest Overseas Warship Technology|link=Latest Overseas Warship Technology]] %d",
 +
            ship.overseastech
 
           )
 
           )
 
     end
 
     end
Line 417: Line 460:     
local function renderCategories(ship)
 
local function renderCategories(ship)
   local categories = "[[Category:Ships]][[Category:" .. ship["class"] .. "]][[Category:" .. ship["type"] .. "s]]"
+
   local categories = "[[Category:Ships]]"
 +
  if notNil(ship["class"]) then
 +
  categories = categories .. "[[Category:" .. ship["class"] .. "]]"
 +
  end
 +
  if notNil(ship["type"]) then
 +
  categories = categories .. "[[Category:" .. ship["type"] .. "s]]"
 +
  end
 
   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 444: Line 493:  
   local reversionlvheader = ""
 
   local reversionlvheader = ""
 
   local reversionlvdata = ""
 
   local reversionlvdata = ""
   if ship["reversionlv"] ~= nil and ship["reversionlv"] ~= "" then
+
   if notNil(ship["reversionlv"]) then
 
     reversionlvheader = "Reversion Level"
 
     reversionlvheader = "Reversion Level"
 
     reversionlvdata = ship["reversionlv"]
 
     reversionlvdata = ship["reversionlv"]
Line 566: Line 615:  
   local ship = Ship(shipsById[(U.find(shipsByNo, ShipData[key] or key, "name") or {}).id] or key)
 
   local ship = Ship(shipsById[(U.find(shipsByNo, ShipData[key] or key, "name") or {}).id] or key)
 
   local data = {}
 
   local data = {}
   data.id = ship:id() or '???'
+
   data.id = ship:id() or "??"
 
   data.no = ship:true_id()
 
   data.no = ship:true_id()
 
   data.name = {ship:japanese_name() or "", ship:reading() or "", ship:name() or ""}
 
   data.name = {ship:japanese_name() or "", ship:reading() or "", ship:name() or ""}
 
   local class = ship:class()
 
   local class = ship:class()
   data.class = class and class:name() or "???"
+
   data.class = class and class:name() or "??"
 
   data.display_class = ship._display_class
 
   data.display_class = ship._display_class
 
   data.type = ship:formatted_type() or ""
 
   data.type = ship:formatted_type() or ""
Line 587: Line 636:  
   data.aircraft = {}
 
   data.aircraft = {}
 
   data.equip = {}
 
   data.equip = {}
   for _, v in ipairs(ship._equipment) do
+
   for _, v in ipairs(ship._equipment or {}) 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.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 "")
 
     table.insert(data.aircraft, v.size or "")
Line 624: Line 673:  
   data.remodelarmmat = trueIsOne(ship._remodel_armament)
 
   data.remodelarmmat = trueIsOne(ship._remodel_armament)
 
   data.remodelboiler = trueIsOne(ship._remodel_boiler)
 
   data.remodelboiler = trueIsOne(ship._remodel_boiler)
 +
  data.overseastech  = trueIsOne(ship._remodel_overseas)
 
   data.remodeldevmat = trueIsOne(ship._remodel_development_material)
 
   data.remodeldevmat = trueIsOne(ship._remodel_development_material)
 
   data.remodelconmat = trueIsOne(ship._remodel_construction_material)
 
   data.remodelconmat = trueIsOne(ship._remodel_construction_material)
7,212

edits