模块:装备:修订间差异
跳转到导航
跳转到搜索
小无编辑摘要 |
小无编辑摘要 |
||
第114行: | 第114行: | ||
end | end | ||
end | end | ||
ret = string.sub(ret, 1, -4) | ret = string.sub(ret, 1, -4) | ||
return ret | return ret | ||
end | end | ||
return p | return p |
2017年5月7日 (日) 14:04的版本
可在模块:装备/doc创建此模块的帮助文档
local equipts = mw.loadData("模块:特殊数据/装备").equipts
local data = mw.loadData("模块:特殊数据/舰娘")
local ships = data.ships
local byIndex = data.byIndex
local p = { }
local function fixEquiptName(name)
name = string.gsub(name, '(', '(')
name = string.gsub(name, ')', ')')
name = string.gsub(name, 'Ⅲ', 'III')
name = string.gsub(name, 'Ⅵ', 'VI')
name = string.gsub(name, '日本', 'J国')
name = string.gsub(name, '德国', 'G国')
name = string.gsub(name, '英国', 'E国')
name = string.gsub(name, '美国', 'U国')
name = string.gsub(name, '意大利', 'I国')
name = string.gsub(name, '法国', 'F国')
name = string.gsub(name, '德国', 'G国')
name = string.gsub(name, '苏联', 'S国')
name = string.gsub(name, '中国', 'C国')
if ret == nil then ret = name end
return ret
end
p['属性'] = function(frame)
local equip = equipts[frame.args[2]]
local default = frame.args[3]
if default == nil then default = '' end
if equip == nil then return default end
local ret = equip[frame.args[1]]
if ret == nil then return default end
return ret
end
p['可否装备'] = function(frame)
local equip = equipts[frame.args[2]]
local default = frame.args[3]
if default == nil then default = '' end
if equip == nil then return default end
local typenum = frame.args[1] + 1
local ret = equip.canEquip[typenum]
if ret == nil then return default end
return ret
end
local rangeName = { '短', '中', '长', '超长' }
local typeName = { '炮潜主炮', '副炮', '鱼雷', '攻击机', '战斗机', '轰炸机', '侦察机', '雷达(通常)', '强化部件', '炮弹', '防空炮', '特殊潜艇', '修理员', '反潜装备', '大型主炮', '中型主炮(重)', '中型主炮(轻)', '小型主炮', '潜艇鱼雷', '雷达(声纳)', '发射器(反舰)', '发射器(防空)', '导弹(反舰)', '导弹(防空)' }
p['射程'] = function(frame)
if equipts[frame.args[1]].range ~= nil then
return rangeName[equipts[frame.args[1]].range]
end
end
p['类型'] = function(frame)
if equipts[frame.args[1]].range ~= 0 then
return typeName[equipts[frame.args[1]].type]
end
end
p['稀有度'] = function(frame)
return equipts[frame.args[1]].rarity
end
p['编号'] = function(frame)
return equipts[frame.args[1]].index
end
local attrList = { 'atk', 'def', 'tpd', 'aa', 'bomb', 'rec', 'as', 'acc', 'eva', 'luck' }
local attrName = { '火力', '装甲', '鱼雷', '对空', '轰炸', '索敌', '对潜', '命中', '回避', '幸运' }
p['属性列表'] = function(frame)
local equipt = equipts[frame.args[1]]
if equipt == nil then return '' end
local ret = ''
for i, attr in pairs(attrList) do
local val = equipt[attr]
if val ~= nil then
ret = ret .. '<br>' .. attrName[i]
if val > 0 then ret = ret .. '+' end
ret = ret .. val
end
end
if equipt.range ~= nil then
ret = ret .. '<br>射程: ' .. rangeName[equipt.range]
end
if equipt.aac ~= nil then
ret = ret .. '<br>对空补正:<wbr>' .. equipt.aac .. '%'
end
if equipt.effect ~= nil then
ret = ret .. '<br>' .. equipt.effect
end
return ret:sub(5)
end
p['自带'] = function(frame)
local equiptName = frame.args[1]
equiptName = fixEquiptName(equiptName)
local ret = ''
for i = 1,1300 do
local shipName = byIndex[i]
if shipName ~= nil then
local eq = {ships[shipName].eq1, ships[shipName].eq2, ships[shipName].eq3, ships[shipName].eq4}
for k = 1,4 do
if eq[k] == equiptName then
if string.sub(shipName, -5, -1) == '·改' then
ret = ret .. '[[' .. string.sub(shipName, 1, -6) .. '|' .. shipName .. ']]、'
else
ret = ret .. '[[' .. shipName .. ']]、'
end
end
end
end
end
ret = string.sub(ret, 1, -4)
return ret
end
return p