模块:图鉴:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
| (未显示同一用户的2个中间版本) | |||
| 第13行: | 第13行: | ||
local moe = ship['萌王'] | local moe = ship['萌王'] | ||
if moe == nil then moe = '' end | if moe == nil then moe = '' end | ||
local args = { idx, name:gsub('·改', ''), link, ship.rarity, ship.type:lower(), moe } | local args = { idx, name:gsub('·改', ''), link, ship.rarity, ship.type:lower(), moe, ship.cost, ship.sp } | ||
return curFrame:expandTemplate{ title = '图鉴立绘2', args = args } | return curFrame:expandTemplate{ title = '图鉴立绘2', args = args } | ||
end | end | ||
| 第76行: | 第76行: | ||
for i = l, r do | for i = l, r do | ||
if byIndex[i] ~= nil and ships[byIndex[i]].type == type then | if byIndex[i] ~= nil and ships[byIndex[i]].type == type then | ||
if cnt < 5 then | |||
ret = ret .. '\n|width="20%"|' .. expand(i) | |||
else | |||
ret = ret .. '\n|' .. expand(i) | |||
end | |||
cnt = cnt + 1 | |||
if cnt % 5 == 0 then | |||
ret = ret .. '\n|-' | |||
end | |||
end | |||
end | |||
if cnt % 5 ~= 0 then | |||
for i = cnt % 5 + 1, 5 do | |||
ret = ret .. '\n|' | |||
end | |||
end | |||
return ret .. '\n|}' | |||
end | |||
p['按国籍'] = function(frame) | |||
curFrame = frame | |||
local type = frame.args[1] | |||
local l = tonumber(frame.args[2]) | |||
local r = tonumber(frame.args[3]) | |||
local cnt = 0 | |||
local ret = '{| style="max-width:1000px"\n|-valign="bottom"' | |||
for i = l, r do | |||
if byIndex[i] ~= nil and ships[byIndex[i]].country == type then | |||
if cnt < 5 then | if cnt < 5 then | ||
ret = ret .. '\n|width="20%"|' .. expand(i) | ret = ret .. '\n|width="20%"|' .. expand(i) | ||
2025年3月23日 (日) 22:04的最新版本
{{#invoke:图鉴|按编号|1|10}}
No.1~10
|
|
|
|
| |||||||||||||||
|
|
|
|
|
{{#invoke:图鉴|按类型|BB|1|10}}
|
|
|
|
| |||||||||||||||
|
|
|
|
local data = mw.loadData("模块:特殊数据/舰娘")
local ships = data.ships
local byIndex = data.byIndex
local p = { }
local curFrame = nil
local function expand(idx)
local name = byIndex[idx]
local link = byIndex[idx % 1000]
local ship = ships[name]
local moe = ship['萌王']
if moe == nil then moe = '' end
local args = { idx, name:gsub('·改', ''), link, ship.rarity, ship.type:lower(), moe, ship.cost, ship.sp }
return curFrame:expandTemplate{ title = '图鉴立绘2', args = args }
end
local function genShipList(idx)
local part1 = ''
local part2 = ''
local empty1 = true
local empty2 = true
local prefix = '\n|width="20%"|'
for i = idx + 1, idx + 5 do
part1 = part1 .. prefix
if byIndex[i] ~= nil then
part1 = part1 .. expand(i)
empty1 = false
end
end
if not empty1 then prefix = '\n|' end
for i = idx + 6, idx + 10 do
part2 = part2 .. prefix
if byIndex[i] ~= nil then
part2 = part2 .. expand(i)
empty2 = false
end
end
if empty1 and empty2 then
return nil
elseif empty1 then
return '{| style="max-width:1000px"\n|- valign="bottom"' .. part2 .. '\n|}\n'
elseif empty2 then
return '{| style="max-width:1000px"\n|- valign="bottom"' .. part1 .. '\n|}\n'
else
return '{| style="max-width:1000px"\n|- valign="bottom"' .. part1 .. '\n|-' .. part2 .. '\n|}\n' end
end
p['按编号'] = function(frame)
curFrame = frame
local l = math.floor((tonumber(frame.args[1]) - 1) / 10) * 10
local r = math.floor((tonumber(frame.args[2]) - 1) / 10) * 10
local ret = ''
local buf = ''
for i = l, r, 10 do
local title = '===No.' .. (i + 1) .. '~' .. (i + 10) .. '===\n'
local list = genShipList(i)
if list ~= nil then
ret = ret .. buf .. title .. list
buf = ''
else
buf = buf .. title
end
end
return ret
end
p['按类型'] = function(frame)
curFrame = frame
local type = frame.args[1]
local l = tonumber(frame.args[2])
local r = tonumber(frame.args[3])
local cnt = 0
local ret = '{| style="max-width:1000px"\n|-valign="bottom"'
for i = l, r do
if byIndex[i] ~= nil and ships[byIndex[i]].type == type then
if cnt < 5 then
ret = ret .. '\n|width="20%"|' .. expand(i)
else
ret = ret .. '\n|' .. expand(i)
end
cnt = cnt + 1
if cnt % 5 == 0 then
ret = ret .. '\n|-'
end
end
end
if cnt % 5 ~= 0 then
for i = cnt % 5 + 1, 5 do
ret = ret .. '\n|'
end
end
return ret .. '\n|}'
end
p['按国籍'] = function(frame)
curFrame = frame
local type = frame.args[1]
local l = tonumber(frame.args[2])
local r = tonumber(frame.args[3])
local cnt = 0
local ret = '{| style="max-width:1000px"\n|-valign="bottom"'
for i = l, r do
if byIndex[i] ~= nil and ships[byIndex[i]].country == type then
if cnt < 5 then
ret = ret .. '\n|width="20%"|' .. expand(i)
else
ret = ret .. '\n|' .. expand(i)
end
cnt = cnt + 1
if cnt % 5 == 0 then
ret = ret .. '\n|-'
end
end
end
if cnt % 5 ~= 0 then
for i = cnt % 5 + 1, 5 do
ret = ret .. '\n|'
end
end
return ret .. '\n|}'
end
return p