มอดูล:KanmusuModule
This module page contains multiple functions that is used by several templates which will be listed below.
List of functions
shipmodule.KanmusuInfo(frame)
This function is used to build a Kanmusu info table on Kanmusu's respective page. This function will utilize Module:ShipDatabase which contains the main data of respective Kanmusu. It should be used with {{KanmusuInfo}} which will utilize this function instead of directly invoking this function.
Usage
Simply invoke the function with the code below:
{{#invoke:KanmusuModule|KanmusuInfo|<ID> or <Name>}}
- Highly preferable to use Kanmusu Sort ID instead of Kanmusu name
Kanmusu Sort ID will always have 3 digits, means that leading zero must be included into the ID if the Sort ID doesn't have 3 digits, for example 001
and 045
. The only exception is Mist1
to Mist3
.
shipmodule.RemodelBlueprintChk(blueprint)
This function is used as a sub-function to shipmodule.KanmusuInfo(frame)
. It will read the integer value and return whether the Kanmusu's remodel needs blueprint or not in string form.
Usage
Simply invoke the function with the code below:
{{#invoke:KanmusuModule|RemodelBlueprintChk|<integer value>}}
- This function is not intended to work independently and should be used by
shipmodule.KanmusuInfo(frame)
.
- This function is not intended to work independently and should be used by
shipmodule.KanmusuList(frame)
This function is used to list out all Kanmusu data in table format. This function will be planned to use with certain keywords in order to change how the list would be built. This function will also utilize Module:ShipDatabase just like shipmodule.KanmusuInfo(frame)
. It should be used with {{KanmusuList}} which will utilize this function instead of directly invoking this function.
Usage
Simply invoke the function with the code below:
{{#invoke:KanmusuModule|KanmusuList|<string, optional>|<max, optional>}}
- This function will display the full list if no string was entered. String will be used to determine what type of class the list will be displayed (in progress). If max is entered, max values of stats will be displayed, otherwise the base values will be printed.
shipmodule.KanmusuListEntry(id, printMax)
This function is used to list the data of the specific Kanmusu ID. It is intended to be used with shipmodule.KanmusuList(frame)
as this function is to be looped with the table-creating function which is within the shipmodule.KanmusuList(frame)
.
Usage
Simply invoke the function with the code below:
{{#invoke:KanmusuModule|KanmusuListEntry|<kanmusu sort id>|<true or false>}}
- This function will built with only
<tr>
and<td>
tags and it is not recommended to be used independently.
- This function will built with only
local shipmodule = {}
local shipdb = require("Module:ShipDatabase")
shipmodule.data = shipdb.KanmusuData
function shipmodule.getIDNum(frame)
local shipNum = frame.args[1]
-- Getting ship ID, number, & info
if (tonumber(string.sub(shipNum, 1, 3)) == nil and string.sub(shipNum, 1, 4) ~= "Mist" ) then -- if given a name instead of ID, this searches the db for the ship's corresponding ID
shipNum = shipdb.findID(frame)
end
return shipNum
end
function shipmodule.KanmusuInfo(frame) -- Kanmusu Info Template
local shipNum = shipmodule.getIDNum(frame)
local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " ไม่มีในฐานข้อมูล")
local upperTable = shipmodule.makeStatBox(frame)
local DetailTable = shipmodule.EquipmentBox(frame) .. shipmodule.ModernizationBox(frame) .. shipmodule.getArtVoice(frame)
local shipInfoBox = '<div style="display: inline-block; vertical-align: top;"><table style="{{border-radius|10px 10px 10px 10px}} border: 1px solid #aaaaaa; min-width: 495px">'
shipInfoBox = shipInfoBox .. '<tr><td>' .. upperTable .. '</td></tr>'
shipInfoBox = shipInfoBox .. '<tr><td>' .. DetailTable .. '</td></tr></table></div>' .. shipmodule.createCategories(frame)
return shipInfoBox
end
function shipmodule.makeStatBox(frame)
local shipNum = shipmodule.getIDNum(frame)
local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " ไม่มีในฐานข้อมูล")
-- Top half of infobox
-- Cards & Banners
local CardImg = '<div style="text-align: center;">[[File:KanMusu' .. shipNum .. 'Card.png|' .. shipmodule.data[shipNum]["name"][3] .. 'Card]]</div>'
local CardDmgImg = '<div style="text-align: center;">[[File:KanMusu' .. shipNum .. 'CardDmg.png|' .. shipmodule.data[shipNum]["name"][3] .. 'Damaged Card]]</div>'
local BannerImg = '<div style="text-align: center; width: 100%;">[[File:KanMusu' .. shipNum .. 'Banner.png|' .. shipmodule.data[shipNum]["name"][3] .. 'Banner|class=imageCenter]]</div>'
local BannerDmgImg = '<div style="text-align: center; width: 100%;">[[File:KanMusu' .. shipNum .. 'BannerDmg.png|' .. shipmodule.data[shipNum]["name"][3] .. 'Damaged Banner|class=imageCenter]]</div>'
local Cards = '<td rowspan="10" style="text-align: center;">' .. frame:extensionTag('slideshow', CardImg .. CardDmgImg, {sequence = 'forward', transition = 'fade', refresh = '10000'}) .. '</td>'
local Banners = '<td colspan="3" style="text-align: center;">' .. frame:extensionTag('slideshow', BannerImg .. BannerDmgImg, {sequence = 'forward', transition = 'fade', refresh = '10000'}) .. '</td>'
local row1 = '<tr>' .. Cards .. '<th style="text-align: center;">' .. shipNum .. '</th>' .. Banners .. '</tr>'
-- Formatting Japanese
local kanji, form
local formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "[乙改甲航]")
if formNum == nil then
if mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%szwei") ~= nil then
formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%szwei")
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = " zwei"
elseif mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sdrei") ~= nil then
formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sdrei")
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = " drei"
elseif mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sdue") ~= nil then
formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sdue")
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = " due"
elseif mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sдва") ~= nil then
formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sдва")
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = " два"
elseif mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sMk.II") ~= nil then
if mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sMk.II Mod.2") ~= nil then
formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sMk.II Mod.2")
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = " Mk.II Mod.2"
else
formNum = mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sMk.II")
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = " Mk.II"
end
elseif mw.ustring.find(shipmodule.data[shipNum]["name"][1], "%sреволюция") ~= nil then -- Gangut "Kai" exception
kanji = mw.text.split(shipmodule.data[shipNum]["name"][1], "%s")[1] .. '<br/>' .. mw.text.split(shipmodule.data[shipNum]["name"][1], "%s")[2]
form = ""
else
kanji = shipmodule.data[shipNum]["name"][1]
form = ""
end
else
kanji = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], 1, formNum - 1)
form = mw.ustring.sub(shipmodule.data[shipNum]["name"][1], formNum , -1)
end
local JaName = ""
if shipNum == "147" or shipNum == "311" or shipNum == "312" or shipNum == "313" or shipNum == "313a" or shipNum == "316" then --Russian ship markup
JaName = '<ruby lang="ru" xml:lang="ru"><rb>' .. kanji .. '</rb><rp> (</rp><rt lang="ja">' .. shipmodule.data[shipNum]["name"][2] .. '</rt><rp>) </rp></ruby>' .. frame:expandTemplate{ title = 'lang', args = { ru , form } }
else
JaName = frame:expandTemplate{ title = 'ruby-ja', args = { kanji , shipmodule.data[shipNum]["name"][2] } } .. frame:expandTemplate{ title = 'lang', args = { ja , form } }
end
-- Summary of basic ship info
local row2 = '<tr><th colspan="2">' .. JaName .. '</th><th colspan="2">' .. shipmodule.data[shipNum]["name"][3] .. '</th></tr>'
local row3 = '<tr><td colspan="4" style="text-align: center;">' .. shipmodule.data[shipNum]["type"] .. ' ชั้น' .. shipmodule.data[shipNum]["class"] .. '</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;">'
-- HP & FP
local HPinfo = statLabel .. 'HP [[File:IcoHP.png|HP]]</th>' .. statBox .. shipmodule.data[shipNum]["hp"][1] .. '→' .. shipmodule.data[shipNum]["hp"][2] .. '</td>'
local FPinfo = statLabel .. 'ATK [[File:IcoAtk.png|ปืนใหญ่]]</th>' .. statBox .. shipmodule.data[shipNum]["fp"][1] .. '→' .. shipmodule.data[shipNum]["fp"][2] .. '</td>'
local row5 = '<tr>' .. HPinfo .. FPinfo .. '</tr>'
-- Armor & Torpedo
local Armorinfo = statLabel .. 'DEF [[File:IcoArmor.png|เกราะ]]</th>' .. statBox .. shipmodule.data[shipNum]["armor"][1] .. '→' .. shipmodule.data[shipNum]["armor"][2] .. '</td>'
local Torpedoinfo = statLabel .. 'TORP [[File:IcoTorpedo.png|ตอร์ปิโด]]</th>' .. statBox
if shipmodule.data[shipNum]["torpedo"] == 0 then
Torpedoinfo = Torpedoinfo .. shipmodule.data[shipNum]["torpedo"]
else
Torpedoinfo = Torpedoinfo .. shipmodule.data[shipNum]["torpedo"][1] .. '→' .. shipmodule.data[shipNum]["torpedo"][2]
end
local row6 = '<tr>' .. Armorinfo .. Torpedoinfo .. '</tr>'
-- Evasion & AA
local Evasioninfo = statLabel .. 'EVA [[File:IcoEvasion.png|หลบหลีก]]</th>' .. statBox .. shipmodule.data[shipNum]["evasion"][1] .. '→' .. shipmodule.data[shipNum]["evasion"][2] .. '</td>'
local AAinfo = statLabel .. 'AA [[File:IcoAA.png|ต่อต้านอากาศยาน]]</th>' .. statBox
if shipmodule.data[shipNum]["aa"] == 0 then
AAinfo = AAinfo .. shipmodule.data[shipNum]["aa"]
else
AAinfo = AAinfo .. shipmodule.data[shipNum]["aa"][1] .. '→' .. shipmodule.data[shipNum]["aa"][2]
end
local row7 = '<tr>' .. Evasioninfo .. AAinfo .. '</tr>'
-- Planes & ASW
local aircraftTotal = 0
if shipmodule.data[shipNum]["aircraft"] ~= "" then
local aircraftslot = {0, 0, 0, 0}
for i = 1, 4, 1 do
if shipmodule.data[shipNum]["aircraft"][i] ~= nil then
aircraftslot[i] = shipmodule.data[shipNum]["aircraft"][i]
else
aircraftslot[i] = 0
end
end
aircraftTotal = aircraftslot[1] + aircraftslot[2] + aircraftslot[3] + aircraftslot[4]
else
aircraftTotal = 0
end
local Planeinfo = statLabel .. 'PLA [[File:IcoAircraft.png|เครื่องบิน]]</th>' .. statBox .. aircraftTotal .. '</td>'
local ASWinfo = statLabel .. 'ASW [[File:IcoASW.png|ต่อต้านเรือดำน้ำ]]</th>' .. statBox
if shipmodule.data[shipNum]["asw"] == 0 then
ASWinfo = ASWinfo .. shipmodule.data[shipNum]["asw"]
else
ASWinfo = ASWinfo .. shipmodule.data[shipNum]["asw"][1] .. '→' .. shipmodule.data[shipNum]["asw"][2]
end
local row8 = '<tr>' .. Planeinfo .. ASWinfo .. '</tr>'
-- Speed & LOS
local Speedinfo = statLabel .. 'SPD [[File:IcoSpeed.png|ความเร็ว]]</th>' .. statBox .. shipmodule.data[shipNum]["spd"] .. '</td>'
local LOSinfo = statLabel .. 'LOS [[File:IcoLOS.png|ค้นหาศัตรู]]</th>' .. statBox .. shipmodule.data[shipNum]["los"][1] .. '→' .. shipmodule.data[shipNum]["los"][2] .. '</td>'
local row9 = '<tr>' .. Speedinfo .. LOSinfo .. '</tr>'
-- Range & Luck
local Rangeinfo = statLabel .. 'RGE [[File:IcoRange.png|ระยะการยิง]]</th>' .. statBox .. shipmodule.data[shipNum]["range"] .. '</td>'
local Luckinfo = statLabel .. 'LUK [[File:IcoLuck.png|โชค]]</th>' .. statBox .. shipmodule.data[shipNum]["luck"][1] .. '→' .. shipmodule.data[shipNum]["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
function shipmodule.EquipmentBox(frame)
local shipNum = shipmodule.getIDNum(frame)
local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " ไม่มีในฐานข้อมูล")
-- Equipment table
local equipHeader = ''
local planeStyle = '<td style="width: 25%; white-space: nowrap; text-align: center; vertical-align: top;">'
local equipStyle = ''
if shipmodule.data[shipNum]["aircraft"] ~= "" then
equipHeader1 = '<th style="width: 25%; white-space: nowrap; {{border-radius|12px 4px 4px 12px}} background-color: #efe6d7; color: #a3965c;">เครื่องบิน</th>'
equipHeader2 = '<th style="width: 75%; white-space: nowrap; {{border-radius|4px 12px 12px 4px}} background-color: #efe6d7; color: #a3965c; vertical-align: baseline;">อุปกรณ์</th>'
equipHeader = equipHeader1 .. equipHeader2
equipStyle = '<td style="width: 75%; white-space: nowrap; 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;">อุปกรณ์</th>'
equipStyle = '<td style="white-space: nowrap; text-align: center; vertical-align: baseline;">'
end
local numRows = 4
-- 346 Musashi Kai Ni
-- 353 Ise Kai Ni
if shipNum == "346" or shipNum == "353" then
numRows = 5
end
local equipTable = ''
for i = 1, numRows, 1 do
local equipRow = '<tr>'
if shipmodule.data[shipNum]["aircraft"] ~= "" then
if shipmodule.data[shipNum]["aircraft"][i] ~= nil then
equipRow = equipRow .. planeStyle .. shipmodule.data[shipNum]["aircraft"][i] .. '</td>' .. equipStyle
else
equipRow = equipRow .. planeStyle .. '</td>' .. equipStyle
end
if shipmodule.data[shipNum]["equip"] ~= "" then
if shipmodule.data[shipNum]["equip"][i] == "" or shipmodule.data[shipNum]["equip"][i] == "ว่าง" then
equipRow = equipRow .. '- ว่าง -</td></tr>'
elseif shipmodule.data[shipNum]["equip"][i] == nil then
equipRow = equipRow .. '\'\'- ล๊อค -\'\'</td></tr>'
else
if string.find(shipmodule.data[shipNum]["equip"][i], "%★") then
a,b = string.match(shipmodule.data[shipNum]["equip"][i], "^(.+)★(.+)$")
equipRow = equipRow .. '[[' .. a .. '|' .. a .. '★' .. b .. ']]</td></tr>'
else
equipRow = equipRow .. '[[' .. shipmodule.data[shipNum]["equip"][i] .. ']]</td></tr>'
end
end
else
equipRow = equipRow .. '\'\'-Locked-\'\'</td></tr>'
end
else
equipRow = equipRow .. equipStyle
if shipmodule.data[shipNum]["equip"] ~= "" then
if shipmodule.data[shipNum]["equip"][i] == "" or shipmodule.data[shipNum]["equip"][i] == "ว่าง" then
equipRow = equipRow .. '- ว่าง -</td></tr>'
elseif shipmodule.data[shipNum]["equip"][i] == nil then
equipRow = equipRow .. '\'\'ล๊อค\'\'</td></tr>'
else
if string.find(shipmodule.data[shipNum]["equip"][i], "%★") then
a,b = string.match(shipmodule.data[shipNum]["equip"][i], "^(.+)★(.+)$")
equipRow = equipRow .. '[[' .. a .. '|' .. a .. '★' .. b .. ']]</td></tr>'
else
equipRow = equipRow .. '[[' .. shipmodule.data[shipNum]["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
function shipmodule.ModernizationBox(frame)
local shipNum = shipmodule.getIDNum(frame)
local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " ไม่มีในฐานข้อมูล")
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 shipmodule.data[shipNum]["remodellv"] ~= nil and shipmodule.data[shipNum]["remodellv"] ~= "" then
constrheader = 'เลเวลที่รีโมเดลได้'
constrdata = shipmodule.data[shipNum]["remodellv"]
else
constrheader = 'เวลาในการสร้าง'
if shipmodule.data[shipNum]["buildtime"] == nil or shipmodule.data[shipNum]["buildtime"] == "" then
constrdata = 'สร้างไม่ได้'
else
constrdata = shipmodule.data[shipNum]["buildtime"]
end
end
-- Remodel info
local remodelsteel = '[[File:IcoSteel.png|18px|เหล็ก]]'
local remodelammo = '[[File:IcoAmmo.png|18px|กระสุน]]'
local remodelblueprint = shipmodule.data[shipNum]["remodelreq"][3]
local remodelinfo = ''
if shipmodule.data[shipNum]["remodelreq"] ~= "" then
remodelsteel = remodelsteel .. ' ' .. shipmodule.data[shipNum]["remodelreq"][1]
remodelammo = remodelammo .. ' ' .. shipmodule.data[shipNum]["remodelreq"][2]
remodelinfo = remodelsteel .. ' ' .. remodelammo
if shipmodule.data[shipNum]["remodelreq"][3] ~= nil then
remodelinfo = remodelinfo .. ' ' .. shipmodule.RemodelBlueprintChk(remodelblueprint)
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 .. 'รีโมเดล</th>' .. RscData .. remodelinfo .. '</td></tr>'
end
-- Consumption
local consfuel = '[[File:IcoFuel.png|18px|น้ำมัน]] ' .. shipmodule.data[shipNum]["consumption"][1]
local consammo = '[[File:IcoAmmo.png|18px|กระสุน]] ' .. shipmodule.data[shipNum]["consumption"][2]
local row12 = '<tr>' .. RscHeader .. 'เติมทรัพยากร</th>' .. RscData .. consfuel .. ' ' .. consammo .. '</td>'
-- Scrap Info
local scrapfuel = '[[File:IcoFuel.png|18px|น้ำมัน]] ' .. shipmodule.data[shipNum]["dismantle"][1]
local scrapammo = '[[File:IcoAmmo.png|18px|กระสุน]] ' .. shipmodule.data[shipNum]["dismantle"][2]
local scrapsteel = '[[File:IcoSteel.png|18px|เหล็ก]] ' .. shipmodule.data[shipNum]["dismantle"][3]
local scrapbauxite = '[[File:IcoBauxite.png|18px|บอกไซต์]] ' .. shipmodule.data[shipNum]["dismantle"][4]
local scrapinfo = scrapfuel .. ' ' .. scrapammo .. ' ' .. scrapsteel .. ' ' .. scrapbauxite
local row12 = row12 .. RscHeader .. 'ปลดระวาง</th>' .. RscData .. scrapinfo .. '</td></tr>'
-- Modernization
local modFP = '[[File:IcoAtkRemodel.png|25px|ปืนใหญ่]] ' .. shipmodule.data[shipNum]["modernization"][1]
local modTorp = '[[File:IcoTorpedoRemodel.png|25px|ตอร์ปิโด]] ' .. shipmodule.data[shipNum]["modernization"][2]
local modAA = '[[File:IcoAARemodel.png|25px|ต่อต้านอากาศยาน]] ' .. shipmodule.data[shipNum]["modernization"][3]
local modArmor = '[[File:IcoArmorRemodel.png|25px|เกราะ]] ' .. shipmodule.data[shipNum]["modernization"][4]
local modLuck = ''
if shipmodule.data[shipNum]["modernization"][5] ~= nil and shipmodule.data[shipNum]["modernization"][5] ~= "" then
-- modLuck = '[[File:IcoLuck|18px|โชค]] ' .. shipmodule.data[shipNum]["modernization"][5]
modLuck = '[[File:IcoLuckRemodel.png|25px|โชค]] ' .. shipmodule.data[shipNum]["modernization"][5] -- Just a placeholder
end
local modInfo = modFP .. ' ' .. modTorp .. ' ' .. modAA .. ' ' .. modArmor
if modLuck ~= '' then
modInfo = modInfo .. ' ' .. modLuck
end
local row13 = '<tr>' .. RscHeader .. 'ปรับปรุงสมรรถภาพ</th>' .. RscData2 .. modInfo .. '</td></tr>'
return '<table style="width: 100%">' .. row13 .. row11 .. row12 .. '</table>'
end
function shipmodule.getArtVoice(frame)
local shipNum = shipmodule.getIDNum(frame)
local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " ไม่มีในฐานข้อมูล")
-- Artist & Voice Info
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 = ''
local voiceactor = ''
if shipmodule.data[shipNum]["artist"] ~= "ไม่ทราบ" and shipmodule.data[shipNum]["artist"] ~= "" then
illustrator = '[[:Category:' .. shipmodule.data[shipNum]["artist"] .. '|' .. shipmodule.data[shipNum]["artist"] .. ']]'
--cat = cat .. '[[Category:' .. shipmodule.data[shipNum]["artist"] .. ']]'
else
illustrator = 'ไม่ทราบ'
end
art = RscHeader .. 'ผู้วาด</th>' .. RscData .. illustrator .. '</td>'
if shipmodule.data[shipNum]["seiyuu"] ~= "ไม่ทราบ" and shipmodule.data[shipNum]["seiyuu"] ~= "" then
voiceactor = '[[:Category:' .. shipmodule.data[shipNum]["seiyuu"] .. '|' .. shipmodule.data[shipNum]["seiyuu"] .. ']]'
--cat = cat .. '[[Category:' .. shipmodule.data[shipNum]["seiyuu"] .. ']]'
else
voiceactor = 'ไม่ทราบ'
end
voice = RscHeader .. 'นักพากย์</th>' .. RscData .. voiceactor .. '</td>'
local row14 = '<table style="width: 100%">' .. art .. voice .. '</table>'
return row14
end
function shipmodule.createCategories(frame)
local shipNum = shipmodule.getIDNum(frame)
local shipInfo = assert(shipmodule.data[shipNum], "KanMusu ID " .. shipNum .. " ไม่มีในฐานข้อมูล")
local cat = '[[Category:เรือ]]'
cat = cat .. '[[Category:ชั้น'.. shipmodule.data[shipNum]["class"] .. ']][[Category:' .. shipmodule.data[shipNum]["type"] .. ']]'
if shipmodule.data[shipNum]["artist"] ~= "ไม่ทราบ" and shipmodule.data[shipNum]["artist"] ~= "" then
cat = cat .. '[[Category:' .. shipmodule.data[shipNum]["artist"] .. ']]'
end
if shipmodule.data[shipNum]["seiyuu"] ~= "ไม่ทราบ" and shipmodule.data[shipNum]["seiyuu"] ~= "" then
cat = cat .. '[[Category:' .. shipmodule.data[shipNum]["seiyuu"] .. ']]'
end
return cat
end
function shipmodule.RemodelBlueprintChk(blueprint) -- Remodel value check
--Hardcoded Musashi K2 requirements for sake of time.
local blueprinttext = ''
if blueprint == 1 then
blueprinttext = '[[File:IcoBlueprint.png|25px|Blueprint|link=พิมพ์เขียว]]'
elseif blueprint == 2 then
blueprinttext = '[[File:IcoBlueprint.png|25px|Blueprint|link=พิมพ์เขียว]] [[File:IcoCatapult.png|25px|Prototype Flight Deck Catapult]]'
elseif blueprint == 3 then
blueprinttext = '[[File:IcoActionReport.png|25px|Action Report]]'
elseif blueprint == 4 then
blueprinttext = '[[File:IcoBlueprint.png|25px|Blueprint|link=พิมพ์เขียว]] [[File:IcoActionReport.png|25px|Action Report]]'
elseif blueprint == 11 then
--Musashi K2
blueprinttext = '[[File:IcoBlueprint.png|25px|Blueprint|link=พิมพ์เขียว]]x3 [[File:New Type Artillery Armament Materials.png|25px|New Type Artillery Armament Materials]]x3 [[File:IcoActionReport.png|25px|Action Report]]'
elseif blueprint == 12 then
--Ise K2
blueprinttext = '[[File:IcoBlueprint.png|25px|Blueprint|link=พิมพ์เขียว]]x2 [[File:IcoCatapult.png|25px|Prototype Flight Deck Catapult]] [[File:IcoActionReport.png|25px|Action Report]]'
end
return blueprinttext
end
function shipmodule.KanmusuList(frame)
local shipType = frame.args[1]
local shipListTable = '<table class="wikitable filterable sortable" style="width: 100%; min-width: 800px;"><tr>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unfilterable" data-sort-type="number">ID</th>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unfilterable unsortable">ชื่อ</th>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unsortable">ชั้น</th>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unfilterable unsortable">ประเภท</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: LightCoral;" class="unfilterable">[[File:IcoAtk.png|ปืนใหญ่]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: LightSkyBlue;" class="unfilterable">[[File:IcoTorpedo.png|ตอร์ปิโด]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: SandyBrown;" class="unfilterable">[[File:IcoAA.png|ต่อต้านอากาศยาน]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Seashell;" class="unfilterable">[[File:IcoASW.png|ต่อต้านเรือดำน้ำ]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Aquamarine;" class="unfilterable">[[File:IcoLOS.png|ค้นหาศัตรู]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: PaleGreen;" class="unfilterable">[[File:IcoLuck.png|โชค]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Pink;" class="unfilterable">[[File:IcoHP.png|HP]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Yellow;" class="unfilterable">[[File:IcoArmor.png|เกราะ]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Violet;" class="unfilterable">[[File:IcoEvasion.png|หลบหลีก]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Silver;" class="unfilterable">[[File:IcoAircraft.png|เครื่องบิน]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; vertical-align: middle; background-color: Aqua;" class="unsortable">[[File:IcoSpeed.png|ความเร็ว|link=]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unsortable">[[File:IcoRange.png|ระยะการยิง|link=]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unfilterable">[[File:IcoFuel.png|น้ำมันที่ใช้]]</th>'
shipListTable = shipListTable .. '<th style="text-align: center; background-color: SpringGreen;" class="unfilterable">[[File:IcoAmmo.png|กระสุนที่ใช้]]</th></tr>'
local IDList = shipdb.getSortedIDList()
for num, id in pairs(IDList) do
if shipType ~= nil then
if shipType == shipmodule.data[id]["type"] then
shipListTable = shipListTable .. shipmodule.KanmusuListEntry(id, frame.args[2] ~= nil)
end
else
shipListTable = shipListTable .. shipmodule.KanmusuListEntry(id, frame.args[2] ~= nil)
end
end
shipListTable = shipListTable .. '</table>'
return shipListTable
end
function shipmodule.KanmusuListEntry(id, printMax) -- Kanmusu List Table
local strings = '<tr>'
local aircraftTotal = 0
if shipmodule.data[id]["aircraft"] ~= "" then
local aircraftslot = {0, 0, 0, 0}
for i = 1, 4, 1 do
if shipmodule.data[id]["aircraft"][i] ~= nil then
aircraftslot[i] = shipmodule.data[id]["aircraft"][i]
else
aircraftslot[i] = 0
end
end
aircraftTotal = aircraftslot[1] + aircraftslot[2] + aircraftslot[3] + aircraftslot[4]
else
aircraftTotal = 0
end
--finding name of wiki page of ship
shipname = shipmodule.data[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]
--Chitose/Chiyoda-Kou check; submarines should be unaffected
if mw.text.split(shipbasename, '%p')[2] ~= nil and mw.text.split(shipbasename, '%p')[2] == "Kou" then
shipbasename = mw.text.split(shipbasename, '%p')[1]
end
--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" or
mw.text.split(shipname, '%s')[2] == "Dva") then
shipbasename = shipbasename .. ' ' .. mw.text.split(shipname, '%s')[2]
end
pagename = shipbasename
end
statLevel = 1 --base stat
if printMax then
statLevel = 2 --max stat
end
strings = strings .. '<td style="text-align: center;">' .. id .. '</td>'
strings = strings .. '<td style="text-align: center;">[[' .. pagename .. '|' .. shipname ..']]</td>'
strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["class"] .. '</td>'
strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["type"] .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #f0bbbb;">' .. shipmodule.data[id]["fp"][statLevel] .. '</td>'
if shipmodule.data[id]["torpedo"] == 0 then
strings = strings .. '<td style="text-align: center; background-color: #99eefa;">' .. shipmodule.data[id]["torpedo"] .. '</td>'
else
strings = strings .. '<td style="text-align: center; background-color: #99eefa;">' .. shipmodule.data[id]["torpedo"][statLevel] .. '</td>'
end
if shipmodule.data[id]["aa"] == 0 then
strings = strings .. '<td style="text-align: center; background-color: #faccaa;">' .. shipmodule.data[id]["aa"] .. '</td>'
else
strings = strings .. '<td style="text-align: center; background-color: #faccaa;">' .. shipmodule.data[id]["aa"][statLevel] .. '</td>'
end
if shipmodule.data[id]["asw"] == 0 then
strings = strings .. '<td style="text-align: center; background-color: #fff5ee;">' .. shipmodule.data[id]["asw"] .. '</td>'
else
strings = strings .. '<td style="text-align: center; background-color: #fff5ee;">' .. shipmodule.data[id]["asw"][statLevel] .. '</td>'
end
strings = strings .. '<td style="text-align: center; background-color: #afffee;">' .. shipmodule.data[id]["los"][statLevel] .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #cbfbcb;">' .. shipmodule.data[id]["luck"][statLevel] .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #ffe0eb;">' .. shipmodule.data[id]["hp"][statLevel] .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #ffffaa;">' .. shipmodule.data[id]["armor"][statLevel] .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #eeccee;">' .. shipmodule.data[id]["evasion"][statLevel] .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #d9d9d9;">' .. aircraftTotal .. '</td>'
strings = strings .. '<td style="text-align: center; background-color: #aaffff;">' .. shipmodule.data[id]["spd"] .. '</td>'
strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["range"] .. '</td>'
strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["consumption"][1] .. '</td>'
strings = strings .. '<td style="text-align: center;">' .. shipmodule.data[id]["consumption"][2] .. '</td></tr>'
return strings
end
return shipmodule