维护提醒
BWIKI 全站将于 9 月 3 日(全天)进行维护,期间无法编辑任何页面或发布新的评论。
全站通知:
模块:Weapons
刷
历
编
跳到导航
跳到搜索
local Helper = require("Module:Helper")
local WeaponsData = Helper.LazyLoad('Module:Weapons/data')
local p = {}
local function stripPrefix(id)
if not id then return "" end
return string.gsub(id, "^%([^%)]*%)", "")
end
-- 获取伤害范围
function p.getDamageRange(frame)
local id = frame.args[1] or frame.args.id
if not id then
return ""
end
local weapon = WeaponsData[stripPrefix(id)]
if not weapon then
return ""
end
return weapon.MinDamage .. " ~ " .. weapon.MaxDamage
end
-- 获取基础暴击率
function p.getCritChance(frame)
local id = frame.args[1] or frame.args.id
if not id then
return ""
end
local weapon = WeaponsData[stripPrefix(id)]
if not weapon then
return ""
end
-- 将小数转换为百分比
local critPercent = weapon.CritChance * 100
return critPercent .. "%"
end
-- 获取暴击伤害倍率
function p.getCritMultiplier(frame)
local id = frame.args[1] or frame.args.id
if not id then
return ""
end
local weapon = WeaponsData[stripPrefix(id)]
if not weapon then
return ""
end
return tostring(weapon.CritMultiplier)
end
return p