Module:战舰少女:舰娘属性
跳转到导航
跳转到搜索
local ships = mw.loadData("模块:战舰少女:舰娘属性列表")
local p = {}
local shipTypeName = {
CV='航空母舰', CVL='轻型航空母舰', BB='战列舰', BBV='航空战列舰', BC='战列巡洋舰',
CA='重巡洋舰', CL='轻巡洋舰', BM='浅水重炮舰', DD='驱逐舰', SS='潜水艇', SC='重炮潜艇', AP='补给舰'
}
local function getAttr(shipName, attrName)
local ship = ships[shipName]
local canGrow = {}
for i,v in pairs({'火力', '装甲', '鱼雷', '对空', '回避', '对潜', '索敌'}) do
canGrow[v] = true
end
if canGrow[attrName] then
local base = ship[ships.tr['基础' .. attrName]]
local max_ = ship[ships.tr[attrName .. '上限']]
if base == max_ then
return base
else
return base .. '(' .. max_ .. ')'
end
elseif attrName == '搭载' then
return ship.cap1 + ship.cap2 + ship.cap3 + ship.cap4
else
local ret = ship[ships.tr[attrName]]
if ret == nil then ret = '' end
return ret
end
end
local function getAttrList(shipName, attrNameList)
local ret = ''
for i,attrName in pairs(attrNameList) do
ret = ret .. getAttr(shipName, attrName) .. '||'
end
return string.sub(ret, 1, -3)
end
-- {{#invoke:战舰少女:舰娘属性|get|船名|属性名}} -> 属性
-- {{#invoke:战舰少女:舰娘属性|get|船名|属性名1,属性名2,...}} -> 属性1||属性2||...
function p.get(frame)
local shipName = frame.args[1]
local attrNameList = mw.text.split(frame.args[2], ',', true)
return getAttrList(shipName, attrNameList)
end
function p.list(frame)
local shipType = frame.args[1]
local attrNameList = mw.text.split(frame.args[2], ',', true)
ret = '|-\n!colspan=' .. (#attrNameList + 3) .. '|' .. shipTypeName[shipType] .. '属性列表\n'
ret = ret .. '|-\n!图鉴<br>编号!!头像!!名称'
for i,attrName in pairs(attrNameList) do
ret = ret .. '!!'
if mw.ustring.len(attrName) > 2 then
ret = ret .. mw.ustring.sub(attrName, 1, 2)
local tmp = mw.ustring.sub(attrName, 3, -1)
if tmp ~= '上限' then
ret = ret .. '<br>' .. tmp
end
else
ret = ret .. attrName
end
end
ret = ret .. '\n'
for i = 1,1300 do
local shipName = ships.sorted[i]
if shipName ~= nil and ships[shipName].type == shipType then
ret = ret .. '|-\n|' .. i
ret = ret .. '||' .. frame:expandTemplate{ title = '战舰少女:头像', args = { shipName, '150px' } }
ret = ret .. '||' .. frame:expandTemplate{ title = '战舰少女:舰娘', args = { shipName } }
ret = ret .. '||' .. getAttrList(shipName, attrNameList) ..'\n'
end
end
return ret
end
return p