- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:KanmusuModule"
Jump to navigation
Jump to search
(Remodel reversion data now displayed. "Reversible to (remodel)" cell width will be fixed tomorrow (intended 100% width).) |
Jigaraphale (talk | contribs) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 111: | 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;">' .. | + | 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 280: | Line 281: | ||
remodelinfo = | remodelinfo = | ||
string.format( | string.format( | ||
− | "[[File: | + | "[[File:IcoAmmo.png|18px|Ammo]] %d [[File:IcoSteel.png|18px|Steel]] %d", |
− | ship.remodelreq[ | + | ship.remodelreq[2], |
− | ship.remodelreq[ | + | ship.remodelreq[1] |
) | ) | ||
if ship.remodelbp then | if ship.remodelbp then | ||
Line 305: | 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.overseastech or ship.remodelscrew then |
remodelinfo = remodelinfo .. "<br>" | remodelinfo = remodelinfo .. "<br>" | ||
end | end | ||
Line 351: | Line 352: | ||
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 | ||
+ | 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 423: | Line 437: | ||
local function renderReversion(ship) --Copy paste mess by Chocolatecravinghobo. Shows information/cost for models that remodel/revert to a previous remodel | 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 reversionHeader = "" | ||
local reversionStyle = "" | local reversionStyle = "" | ||
local reversionHeader = | local reversionHeader = | ||
− | '<th 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>" | + | '<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 reversionStyle = '<td style="white-space: nowrap; text-align: center; vertical-align: baseline;">' | ||
local RscHeader = | local RscHeader = | ||
Line 442: | Line 461: | ||
reversioninfo = | reversioninfo = | ||
string.format( | string.format( | ||
− | "[[File: | + | "[[File:IcoAmmo.png|18px|Ammo]] %d [[File:IcoSteel.png|18px|Steel]] %d", |
− | ship.reversionreq[ | + | ship.reversionreq[2], |
− | ship.reversionreq[ | + | ship.reversionreq[1] |
) | ) | ||
if ship.reversionbp then | if ship.reversionbp then | ||
Line 467: | Line 486: | ||
string.format("[[File:Item Icon Action Report.png|25px|Action Report|link=Action Report]] %d", ship.reversionar) | string.format("[[File:Item Icon Action Report.png|25px|Action Report|link=Action Report]] %d", ship.reversionar) | ||
end | end | ||
− | if ship.reversiondevmat or ship.reversionconmat or ship.reversiongunmat or ship.reversionairmat then | + | 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>" | reversioninfo = reversioninfo .. "<br>" | ||
end | end | ||
Line 513: | Line 532: | ||
ship.reversionboiler | 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 | ||
end | end | ||
Line 548: | Line 573: | ||
local function loadShipData(key) | local function loadShipData(key) | ||
− | local ship = Ship(shipsById[(U.find(shipsByNo, ShipData[key] or key, "name") or {}).id]) | + | 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 '???' | ||
Line 554: | Line 579: | ||
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 | + | data.class = class and class:name() or "???" |
+ | data.display_class = ship._display_class | ||
data.type = ship:formatted_type() or "" | data.type = ship:formatted_type() or "" | ||
data.spd = ship:formatted_speed() or "" | data.spd = ship:formatted_speed() or "" | ||
Line 606: | Line 632: | ||
data.remodelairmat = trueIsOne(ship._remodel_airmat) | data.remodelairmat = trueIsOne(ship._remodel_airmat) | ||
data.remodelarmmat = trueIsOne(ship._remodel_armament) | data.remodelarmmat = trueIsOne(ship._remodel_armament) | ||
+ | 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) | ||
− | data. | + | data.remodelscrew = trueIsOne(ship._remodel_screw) |
data.reversible = trueIsOne(ship._reversible) | data.reversible = trueIsOne(ship._reversible) | ||
data.reversionto = ship:remodel_to() or "" | data.reversionto = ship:remodel_to() or "" | ||
data.reversionto = data.reversionto:gsub("/", " ") | data.reversionto = data.reversionto:gsub("/", " ") | ||
+ | data.reversionbp = trueIsOne(ship._remodel_to_blueprint) | ||
data.reversionlv = ship:remodel_to_level() or "" | 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.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.reversionbp = trueIsOne(ship._remodel_to_blueprint) | ||
data.reversioncatapult = trueIsOne(ship._remodel_to_catapult) | 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.reversiondevmat = trueIsOne(ship._remodel_to_development_material) | ||
data.reversionconmat = trueIsOne(ship._remodel_to_construction_material) | data.reversionconmat = trueIsOne(ship._remodel_to_construction_material) | ||
+ | data.reversionscrew = trueIsOne(ship._remodel_to_screw) | ||
return data | return data | ||
end | end |
Latest revision as of 22:35, 27 July 2024
Documentation for this module may be created at Module:KanmusuModule/doc
local U = require("Module:Core")
-- Some formatting
local function formatBuildtime(minutes)
return U.format {"${hours}:${minutes:2}", hours = math.floor(minutes / 60), minutes = minutes % 60}
end
local function formatTooltip(content, title)
return tostring(mw.html.create("span"):attr("title", title):addClass("explain"):wikitext(content))
end
-- Some calculations
local function getTotalAircraft(ship)
local total = 0
if ship.aircraft ~= "" then
for i, _ 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
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])
end
-- The ship infobox stuff, legacy
local function renderStats(ship)
local shipName = ship.name[3]
local CardImg = '<div class="top-image">[[File:Ship Card ' .. shipName .. ".png|218x300px|link=]]</div>"
local CardDmgImg = '<div class="bottom-image">[[File:Ship Card ' .. shipName .. " Damaged.png|218x300px|link=]]</div>"
local BannerImg = '<div class="top-image">[[File:Ship Banner ' .. shipName .. ".png|link=]]</div>"
local BannerDmgImg = '<div class="bottom-image">[[File:Ship Banner ' .. shipName .. " Damaged.png|link=]]</div>"
local Cards =
'<td rowspan="10" class="double-image" style="width:218px;height:300px">' .. CardImg .. CardDmgImg .. "</td>"
local Banners =
'<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 row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNoText .. "</th>" .. Banners .. "</tr>"
-- Formatting Japanese
local kanji, form
local formNum = mw.ustring.find(ship["name"][1], "[乙改甲航]")
if formNum == nil then
if mw.ustring.find(ship["name"][1], "%szwei") ~= nil then
formNum = mw.ustring.find(ship["name"][1], "%szwei")
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = " zwei"
elseif mw.ustring.find(ship["name"][1], "%sdrei") ~= nil then
formNum = mw.ustring.find(ship["name"][1], "%sdrei")
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = " drei"
elseif mw.ustring.find(ship["name"][1], "%sdue") ~= nil then
formNum = mw.ustring.find(ship["name"][1], "%sdue")
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = " due"
elseif mw.ustring.find(ship["name"][1], "%sдва") ~= nil then
formNum = mw.ustring.find(ship["name"][1], "%sдва")
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = " два"
elseif mw.ustring.find(ship["name"][1], "%sMk.II") ~= nil then
if mw.ustring.find(ship["name"][1], "%sMk.II Mod.2") ~= nil then
formNum = mw.ustring.find(ship["name"][1], "%sMk.II Mod.2")
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = " Mk.II Mod.2"
else
formNum = mw.ustring.find(ship["name"][1], "%sMk.II")
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = " Mk.II"
end
elseif mw.ustring.find(ship["name"][1], "%sреволюция") ~= nil then -- Gangut "Kai" exception
kanji = mw.text.split(ship["name"][1], "%s")[1] .. "<br/>" .. mw.text.split(ship["name"][1], "%s")[2]
form = ""
else
kanji = ship["name"][1]
form = ""
end
else
kanji = mw.ustring.sub(ship["name"][1], 1, formNum - 1)
form = mw.ustring.sub(ship["name"][1], formNum, -1)
end
local JaName = ""
if
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"
then -- Russian ship markup
JaName =
'<ruby lang="ru"><rb>' ..
kanji ..
'<span lang="ru">' ..
form .. "</span>" .. '</rb><rp> (</rp><rt lang="ja">' .. ship["name"][2] .. "</rt><rp>) </rp></ruby>"
else
if ship.name[2] then
JaName =
'<ruby lang="ja"><rb>' ..
kanji .. "<span>" .. form .. "</span>" .. "</rb><rp> (</rp><rt>" .. ship.name[2] .. "</rt><rp>) </rp></ruby>"
else
JaName = '<ruby lang="ja"><rb>' .. kanji .. "<span>" .. form .. "</span>" .. "</rb></ruby>"
end
end
-- Summary of basic ship info
local isCVE =
ship.type == "Light Carrier" and type(ship.asw) == "table" and type(ship.asw[1]) == "number" and ship.asw[1] > 0
local shipType =
isCVE and string.format('<span class="explain" title="CVE">%s[[Category:Escort Carriers]]</span>', ship.type) or
ship.type
local row2 = '<tr><th colspan="2">' .. JaName .. '</th><th colspan="2">' .. ship.name[3] .. "</th></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 =
'<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>'
-- Ship stats table
local statLabel =
'<th style="width: 65px; {{border-radius|12px 4px 4px 12px}} padding-left: 5px; padding-right: 5px; background-color: #eae1d1; color: #a3965c; text-align: right; vertical-align: baseline;">'
local statBox =
'<td style="{{border-radius|4px 12px 12px 4px}} padding-left: 5px; padding-right: 5px; border: 1px solid #a3965c; text-align: left; vertical-align: baseline;">'
local hp = ship["hp"][1]
local maxHp = ship["hp"][2]
local HPinfo
if maxHp then
local marriedHp = getMarriedHp(hp, maxHp)
local maxModHp = math.min(hp + 2, maxHp)
local maxModMarriedHp = math.min(marriedHp + 2, maxHp)
local hpSpan1 = hp == maxModHp and hp or formatTooltip(hp, string.format("%d with HP modernization", maxModHp))
local hpSpan2 =
formatTooltip(
marriedHp,
marriedHp == maxModMarriedHp and "Married" or string.format("Married, %d with HP modernization", maxModMarriedHp)
)
HPinfo = statLabel .. "HP [[File:IcoHP.png|HP]]</th>" .. statBox .. hpSpan1 .. "→" .. hpSpan2 .. "</td>"
else
HPinfo = statLabel .. "HP [[File:IcoHP.png|HP]]</th>" .. statBox .. hp .. "</td>"
end
local FPinfo =
statLabel .. "FP [[File:IcoAtk.png|18px|Firepower]]</th>" .. statBox .. ship["fp"][1] .. "→" .. ship["fp"][2] .. "</td>"
local row5 = "<tr>" .. HPinfo .. FPinfo .. "</tr>"
-- Armor & Torpedo
local Armorinfo =
statLabel ..
"ARM [[File:IcoArmor.png|Armor]]</th>" .. statBox .. ship["armor"][1] .. "→" .. ship["armor"][2] .. "</td>"
local Torpedoinfo = statLabel .. "TORP[[File:IcoTorpedo.png|Torpedo]]</th>" .. statBox
if ship["torpedo"] == 0 then
Torpedoinfo = Torpedoinfo .. ship["torpedo"]
else
Torpedoinfo = Torpedoinfo .. ship["torpedo"][1] .. "→" .. ship["torpedo"][2]
end
local row6 = "<tr>" .. Armorinfo .. Torpedoinfo .. "</tr>"
-- Evasion & AA
local Evasioninfo =
statLabel ..
"EVA [[File:IcoEvasion.png|Evasion]]</th>" .. statBox .. ship["evasion"][1] .. "→" .. ship["evasion"][2] .. "</td>"
local AAinfo = statLabel .. "AA [[File:IcoAA.png|Anti-Air]]</th>" .. statBox
if ship["aa"] == 0 then
AAinfo = AAinfo .. ship["aa"]
else
AAinfo = AAinfo .. ship["aa"][1] .. "→" .. ship["aa"][2]
end
local row7 = "<tr>" .. Evasioninfo .. AAinfo .. "</tr>"
-- Planes & ASW
local aircraftTotal = getTotalAircraft(ship)
local Planeinfo = statLabel .. "PLA [[File:IcoAircraft.png|Aircraft]]</th>" .. statBox .. aircraftTotal .. "</td>"
local ASWinfo = statLabel .. "ASW [[File:IcoASW.png|Anti-Submarine Warfare]]</th>" .. statBox
if ship["asw"] == 0 then
ASWinfo = ASWinfo .. ship["asw"]
else
ASWinfo = ASWinfo .. ship["asw"][1] .. "→" .. ship["asw"][2]
end
local row8 = "<tr>" .. Planeinfo .. ASWinfo .. "</tr>"
-- Speed & LOS
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 .. ship["los"][1] .. "→" .. ship["los"][2] .. "</td>"
local row9 = "<tr>" .. Speedinfo .. LOSinfo .. "</tr>"
-- Range & Luck
local Rangeinfo = statLabel .. "RGE [[File:IcoRange.png|Range]]</th>" .. statBox .. ship["range"] .. "</td>"
local Luckinfo =
statLabel .. "LUK [[File:IcoLuck.png|Luck]]</th>" .. statBox .. ship["luck"][1] .. "→" .. ship["luck"][2] .. "</td>"
local row10 = "<tr>" .. Rangeinfo .. Luckinfo .. "</tr>"
local StatTable =
"<table>" .. row1 .. row2 .. row3 .. row4 .. row5 .. row6 .. row7 .. row8 .. row9 .. row10 .. "</table>"
return StatTable
end
local function renderEquipment(ship)
local equipHeader = ""
local planeStyle = '<td style="width: 25%; white-space: nowrap; text-align: center; vertical-align: top;">'
local equipStyle = ""
if ship["aircraft"] ~= "" then
local equipHeader1 =
'<th style="width: 25%; white-space: nowrap; {{border-radius|12px 4px 4px 12px}} background-color: #efe6d7; color: #a3965c;">Aircraft</th>'
local equipHeader2 =
'<th style="width: 75%; white-space: nowrap; {{border-radius|4px 12px 12px 4px}} background-color: #efe6d7; color: #a3965c; vertical-align: baseline;">Equipment</th>'
equipHeader = equipHeader1 .. equipHeader2
equipStyle = '<td style="width: 75%; max-width: 375px; text-align: center; vertical-align: baseline;">'
else
equipHeader =
'<th style="white-space: nowrap; {{border-radius|12px 12px 12px 12px}} background-color: #efe6d7; color: #a3965c; vertical-align: baseline;">Equipment</th>'
equipStyle = '<td style="white-space: nowrap; text-align: center; vertical-align: baseline;">'
end
local numRows = math.max(4, U.isize(ship["equip"]))
local equipTable = ""
for i = 1, numRows, 1 do
local equipRow = "<tr>"
if ship["aircraft"] ~= "" then
if ship["aircraft"][i] ~= nil then
equipRow = equipRow .. planeStyle .. ship["aircraft"][i] .. "</td>" .. equipStyle
else
equipRow = equipRow .. planeStyle .. "</td>" .. equipStyle
end
if ship["equip"] ~= "" then
if ship["equip"][i] == "" or ship["equip"][i] == "Unequipped" then
equipRow = equipRow .. "-Unequipped-</td></tr>"
elseif ship["equip"][i] == nil then
equipRow = equipRow .. "''-Locked-''</td></tr>"
else
if string.find(ship["equip"][i], "%★") then
local a, b = string.match(ship["equip"][i], "^(.+)★(.+)$")
equipRow = equipRow .. "[[" .. a .. "|" .. a .. "★" .. b .. "]]</td></tr>"
else
equipRow = equipRow .. "[[" .. ship["equip"][i] .. "]]</td></tr>"
end
end
else
equipRow = equipRow .. "''-Locked-''</td></tr>"
end
else
equipRow = equipRow .. equipStyle
if ship["equip"] ~= "" then
if ship["equip"][i] == "" or ship["equip"][i] == "Unequipped" then
equipRow = equipRow .. "-Unequipped-</td></tr>"
elseif ship["equip"][i] == nil then
equipRow = equipRow .. "''Locked''</td></tr>"
else
if string.find(ship["equip"][i], "%★") then
local a, b = string.match(ship["equip"][i], "^(.+)★(.+)$")
equipRow = equipRow .. "[[" .. a .. "|" .. a .. "★" .. b .. "]]</td></tr>"
else
equipRow = equipRow .. "[[" .. ship["equip"][i] .. "]]</td></tr>"
end
end
else
equipRow = equipRow .. "''Locked''</td></tr>"
end
end
equipTable = equipTable .. equipRow
end
return '<table style="width: 100%">' .. equipHeader .. equipTable .. "</table>"
end
local function renderModernization(ship)
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 RscData2 = '<td colspan="3" style="width: 75%; white-space: nowrap; text-align: center;">'
-- Construction info
local constrheader = ""
local constrdata = ""
if ship["remodellv"] ~= nil and ship["remodellv"] ~= "" then
constrheader = "Remodel Level"
constrdata = ship["remodellv"]
else
constrheader = '<span class="explain-dash" title="h:mm">Build Time</span>'
constrdata =
type(ship.buildtime) ~= "table" and "??" or
string.format(
"%s (%s)",
formatBuildtime(ship.buildtime[1]),
ship.buildtime[2] and ship.buildtime[3] and "Normal, LSC" or ship.buildtime[2] and "Normal" or
ship.buildtime[3] and "LSC" or
"Unbuildable"
)
end
local remodelinfo = ""
if ship.remodelreq and ship.remodelreq ~= "" then
remodelinfo =
string.format(
"[[File:IcoAmmo.png|18px|Ammo]] %d [[File:IcoSteel.png|18px|Steel]] %d",
ship.remodelreq[2],
ship.remodelreq[1]
)
if ship.remodelbp then
remodelinfo =
remodelinfo ..
" " ..
string.format("[[File:Item Icon Remodel Blueprint.png|25px|Blueprint|link=Blueprints]] %d", ship.remodelbp)
end
if ship.remodelcatapult then
remodelinfo =
remodelinfo ..
" " ..
string.format(
"[[File:Item Icon Prototype Flight Deck Catapult.png|25px|Prototype Flight Deck Catapult|link=Prototype Flight Deck Catapult]] %d",
ship.remodelcatapult
)
end
if ship.remodelar then
remodelinfo =
remodelinfo ..
" " ..
string.format("[[File:Item Icon Action Report.png|25px|Action Report|link=Action Report]] %d", ship.remodelar)
end
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>"
end
if ship.remodeldevmat then
remodelinfo =
remodelinfo .. " " .. string.format("[[File:IcoDevmat.png|18px|Development Material]] %d", ship.remodeldevmat)
end
if ship.remodelconmat then
remodelinfo =
remodelinfo .. " " .. string.format("[[File:IcoConmat.png|18px|Construction Material]] %d", ship.remodelconmat)
end
if ship.remodelgunmat then
remodelinfo =
remodelinfo ..
" " ..
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.remodelgunmat
)
end
if ship.remodelairmat then
remodelinfo =
remodelinfo ..
" " ..
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.remodelairmat
)
end
if ship.remodelarmmat then
remodelinfo =
remodelinfo ..
" " ..
string.format(
"[[File:Item Icon New Model Armament Material.png|18px|New Model Armament Material|link=New Model Armament Material]] %d",
ship.remodelarmmat
)
end
if ship.remodelboiler then
remodelinfo =
remodelinfo ..
" " ..
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.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
if ship.remodelscrew then
remodelinfo =
remodelinfo .. " " .. string.format("[[File:Item Icon Improvement Material.png|18px|Improvement Material|link=Improvement]] %d", ship.remodelscrew)
end
end
-- Construction & Remodel
local row11 = ""
if constrheader == "Build Time" then
row11 =
"<tr>" .. RscHeader .. constrheader .. "</th>" .. RscData .. constrdata .. '</td><td colspan="2"> </td></tr>'
else
row11 =
"<tr>" ..
RscHeader ..
constrheader ..
"</th>" ..
RscData ..
constrdata .. "</td>" .. RscHeader .. "Remodel Req</th>" .. RscData .. remodelinfo .. "</td></tr>"
end
-- Consumption
local consfuel = "[[File:IcoFuel.png|18px|Fuel]] " .. ship["consumption"][1]
local consammo = "[[File:IcoAmmo.png|18px|Ammo]] " .. ship["consumption"][2]
local row12 = "<tr>" .. RscHeader .. "Consumption</th>" .. RscData .. consfuel .. " " .. consammo .. "</td>"
-- Scrap Info
local scrapfuel = "[[File:IcoFuel.png|18px|Fuel]] " .. ship["dismantle"][1]
local scrapammo = "[[File:IcoAmmo.png|18px|Ammo]] " .. ship["dismantle"][2]
local scrapsteel = "[[File:IcoSteel.png|18px|Steel]] " .. ship["dismantle"][3]
local scrapbauxite = "[[File:IcoBauxite.png|18px|Bauxite]] " .. ship["dismantle"][4]
local scrapinfo = scrapfuel .. " " .. scrapammo .. " " .. scrapsteel .. " " .. scrapbauxite
local row12 = row12 .. RscHeader .. "Dismantle</th>" .. RscData .. scrapinfo .. "</td></tr>"
-- Modernization
local modFP = "[[File:IcoAtkRemodel.png|25px|Firepower]] " .. ship["modernization"][1]
local modTorp = "[[File:IcoTorpedoRemodel.png|25px|Torpedo]] " .. ship["modernization"][2]
local modAA = "[[File:IcoAARemodel.png|25px|Anti-Air]] " .. ship["modernization"][3]
local modArmor = "[[File:IcoArmorRemodel.png|25px|Armor]] " .. ship["modernization"][4]
local modLuck = ""
if ship["modernization"][5] ~= nil and ship["modernization"][5] ~= "" then
modLuck = "[[File:IcoLuckRemodel.png|25px|Luck]] " .. ship["modernization"][5]
end
local modInfo = modFP .. " " .. modTorp .. " " .. modAA .. " " .. modArmor
if modLuck ~= "" then
modInfo = modInfo .. " " .. modLuck
end
local row13 = "<tr>" .. RscHeader .. "Modernization</th>" .. RscData2 .. modInfo .. "</td></tr>"
return row13 .. row11 .. row12
end
local function renderArtists(ship)
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 illustrator =
ship["artist"] ~= "Unknown" and ship["artist"] ~= "" and
("[[:Category:" .. ship["artist"] .. "|" .. ship["artist"] .. "]]") or
"Unknown"
local voiceactor =
ship["seiyuu"] ~= "Unknown" and ship["seiyuu"] ~= "" and
("[[:Category:" .. ship["seiyuu"] .. "|" .. ship["seiyuu"] .. "]]") or
"Unknown"
return RscHeader ..
"Illustrator</th>" .. RscData .. illustrator .. "</td>" .. RscHeader .. "Seiyuu</th>" .. RscData .. voiceactor .. "</td>"
end
local function renderCategories(ship)
local categories = "[[Category:Ships]][[Category:" .. ship["class"] .. "]][[Category:" .. ship["type"] .. "s]]"
if ship["artist"] ~= "Unknown" and ship["artist"] ~= "" then
categories = categories .. "[[Category:" .. ship["artist"] .. "]]"
end
if ship["seiyuu"] ~= "Unknown" and ship["seiyuu"] ~= "" then
categories = categories .. "[[Category:" .. ship["seiyuu"] .. "]]"
end
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.overseastech = trueIsOne(ship._remodel_overseas)
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
local function render(frame)
local ship = loadShipData(frame.args[1])
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) ..
"</td></tr><tr><td>" ..
renderEquipment(ship) ..
'<table style="width:100%">' ..
renderModernization(ship) ..
renderArtists(ship) ..
renderReversion(ship) .. "</table></td></tr></table></div>" .. renderCategories(ship)
end
local function test()
return render({args = {"Brooklyn"}})
end
-- print(p.test())
return {KanmusuInfo = render, test = test}