| Line 29: |
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 | | end |
| | local function getScaledStat(baseStat, maxStat, level) | | local function getScaledStat(baseStat, maxStat, level) |
| | return math.floor((maxStat-baseStat) /99 * level + baseStat) | | return math.floor((maxStat-baseStat) /99 * level + baseStat) |
| | + | end |
| | + | local function notNil(value) |
| | + | return value ~= nil and value ~= "" and value ~= "??" |
| | end | | end |
| | | | |
| Line 116: |
Line 119: |
| | ship.type == "Light Carrier" and type(ship.asw) == "table" and type(ship.asw[1]) == "number" and ship.asw[1] > 0 | | ship.type == "Light Carrier" and type(ship.asw) == "table" and type(ship.asw[1]) == "number" and ship.asw[1] > 0 |
| | local shipType = | | local shipType = |
| − | isCVE and string.format('<span class="explain" title="CVE"></span>', ship.type) or | + | isCVE and string.format('<span class="explain" title="CVE">%s[[Category:Escort Carriers]]</span>', ship.type) or |
| | 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>" |
| Line 131: |
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 161: |
Line 164: |
| | -- Evasion & AA | | -- Evasion & AA |
| | local Evasioninfo = statLabel .. "EVA [[File:IcoEvasion.png|Evasion]]</th>" .. statBox | | local Evasioninfo = statLabel .. "EVA [[File:IcoEvasion.png|Evasion]]</th>" .. statBox |
| − | if ship["remodellv"] ~= nil and ship["remodellv"] ~= "" then | + | if notNil(ship["evasion"][1]) and notNil(ship["evasion"][2]) then |
| − | Evasioninfo = Evasioninfo .. formatTooltip(ship["evasion"][1], U.format{RemodelLevelStatValueText, value = getScaledStat(ship["evasion"][1], ship["evasion"][2], ship["remodellv"])}) .. "→"
| + | 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 | | else |
| − | Evasioninfo = Evasioninfo .. ship["evasion"][1] .. "→"
| + | Evasioninfo = Evasioninfo .. ship["evasion"][1] .. "→" .. ship["evasion"][2] |
| | end | | end |
| − | Evasioninfo = Evasioninfo .. formatTooltip(ship["evasion"][2], U.format{MarriedMaxTemplate, value = getScaledStat(ship["evasion"][1], ship["evasion"][2], DataCaps.ship_level)}) .. "</td>"
| |
| | 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 180: |
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 |
| − | if ship["remodellv"] ~= nil and ship["remodellv"] ~= "" then
| + | ASWinfo = ASWinfo .. ship["asw"][1] .. "→" .. ship["asw"][2] |
| − | 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} )
| |
| | end | | end |
| | local row8 = "<tr>" .. Planeinfo .. ASWinfo .. "</tr>" | | local row8 = "<tr>" .. Planeinfo .. ASWinfo .. "</tr>" |
| Line 193: |
Line 202: |
| | 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 = statLabel .. "LOS [[File:IcoLOS.png|Line of Sight]]</th>" .. statBox | | local LOSinfo = statLabel .. "LOS [[File:IcoLOS.png|Line of Sight]]</th>" .. statBox |
| − | if ship["remodellv"] ~= nil and ship["remodellv"] ~= "" then | + | if notNil(ship["los"][1]) and notNil(ship["los"][2]) then |
| − | LOSinfo = LOSinfo .. formatTooltip(ship["los"][1], U.format{RemodelLevelStatValueText, value = getScaledStat(ship["los"][1], ship["los"][2], ship["remodellv"])}) .. "→"
| + | 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 | | else |
| − | LOSinfo = LOSinfo .. ship["los"][1] .. "→"
| + | LOSinfo = LOSinfo .. ship["los"][1] .. "→" .. ship["los"][2] |
| | end | | end |
| − | LOSinfo = LOSinfo .. formatTooltip(ship["los"][2], U.format{MarriedMaxTemplate, value = getScaledStat(ship["los"][1], ship["los"][2], DataCaps.ship_level)}) .. "</td>"
| |
| | local row9 = "<tr>" .. Speedinfo .. LOSinfo .. "</tr>" | | local row9 = "<tr>" .. Speedinfo .. LOSinfo .. "</tr>" |
| | -- Range & Luck | | -- Range & Luck |
| Line 284: |
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 293: |
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 448: |
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 454: |
Line 472: |
| | if ship["seiyuu"] ~= "Unknown" and ship["seiyuu"] ~= "" then | | if ship["seiyuu"] ~= "Unknown" and ship["seiyuu"] ~= "" then |
| | categories = categories .. "[[Category:" .. ship["seiyuu"] .. "]]" | | categories = categories .. "[[Category:" .. ship["seiyuu"] .. "]]" |
| − | end
| |
| − | if ship.type == "Light Carrier" and type(ship.asw) == "table" and type(ship.asw[1]) == "number" and ship.asw[1] > 0 then
| |
| − | categories = categories .. "[[Category:Escort Carriers]]"
| |
| | end | | end |
| | return categories | | return categories |
| Line 478: |
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 600: |
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 621: |
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 "") |