🌟現在、鉄壁 鉄壁ヘッドショットには対応済みです。
鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。

「モジュール:WeaponInfobox」の版間の差分

提供:Apex Data
ナビゲーションに移動 検索に移動
(一部のダメージ表示に数字タイプのスタイルを付与)
(アンビルレシーバーが出現しない場合にアンビルレシーバー用の拡散を非表示するように対処)
 
(同じ利用者による、間の135版が非表示)
3行目: 3行目:
local p = {}
local p = {}
local cfg = mw.loadData('Module:WeaponInfobox/configuration')
local cfg = mw.loadData('Module:WeaponInfobox/configuration')
local Hopup = mw.loadData('Module:Stat/Hopup')


local aw = require('Module:Utility/Library')
local aw   = require('Module:Utility/Library')
local iu = require('Module:Utility/Image')
local apex  = require('Module:Utility/ApexLibrary')
local nu = require('Module:Utility/Name')
local iu   = require('Module:Utility/Image')
local inu  = require('Module:Utility/ImageWithName')
local nu   = require('Module:Utility/Name')
local proto = require('Module:Utility/Prototypes')
local StringBuilder = require('Module:Utility/StringBuilder')
local formatter -- lazily initialized
local formatter -- lazily initialized
local getArgs -- lazily initialized
local getArgs -- lazily initialized
local function calcBurstAverageRPS(stat, delay)
delay = delay or stat.firerate.burst_delay
return stat.mode.burst / ((stat.mode.burst - 1) / stat.firerate.burst + delay)
end


local function createCellInRow(tbl, name)
local function createCellInRow(tbl, name)
31行目: 31行目:
opts.separator = opts.separator or ' - '
opts.separator = opts.separator or ' - '
local row = tbl:tag('tr')
local row = tbl:tag('tr')
:addClassIf(opts.class and type(opts.class) == 'string', opts.class)
:addClassIf(type(opts.class)  == 'string', opts.class)
:addClassIf(type(opts.rarity) == 'string', 'row-rarity-one disp-rarity-' .. (opts.rarity or 'common'))
if name ~= nil then
if name ~= nil then
38行目: 39行目:
:wikitext(name)
:wikitext(name)
end
end
 
row:tag('td')
local first = true
:addClass('cell-type-number')
if default ~= nil then
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
first = false
:wikitext(default)
row:tag('td')
:addClass('cell-type-number')
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
:wikitext(default)
end
if common ~= nil then
if common ~= nil then
row:tag('td'):wikitext(opts.separator):done()
if not first then
:tag('td')
row:tag('td'):wikitext(opts.separator)
:addClass('cell-type-number')
end
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
first = false
:wikitext(formatter:common(common))
row:tag('td')
:addClass('cell-type-number')
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
:tag('span')
:addClass('text-rarity')
:addClass('text-rarity-common')
:wikitext(common)
end
end
if rare ~= nil then
if rare ~= nil then
row:tag('td'):wikitext(opts.separator):done()
if not first then
:tag('td')
row:tag('td'):wikitext(opts.separator)
:addClass('cell-type-number')
end
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
first = false
:wikitext(formatter:rare(rare))
row:tag('td')
:addClass('cell-type-number')
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
:tag('span')
:addClass('text-rarity')
:addClass('text-rarity-rare')
:wikitext(rare)
end
end
if epic ~= nil then
if epic ~= nil then
row:tag('td'):wikitext(opts.separator):done()
if not first then
:tag('td')
row:tag('td'):wikitext(opts.separator)
:addClass('cell-type-number')
end
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
first = false
:wikitext(formatter:epic(epic))
row:tag('td')
:addClass('cell-type-number')
:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
:tag('span')
:addClass('text-rarity')
:addClass('text-rarity-epic')
:wikitext(epic)
end
end
85行目: 108行目:
end
end


local function renderCategory(tbl, cfg, stat)
local function renderCategory(tbl, cfg, stat, lang)
local category = nu.type(stat)
local category = nu.type(stat, lang, 1)
local item = string.format('[[武器#%s|%s]][[Category:%s]]', category, category, category)
local item
if lang == 'ja' then
item = string.format('[[武器#%s|%s]][[Category:%s]]', category, category, category)
else
item = string.format('%s[[Category:%s]]', category, category)
end
renderRow(tbl, cfg.name, item)
renderRow(tbl, cfg.name, item)
end
end


local function renderAmmo(tbl, cfg, stat)
local function renderAmmo(tbl, cfg, stat, lang)
local ammo = nu.ammo(stat)
createCellInRow(tbl, cfg.name)
local item = string.format(
:addClass('cell-ammo')
'%s [[弾薬#%s|%s]][[Category:%s]]',
:wikitext(inu.ammo(stat, { lang = lang, size = 24 }))
iu.ammo(stat, { size = 24 }),
ammo,
ammo,
ammo)
renderRow(tbl, cfg.name, item)
end
end


local function renderMode(tbl, cfg, stat)
local function renderCost(tbl, cfg, stat, ammo)
local mode = nil
if stat == nil or aw.stringstarts(ammo, 'special_') then
if stat.burst > 1 then
return
mode = string.format(cfg.burst, stat.burst) .. cfg.burst_category
end
end
if stat.auto then
local text = formatter:format(
if mode == nil then
aw.comma(stat[1]),
mode = cfg.auto .. cfg.auto_category
aw.comma(stat[2]),
aw.comma(stat[3]),
aw.comma(stat[4]),
'', ' - ')
renderRow(tbl, cfg.name, cfg.header .. text)
end
 
local function appendMode(builder, cfg, stat, base)
if stat.is_semi_auto or (stat.is_semi_auto == nil and base.is_semi_auto) then
local burstCount = stat.burst_count or (base and base.burst_count) or 1
if aw.isNumberAndGreaterThanOrEqualToX(burstCount, 2) then
builder:appendFormat(cfg.burst, burstCount)
builder:append(cfg.burst_category)
else
else
mode = mode .. cfg.separator .. cfg.auto .. cfg.auto_category
builder:append(cfg.single, cfg.single_category)
end
end
else
builder:append(cfg.auto, cfg.auto_category)
end
end
end
if stat.single then
 
if mode == nil then
local function renderMode(tbl, cfg, stat, isSpecial)
mode = cfg.single .. cfg.single_category
local builder = StringBuilder.new()
else
appendMode(builder, cfg, stat)
mode = mode .. cfg.separator .. cfg.single .. cfg.single_category
if stat.altfire then
end
builder:append(cfg.separator)
appendMode(builder, cfg, stat.altfire, stat)
end
if (Hopup.selectfire_receiver.enabled or isSpecial) and stat.selectfire_receiver then
builder:append(cfg.separator, '<span class="block-rarity disp-rarity-epic">', iu.hopup('selectfire_receiver'), ' ')
appendMode(builder, cfg, stat.selectfire_receiver, stat)
builder:append('</span>')
end
if (Hopup.double_tap_trigger.enabled or isSpecial) and stat.double_tap_trigger then
builder:append(cfg.separator, '<span class="block-rarity disp-rarity-epic">', iu.hopup('double_tap_trigger'), ' ')
appendMode(builder, cfg, stat.double_tap_trigger, stat)
builder:append('</span>')
end
end
renderRow(tbl, cfg.name, tostring(builder))
renderRow(tbl, cfg.name, mode)
end
end


local function renderDamage(tbl, cfg, stat, ammo, pellet)
local HammerpointRoundsProto = {
local base = stat.base
hammerpoint_rounds = {
local typename = type(base)
damage_unshielded_scale = proto.NumberRange(1),
local damageText
},
if pellet ~= nil then
}
damageText = string.format(cfg.shotgun, base, pellet)
local DisruptorRoundsProto = {
elseif typename == 'table' then
disruptor_rounds = {
damageText = table.concat(base, ' - ')
damage_shield_scale = proto.NumberRange(1),
elseif typename == 'number' then
},
if stat.anvil_receiver ~= nil then
}
damageText = string.format(
local function getDamageText(stat, root, isSpecial)
'<span class="text-type-number">%s</span> <span class="text-separator">/</span> %s <span class="text-type-number">%s</span>',
local builder = StringBuilder.new()
base,
local rarity  = isSpecial and 'heirloom'
iu.hopup('アンビルレシーバー'),
local damage, pellet
formatter:legendary(stat.anvil_receiver.base))
if root then
elseif stat.amped then
damage = stat.damage or root.damage
damageText = string.format(
pellet = stat.pellet or root.pellet or 1
'<span class="text-type-number">%s</span> <span class="text-separator">/</span> %s <span class="text-type-number">%s</span>',
else
base,
damage = stat.damage
pellet = stat.pellet or 1
end
if aw.isNumberAndGreaterThanOrEqualToX(pellet, 2) then
builder:appendFormat(
'<span class="text-type-number">%s</span>&thinsp;&times;&thinsp;%d',
damage.base,
pellet)
if aw.isNumberAndGreaterThanZero(damage.charged) then
builder:appendFormat(
'&thinsp;&rarr;&thinsp;<span class="text-type-number">%s</span>&thinsp;&times;&thinsp;%d',
damage.charged,
pellet)
elseif proto.validateTypes(stat, HammerpointRoundsProto) then
if not rarity then
rarity = Hopup.hammerpoint_rounds.rarity
end
builder:appendFormat(
'&thinsp;&rarr;&thinsp;<span class="block-rarity disp-rarity-%s text-rarity text-rarity-%s">%s \'\'\'<span class="text-type-number">%s</span>&thinsp;&times;&thinsp;%d\'\'\'</span>',
rarity,
rarity,
iu.hopup('hammerpoint_rounds', { rarity = rarity }),
math.floor(damage.base * stat.hammerpoint_rounds.damage_unshielded_scale),
pellet)
end
else
if aw.isNumberAndGreaterThanZero(damage.amped) then
builder:appendFormat(
'<span class="text-type-number">%s</span> <span class="text-separator">/</span> %s&nbsp;<span class="text-type-number">%s</span>',
damage.base,
iu.item('シールドセル'),
iu.item('シールドセル'),
stat.amped)
damage.amped)
elseif aw.isNumberAndGreaterThanZero(damage.charged) then
builder:appendFormat(
'<span class="text-type-number">%s</span>&thinsp;&rarr;&thinsp;<span class="text-type-number">%s</span>',
damage.base,
damage.charged)
elseif proto.validateTypes(stat, HammerpointRoundsProto) then
if not rarity then
rarity = Hopup.hammerpoint_rounds.rarity
end
builder:appendFormat(
'<span class="text-type-number">%s</span>&thinsp;&rarr;&thinsp;<span class="block-rarity disp-rarity-%s text-rarity text-rarity-%s">%s \'\'\'<span class="text-type-number">%s</span>\'\'\'</span>',
damage.base,
rarity,
rarity,
iu.hopup('hammerpoint_rounds', { rarity = rarity }),
math.floor(damage.base * stat.hammerpoint_rounds.damage_unshielded_scale))
elseif proto.validateTypes(stat, DisruptorRoundsProto) then
if not rarity then
rarity = Hopup.disruptor_rounds.rarity
end
builder:appendFormat(
'<span class="block-rarity disp-rarity-%s text-rarity text-rarity-%s">%s \'\'\'<span class="text-type-number">%s</span>\'\'\'</span>&thinsp;&rarr;&thinsp;<span class="text-type-number">%s</span>',
rarity,
rarity,
iu.hopup('disruptor_rounds', { rarity = rarity }),
math.floor(damage.base * stat.disruptor_rounds.damage_shield_scale),
damage.base)
else
else
damageText = tostring(base)
builder:appendFormat('<span class="text-type-number">%s</span>', damage.base)
end
end
else
return
end
end
renderRow(tbl, cfg.name, damageText)
return tostring(builder)
end
local head = stat.headshot
 
local hlm1 = 0.2 + 0.8 * stat.headshot
local function renderHeadRow(tbl, name, head, cfg, nolist)
local hlm2 = 0.4 + 0.6 * stat.headshot
local opts = { align = 'left', footer = cfg.unit }
local hlm3 = 0.5 + 0.5 * stat.headshot
if nolist then
local leg = stat.legshot
opts.class = 'no-list-style'
local sprm = stat.skullpiercer_rifling or 1
opts.headerAlign = 'right'
end
local cattext = string.format(cfg.head_category, stat.headshot)
renderFormatRow(
local intable = tbl:tag('tr')
tbl,
:tag('td')
name,
:attr('colspan', 2)
nil,
:tag('table')
apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV1),
:addClass('condensedtable')
apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV2),
:addClass('listtable')
apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV3),
if sprm > 1 then
opts)
local spr0 = sprm
end
local spr1 = 0.2 + 0.8 * sprm
 
local spr2 = 0.4 + 0.6 * sprm
local function renderHeadEffectiveRange(tbl, cfg, stat, root)
local spr3 = 0.5 + 0.5 * sprm
local headDist = stat.damage_head_distance or root.damage_head_distance
if aw.isNumberAndGreaterThanZero(headDist) then
renderFormatRow(
local text = string.format(cfg.head_effective_range, 0.0254 * headDist)
intable,
tbl:tag('tr')
cfg.head,
:addClass('no-list-style')
head, hlm1, hlm2, hlm3,
:tag('td')
{ align = 'left', footer = cfg.unit .. cattext })
:attr('align', 'left')
renderFormatRow(
:attr('colspan', 7)
intable,
:wikitext(text)
iu.hopup('スカルピアサーライフリング') .. '&nbsp;',
spr0, spr1, spr2, spr3,
{ class = 'no-list-style', align = 'left', footer = cfg.unit })
else
renderFormatRow(
intable,
cfg.head,
head, hlm1, hlm2, hlm3,
{ align = 'left', footer = cfg.unit .. cattext })
end
end
end
local additional
 
if stat.anvil_receiver ~= nil then
local function renderLegsRow(tbl, cfg, stat, root)
additional = string.format(
local legs = stat.damage_legs_scale or root.damage_legs_scale
' <span class="text-separator">/</span> %s %s',
local text
iu.hopup('アンビルレシーバー'),
if aw.isNumberAndGreaterThanZero(stat.legshot_charged) then
formatter:legendary('<span class="text-type-number">' .. stat.anvil_receiver.legshot .. '</span>' .. cfg.unit))
text = string.format(
'<span class="text-type-number">%s</span> &rarr; <span class="text-type-number">%s</span>%s',
legs,
stat.legshot_charged,
cfg.unit)
else
else
additional = ''
text = string.format(
'<span class="text-type-number">%s</span>%s',
legs,
cfg.unit)
end
end
tbl:tag('tr')
intable:tag('tr')
:tag('th')
:tag('th')
:wikitext(cfg.legs)
:wikitext(cfg.legs)
210行目: 308行目:
:tag('td')
:tag('td')
:attr('align', 'left')
:attr('align', 'left')
:attr('colspan', 8)
:attr('colspan', 6)
:wikitext('<span class="text-type-number">' .. leg .. '</span>' .. cfg.unit .. additional)
:wikitext(text)
end
end


local function renderFirerateRow(intbl, name, cfg, rps, opts)
local DamageProto = {
opts = opts or {}
damage = {
intbl:tag('tr')
base    = proto.NumberRange(1),
:addClassIf(opts.class and type(opts.class) == 'string', opts.class)
},
:tag('th')
damage_head_scale = proto.NumberRange(1),
:wikitext(name)
damage_legs_scale = proto.NumberRange(0, 1),
:done()
}
:tag('td')
local ShatterCapsProto = {
:addClass('cell-type-number')
damage = {
:attr('align', 'right')
base    = proto.NumberRange(1),
:wikitext(string.format(cfg.rps.format, rps))
},
:done()
damage_head_scale = proto.NumberRange(1),
:tag('td')
damage_legs_scale = proto.NumberRange(0, 1),
:wikitext(cfg.rps.unit)
pellet = proto.NumberRange(1),
:done()
}
:tag('td')
local damageHopups = {
:tag('small')
{
:addClass('text-secondary')
name = 'selectfire_receiver',
:wikitext(cfg.rpm.name)
proto = DamageProto,
:done()
textclass = 'text-rarity-epic',
:done()
dispclass = 'disp-rarity-epic',
:tag('td')
},
:addClass('cell-type-number')
{
:attr('align', 'right')
name = 'anvil_receiver',
:tag('small')
proto = DamageProto,
:addClass('text-secondary')
textclass = 'text-rarity-legendary',
:wikitext(aw.comma(60 * rps))
dispclass = 'disp-rarity-legendary',
:done()
},
:done()
{
:tag('td')
name = 'shatter_caps',
:tag('small')
proto = ShatterCapsProto,
:addClass('text-secondary')
textclass = 'text-rarity-epic',
:wikitext(cfg.rpm.unit)
dispclass = 'disp-rarity-epic',
end
},
 
}
local function renderFirerateCell(cell, cfg, rps, opts)
local function renderDamage(tbl, cfg, stat, isSpecial)
opts = opts or {}
if not proto.validateTypes(stat, DamageProto) then
opts.header = opts.header or ''
cell:wikitext(string.format(
opts.header .. '<span class="text-type-number">' .. cfg.rps.format .. '</span>' .. cfg.rps.unit .. '<span class="text-secondary"><small>(<span class="text-type-number">%s</span>' .. cfg.rpm.unit .. '</small></span>',
rps,
aw.comma(60 * rps)))
end
 
local function renderFirerate(tbl, cfg, stat)
local firerate = stat.firerate
if firerate == nil then
return
return
end
end
local mode = stat.mode
local cattext = string.format(cfg.head_category, stat.damage.headshot_charged or stat.damage_head_scale or 1)
local cell = createCellInRow(tbl, cfg.name)
local cell = createCellInRow(tbl, cfg.name)
local rps
cell:wikitext(cattext .. getDamageText(stat, nil, isSpecial))
if mode.auto then
if mode.single then
-- Headshot
if firerate.anvil_receiver then
local head = stat.damage_head_scale or 1
local intbl = cell:tag('table')
local intable = cell:tag('table')
:addClass('condensedtable')
:addClass('condensedtable')
:addClass('listtable')
:addClass('listtable')
renderFirerateRow(intbl, cfg.auto, cfg, firerate.auto)
renderHeadRow(intable, cfg.head, head, cfg)
if firerate.auto ~= firerate.single then
local hlmc = stat.damage.headshot_charged or 1
renderFirerateRow(intbl, cfg.single, cfg, firerate.single)
if hlmc > 1 then
end
local nameC = '→&nbsp;'
renderHeadRow(intable, nameC, hlmc, cfg, true)
if firerate.anvil_receiver then
end
renderFirerateRow(intbl, iu.hopup('アンビルレシーバー'), cfg, firerate.anvil_receiver)
end
local sprm = stat.damage.skullpiercer_rifling or 1
return
if sprm > 1 then
elseif firerate.auto ~= firerate.single then
local nameS = iu.hopup('skullpiercer_rifling') .. '&nbsp;'
local intbl = cell:tag('table')
renderHeadRow(intable, nameS, sprm, cfg, true)
:addClass('condensedtable')
end
:addClass('listtable')
renderHeadEffectiveRange(intable, cfg, stat, stat)
if firerate.burst then
renderFirerateRow(intbl, cfg.burst, cfg, firerate.burst)
-- Legsshot
end
renderLegsRow(intable, cfg, stat, stat)
renderFirerateRow(intbl, cfg.auto,   cfg, firerate.auto)
renderFirerateRow(intbl, cfg.single, cfg, firerate.single)
-- [Hop-Up] Selectfire Receiver, Anvil Receiver & Shatter Caps
return
for _, v in ipairs(damageHopups) do
end
local hopupStat = stat[v.name]
elseif mode.burst > 1 then
if (Hopup[v.name].enabled or isSpecial) and proto.validateTypes(hopupStat, v.proto) then
if type(firerate.auto) == 'table' then
local intblS = cell:tag('div')
local newcell = tbl:tag('tr')
:addClass('tpl-weapon-inbox')
:tag('td')
:addClass(specialOnly and 'disp-rarity-heirloom' or v.dispclass)
:attr('colspan', 2)
:wikitext(iu.hopup(v.name) .. '&nbsp;')
renderFirerateCell(newcell:tag('ul'):tag('li'), cfg, firerate.burst, { header = cfg.burst })
:tag('span')
:addClass('text-rarity')
intbl = newcell:tag('table')
:addClass(specialOnly and 'text-rarity-heirloom' or v.textclass)
:wikitext(getDamageText(hopupStat, stat))
:done()
:tag('table')
:addClass('condensedtable')
:addClass('condensedtable')
:addClass('listtable')
:addClass('listtable')
local average1 = 0.01 * aw.round(100 * calcBurstAverageRPS(stat, firerate.burst_delay[1]))
local average2 = 0.01 * aw.round(100 * calcBurstAverageRPS(stat, firerate.burst_delay[2]))
local head = hopupStat.damage_head_scale or stat.damage_head_scale or 1
local average3 = 0.01 * aw.round(100 * calcBurstAverageRPS(stat, firerate.burst_delay[3]))
renderHeadRow(intblS, cfg.head, head, cfg)
local average4 = 0.01 * aw.round(100 * calcBurstAverageRPS(stat, firerate.burst_delay[4]))
renderHeadEffectiveRange(intblS, cfg, hopupStat, stat)
renderFormatRow(
renderLegsRow          (intblS, cfg, hopupStat, stat)
intbl,
cfg.burst_average .. cfg.rps.name,
string.format(cfg.rps.format, average1),
string.format(cfg.rps.format, average2),
string.format(cfg.rps.format, average3),
string.format(cfg.rps.format, average4),
{ class = 'no-list-style', separator = cfg.rps.separator, footer = cfg.rps.unit })
renderFormatRow(
intbl,
cfg.rpm.name,
string.format(cfg.rpm.format, 60 * average1),
string.format(cfg.rpm.format, 60 * average2),
string.format(cfg.rpm.format, 60 * average3),
string.format(cfg.rpm.format, 60 * average4),
{ class = 'all-secondary no-list-style', headerAlign = 'right', separator = cfg.rpm.separator, footer = cfg.rpm.unit })
renderFormatRow(
intbl,
cfg.auto .. cfg.rps.name,
string.format(cfg.rps.format, firerate.auto[1]),
string.format(cfg.rps.format, firerate.auto[2]),
string.format(cfg.rps.format, firerate.auto[3]),
string.format(cfg.rps.format, firerate.auto[4]),
{ separator = cfg.rps.separator, footer = cfg.rps.unit })
renderFormatRow(
intbl,
cfg.rpm.name,
string.format(cfg.rpm.format, 60 * firerate.auto[1]),
string.format(cfg.rpm.format, 60 * firerate.auto[2]),
string.format(cfg.rpm.format, 60 * firerate.auto[3]),
string.format(cfg.rpm.format, 60 * firerate.auto[4]),
{ class = 'all-secondary no-list-style', headerAlign = 'right', separator = cfg.rpm.separator, footer = cfg.rpm.unit })
else
local intbl = cell:tag('table')
:addClass('condensedtable')
:addClass('listtable')
local average = 0.01 * aw.round(100 * calcBurstAverageRPS(stat))
renderFirerateRow(intbl, cfg.burst,        cfg, firerate.burst)
renderFirerateRow(intbl, cfg.burst_average, cfg, average, { class = 'no-list-style' })
renderFirerateRow(intbl, cfg.auto,         cfg, firerate.auto)
end
return
end
rps = firerate.auto
elseif mode.single then
if mode.burst > 1 then
local intbl = cell:tag('table')
:addClass('condensedtable')
:addClass('listtable')
local average = 0.01 * aw.round(100 * calcBurstAverageRPS(stat))
renderFirerateRow(intbl, cfg.burst,         cfg, firerate.burst)
renderFirerateRow(intbl, cfg.burst_average, cfg, average, { class = 'no-list-style' })
renderFirerateRow(intbl, cfg.single,        cfg, firerate.single)
return
end
end
rps = firerate.single
else
return
end
end
end
if type(rps) == 'table' then
 
local intable = cell:tag('table'):addClass('condensedtable')
local function renderFirerate(tbl, cfg, stat, lang)
renderFormatRow(
local cell = createCellInRow(tbl, cfg.name)
intable,
local node, newcell = require('Module:WeaponInfobox/Firerate').renderFirerate(stat, lang)
cfg.rps.name,
if newcell then
string.format(cfg.rps.format, rps[1]),
tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
string.format(cfg.rps.format, rps[2]),
string.format(cfg.rps.format, rps[3]),
string.format(cfg.rps.format, rps[4]),
{ separator = cfg.rps.separator, footer = cfg.rps.unit })
renderFormatRow(
intable,
cfg.rpm.name,
string.format(cfg.rpm.format, 60 * rps[1]),
string.format(cfg.rpm.format, 60 * rps[2]),
string.format(cfg.rpm.format, 60 * rps[3]),
string.format(cfg.rpm.format, 60 * rps[4]),
{ class = 'all-secondary', separator = cfg.rpm.separator, footer = cfg.rpm.unit })
else
else
renderFirerateCell(cell, cfg, rps)
cell:node(node)
end
end
end
end


local function renderProjectileSpeed(tbl, cfg, projectile_speed)
local function renderProjectileSpeed(tbl, cfg, projectile_speed, projectile_speed_charged)
if projectile_speed == nil then
if not aw.isNumberAndGreaterThanZero(projectile_speed) then
return
return
end
end
400行目: 422行目:
if projectile_speed == math.huge then
if projectile_speed == math.huge then
text = cfg.hitscan
text = cfg.hitscan
elseif aw.isNumberAndGreaterThanZero(move_speed_charged) then
text = string.format(
'<span class="text-type-number">%s</span> → <span class="text-type-number">%s</span>%s',
string.format(cfg.format, aw.comma(aw.roundx(0.0254 * projectile_speed, 2))),
string.format(cfg.format, aw.comma(aw.roundx(0.0254 * projectile_speed_charged, 2))),
cfg.unit)
else
else
text = '<span class="text-type-number">' .. string.format(cfg.format, aw.comma(0.1 * projectile_speed)) .. '</span>' .. cfg.unit
text = string.format(
'<span class="text-type-number">%s</span>%s',
string.format(cfg.format, aw.comma(aw.roundx(0.0254 * projectile_speed, 2))),
cfg.unit)
end
end
renderRow(tbl, cfg.name, text)
renderRow(tbl, cfg.name, text)
end
end


local function renderRowDPS(tbl, name, leg, body, head, skullpiercer, tag)
local ShatterCapsMoveSpeedProto = {
tag = tag or 'td'
shatter_caps = {
move_speed = proto.NumberRange(0, 1),
},
}
local function getMoveSpeedText(cfg, moveSpeed)
return string.format(
'<span class="text-type-number">%s</span>%s',
string.format(cfg.format, 100 * (moveSpeed - 1)),
cfg.unit)
end
local function renderMoveSpeed(tbl, cfg, stat)
if not aw.isNumberAndGreaterThanZero(stat.move_speed) then
return
end
local row = tbl:tag('tr')
local text
row:tag('th'):wikitext(name)
if leg == '' then
-- [Hop-up] Shatter Caps
row:tag(tag)
if proto.validateTypes(stat, ShatterCapsMoveSpeedProto) and stat.move_speed ~= stat.shatter_caps.move_speed then
:attr('align', 'center')
text = string.format(
:addClass('disabled')
'%s%s<span class="block-rarity disp-rarity-epic text-rarity text-rarity-epic">%s %s</span>',
:wikitext('–')
getMoveSpeedText(cfg, stat.move_speed),
elseif leg ~= nil and leg ~= body then
cfg.separator,
row:tag(tag):wikitext(leg)
iu.hopup('shatter_caps'),
end
getMoveSpeedText(cfg, stat.shatter_caps.move_speed))
row
elseif aw.isNumberAndGreaterThanZero(stat.move_speed_charged) then
:tag(tag):wikitext(body):done()
text = string.format(
:tag(tag):wikitext(head)
'%s → %s',
if skullpiercer ~= nil then
getMoveSpeedText(cfg, stat.move_speed),
row:tag(tag):wikitext(skullpiercer)
getMoveSpeedText(cfg, stat.move_speed_charged),
cfg.unit)
else
text = getMoveSpeedText(cfg, stat.move_speed)
end
end
renderRow(tbl, cfg.name, text)
end
local function renderDPS(tbl, cfg, stat, lang)
local sld  = require('Module:Stat/Shield')['reinforcehelmets']
local node = require('Module:WeaponInfobox/DPS').renderDPS(stat, sld, lang)
createCellInRow(tbl, cfg.name)
tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
end
end


local function toDPSText(dps)
local function renderMagazineRow(intbl, name, mag, rsvmag, cfg, opts)
return string.format("%.1f", dps)
opts = opts or {}
intbl:tag('tr')
:addClassIf(opts.class and type(opts.class) == 'string', opts.class)
:tag('th')
:wikitext(name)
:done()
:tag('td')
:addClass('cell-type-number')
:attr('align', 'right')
:wikitext(mag)
:done()
:tag('td')
:wikitext(cfg.unit)
:done()
:tag('td')
:addClass('text-secondary')
:wikitext('&nbsp;/&nbsp;')
:done()
:tag('td')
:addClass('cell-type-number')
:attr('align', 'right')
:wikitext(rsvmag == math.huge and cfg.infinity or rsvmag)
:done()
:tag('td')
:wikitext(cfg.unit)
end
end


local function renderDPSTable(cell, name, pellet, base, damages, firerate, useRound)
local function calcVirtualMagSize(overheat, firerate, moddedLoader)
local headDamage = aw.round(damages.headshot * base)
if moddedLoader then
local legDamage = aw.round(damages.legshot * base)
return math.ceil(1.15 * overheat * firerate)
local skullpiercer = damages.skullpiercer_rifling
local selectiveRound = useRound and aw.round or aw.roundover
local skullpiercerHeader = nil
local commonSkullpiercerDPS = nil
local lowprofileSkullpiercerDPS = nil
local fortifiedSkullpiercerDPS = nil
if skullpiercer ~= nil then
skullpiercerHeader = iu.hopup('スカルピアサーライフリング')
local skullpiercerDamage = aw.round(skullpiercer * base)
commonSkullpiercerDPS = toDPSText(pellet * skullpiercerDamage * firerate)
lowprofileSkullpiercerDPS = toDPSText(pellet * selectiveRound(1.05 * skullpiercerDamage) * firerate)
fortifiedSkullpiercerDPS = toDPSText(pellet * aw.round(0.85 * skullpiercerDamage) * firerate)
end
if type(firerate) == 'table' then
firerate = firerate[1]
end
local intable = cell:tag('table')
:addClass('intable')
:addClass('numbertable')
local lowprofileLegDamagePlaceholder
if damages.legshot == 1 then
lowprofileLegDamagePlaceholder = nil
renderRowDPS(intable, name, nil, '胴', '頭', skullpiercerHeader, 'th')
else
else
lowprofileLegDamagePlaceholder = ''
return math.ceil(overheat * firerate)
renderRowDPS(intable, name, '脚', '胴', '頭', skullpiercerHeader, 'th')
end
end
renderRowDPS(
intable,
'通常',
toDPSText(pellet * legDamage * firerate),
toDPSText(pellet * base * firerate),
toDPSText(pellet * headDamage * firerate),
commonSkullpiercerDPS)
renderRowDPS(
intable,
'小柄',
lowprofileLegDamagePlaceholder,
toDPSText(pellet * selectiveRound(1.05 * base, useRound) * firerate),
toDPSText(pellet * selectiveRound(1.05 * headDamage, useRound) * firerate),
lowprofileSkullpiercerDPS)
renderRowDPS(
intable,
'鉄壁',
toDPSText(pellet * aw.round(0.85 * legDamage) * firerate),
toDPSText(pellet * aw.round(0.85 * base) * firerate),
toDPSText(pellet * aw.round(0.85 * headDamage) * firerate),
fortifiedSkullpiercerDPS)
end
end


local function renderDPS(tbl, name, stat)
local MultipleNumberProto = {
if stat.firerate == nil then
proto.NumberRange(0),
return
proto.NumberRange(0),
end
proto.NumberRange(0),
proto.NumberRange(0),
}
local function renderMagazine(tbl, cfg, stat, isSpecial, isModdedLoaderAttachable)
local magazine = stat.magazine
local typename = type(magazine)
local text
local damage = stat.damage.base
-- 物資投下武器
renderRow(tbl, name, '')
if isSpecial or stat.ammo == 'minigun' then
local magazine2
local pellet = stat.pellet or 1
if typename == 'table' then
local useRound = stat.damage.round or false
magazine2 = magazine[4]
local cell = tbl:tag('tr'):tag('td'):attr('colspan', 2)
else
magazine2 = magazine
if type(damage) == 'table' then
for _, damage in ipairs(damage) do
if stat.mode.single then
renderDPSTable(
cell,
'',
pellet,
damage,
stat.damage,
stat.firerate.single,
useRound)
end
end
end
else
if stat.mode.burst and stat.mode.burst > 1 then
if aw.isNumberAndGreaterThanZero(stat.magazine_reserve) then
local average
if isModdedLoaderAttachable then
if type(stat.firerate.burst_delay) == 'table' then
local moddedLoaderMagazine2 = apex.calcMagazineWithModdedLoader(magazine2)
average = calcBurstAverageRPS(stat, stat.firerate.burst_delay[1])
local moddedLoaderReserve  = stat.magazine_reserve - (moddedLoaderMagazine2 - magazine2)
local intbl = createCellInRow(tbl, cfg.name)
:tag('table')
:addClass('condensedtable')
renderMagazineRow(intbl, '', magazine2, stat.magazine_reserve, cfg)
renderMagazineRow(intbl, iu.passive('modded_loader') .. '&nbsp;', moddedLoaderMagazine2, moddedLoaderReserve, cfg)
return
elseif magazine2 == math.huge then
text = string.format(
'%s <span class="text-separator">/</span> <span class="text-type-number">%s</span>%s',
cfg.infinity,
stat.magazine_reserve == math.huge and cfg.infinity or stat.magazine_reserve,
cfg.unit)
else
else
average = calcBurstAverageRPS(stat)
text = string.format(
'<span class="text-type-number">%d</span>%s <span class="text-separator">/</span> <span class="text-type-number">%s</span>%s',
magazine2,
cfg.unit,
stat.magazine_reserve == math.huge and cfg.infinity or stat.magazine_reserve,
cfg.unit)
end
end
renderDPSTable(
else
cell,
text = string.format('<span class="text-type-number">%d</span>%s', magazine2, cfg.unit)
'',
pellet,
stat.damage.base,
stat.damage,
average,
useRound)
end
end
if stat.mode.auto then
-- 拡張マガジンあり
renderDPSTable(
elseif typename == 'table' then
cell,
if isModdedLoaderAttachable then
local intable = createCellInRow(tbl, cfg.name)
:tag('table')
:addClass('condensedtable')
renderFormatRow(
intable,
'',
'',
pellet,
magazine[1], magazine[2], magazine[3], magazine[4],
stat.damage.base,
{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
stat.damage,
local moddedLoaderMagazine = apex.calcMagazinesWithModdedLoader(magazine)
stat.firerate.auto,
renderFormatRow(
useRound)
intable,
end
iu.passive('modded_loader') .. '&nbsp;',
moddedLoaderMagazine[1],
moddedLoaderMagazine[2],
moddedLoaderMagazine[3],
moddedLoaderMagazine[4],
{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
return
if stat.mode.single and stat.firerate.auto ~= stat.firerate.single then
-- Boosted Loader
renderDPSTable(
elseif stat.boosted_loader and proto.validateTypes(stat.boosted_loader.magazine, MultipleNumberProto) then
cell,
'',
pellet,
stat.damage.base,
stat.damage,
stat.firerate.single,
useRound)
end
if stat.damage.anvil_receiver and stat.firerate.anvil_receiver then
renderDPSTable(
cell,
iu.hopup('アンビルレシーバー'),
pellet,
stat.damage.anvil_receiver.base,
stat.damage.anvil_receiver,
stat.firerate.anvil_receiver,
useRound)
end
end
end
 
local function renderMagazine(tbl, cfg, stat, overheat, firerate, rounds_per_shot, islmg)
local typename = type(stat)
if typename == 'table' then
if islmg then
local intable = createCellInRow(tbl, cfg.name)
local intable = createCellInRow(tbl, cfg.name)
:tag('table')
:tag('table')
:addClass('condensedtable')
:addClass('condensedtable')
:addClass('raritytable')
renderFormatRow(
renderFormatRow(
intable,
intable,
'',
'',
stat[1], stat[2], stat[3], stat[4], { footer = cfg.units })
magazine[1], magazine[2], magazine[3], magazine[4],
{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
renderFormatRow(
renderFormatRow(
intable,
intable,
formatter:hopup('改造ローダー') .. '&nbsp;',
iu.hopup('boosted_loader') .. '&nbsp;',
aw.round(1.15 * stat[1]),
stat.boosted_loader.magazine[1],
aw.round(1.15 * stat[2]),
stat.boosted_loader.magazine[2],
aw.round(1.15 * stat[3]),
stat.boosted_loader.magazine[3],
aw.round(1.15 * stat[4]),
stat.boosted_loader.magazine[4],
{ footer = cfg.units })
{ rarity = 'legendary', separator = '&thinsp;-&thinsp;', footer = cfg.unit })
return
else
else
local text = formatter:format(stat[1], stat[2], stat[3], stat[4], cfg.units, ' - ')
text = formatter:format(magazine[1], magazine[2], magazine[3], magazine[4], cfg.unit, ' - ')
renderRow(tbl, cfg.name, text)
end
end
-- 拡張マガジンなし
elseif typename == 'number' then
elseif typename == 'number' then
local text
if magazine == math.huge then
if stat == math.huge then
if aw.isNumberAndGreaterThanZero(stat.firerate) then
if overheat and firerate and firerate.auto then
if proto.validateTypes(stat.overheat, MultipleNumberProto) then
text = string.format(
local intable = createCellInRow(tbl, cfg.name):tag('table'):addClass('condensedtable')
'%s (%d%s <span class="text-separator">/</span> %s %d%s)',
renderFormatRow(
cfg.infinity,
intable,
1 + math.floor(overheat * firerate.auto),
'',
cfg.unit,
calcVirtualMagSize(stat.overheat[1], stat.firerate),
formatter:hopup('改造ローダー'),
calcVirtualMagSize(stat.overheat[2], stat.firerate),
1 + math.floor(1.15 * overheat * firerate.auto),
calcVirtualMagSize(stat.overheat[3], stat.firerate),
cfg.unit)
calcVirtualMagSize(stat.overheat[4], stat.firerate),
{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
renderFormatRow(
intable,
cfg.seconds.name,
string.format(cfg.seconds.format, stat.overheat[1]),
string.format(cfg.seconds.format, stat.overheat[2]),
string.format(cfg.seconds.format, stat.overheat[3]),
string.format(cfg.seconds.format, stat.overheat[4]),
{ class = 'no-list-style text-secondary text-smaller', headerAlign = 'right', separator = '&thinsp;-&thinsp;', footer = cfg.seconds.unit })
if isModdedLoaderAttachable then
renderFormatRow(
intable,
iu.passive('modded_loader') .. '&nbsp;',
calcVirtualMagSize(stat.overheat[1], stat.firerate, true),
calcVirtualMagSize(stat.overheat[2], stat.firerate, true),
calcVirtualMagSize(stat.overheat[3], stat.firerate, true),
calcVirtualMagSize(stat.overheat[4], stat.firerate, true),
{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
renderFormatRow(
intable,
cfg.seconds.name,
string.format(cfg.seconds.format, 1.15 * stat.overheat[1]),
string.format(cfg.seconds.format, 1.15 * stat.overheat[2]),
string.format(cfg.seconds.format, 1.15 * stat.overheat[3]),
string.format(cfg.seconds.format, 1.15 * stat.overheat[4]),
{ class = 'no-list-style text-secondary text-smaller', headerAlign = 'right', separator = '&thinsp;-&thinsp;', footer = cfg.seconds.unit })
end
return
elseif aw.isNumberAndGreaterThanZero(stat.overheat) then
text = string.format(
'%s (<span class="text-type-number">%d</span>%s <span class="text-separator">/</span> %s <span class="text-type-number">%d</span>%s)',
cfg.infinity,
1 + math.floor(stat.overheat * stat.firerate),
cfg.unit,
iu.passive('modded_loader'),
1 + math.floor(1.15 * stat.overheat * stat.firerate),
cfg.unit)
else
text = cfg.infinity
end
else
else
text = cfg.infinity
text = cfg.infinity
end
end
elseif rounds_per_shot and rounds_per_shot.single and rounds_per_shot.single > 1 then
local times = stat / rounds_per_shot.single
elseif aw.isNumberAndGreaterThanX(stat.ammo_per_shot, 1) then
local times = magazine / stat.ammo_per_shot
local timesText
local timesText
if type(cfg.times.format) == 'table' then
if type(cfg.times.format) == 'table' then
619行目: 685行目:
text = string.format(
text = string.format(
'<span class="text-type-number">%d</span>%s <span class="text-secondary"><small>(%s)</small></span>',
'<span class="text-type-number">%d</span>%s <span class="text-secondary"><small>(%s)</small></span>',
stat, cfg.unit, timesText)
magazine, cfg.unit, timesText)
else
else
text = string.format('<span class="text-type-number">%d</span>%s', stat, cfg.unit)
text = string.format('<span class="text-type-number">%d</span>%s', magazine, cfg.unit)
end
end
renderRow(tbl, cfg.name, text)
end
end
renderRow(tbl, cfg.name, text)
end
end


local function renderReload(tbl, cfg, reload, attachments, ammo, islmg)
local function renderDuration(tbl, cfg, stat, lang)
if reload.full == nil then
local node, isSimple = require('Module:WeaponInfobox/Duration').renderDuration(stat, lang)
return
local cell = createCellInRow(tbl, cfg.name)
end
if isSimple then
cell:node(node)
local muls
if ammo == 'heavy' or ammo == 'special_heavy' then
muls = { level2 = 0.92, level3 = 0.87 }
else
else
muls = { level2 = 0.95, level3 = 0.9 }
tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
end
end
end
local incompatible = not attachments.extended_mag_or_shotgun_bolt
 
if incompatible or ammo == 'shotgun' or aw.stringstarts(ammo, "special_") then
local function renderSpread(tbl, cfg, stat, lang, frame)
if reload.tactical ~= nil and reload.tactical ~= reload.full then
local Spread = require('Module:WeaponInfobox/Spread')
local tacticalText, fullText
local node = Spread.renderSpread(stat.spread, stat.attachments.laser_sight, stat.quickdraw_holster and stat.quickdraw_holster.spread, lang)
if incompatible or ammo == 'special_sniper' then
local cell = createCellInRow(tbl, cfg.name)
tacticalText = tostring(reload.tactical)
if node.tagName == 'span' then
fullText    = tostring(reload.full)
cell:node(node)
else
elseif Hopup.anvil_receiver.enabled and stat.anvil_receiver and stat.anvil_receiver.spread then
tacticalText = tostring(muls.level3 * reload.tactical)
local node2 = Spread.renderSpread(stat.anvil_receiver.spread, stat.attachments.laser_sight, nil, lang)
fullText    = tostring(muls.level3 * reload.full)
if frame then
end
local tabContent = string.format(
'{{#tab:%s|%s}}{{#tab:%s|%s}}',
local intable = createCellInRow(tbl, cfg.name)
cfg.normal, tostring(node),
:tag('table')
cfg.anvil_receiver, tostring(node2))
:addClass('condensedtable')
tbl:tag('tr')
:addClass('listtable')
:tag('td')
renderFormatRow(
:attr('colspan', 2)
intable,
:wikitext(frame:extensionTag { name = 'tabs', content = tabContent, args = { class = 'tabs-intable' }})
cfg.tactical.name .. '&nbsp;',
string.format(cfg.tactical.format, reload.tactical),
nil, nil, nil, { footer = cfg.tactical.unit })
if islmg then
renderFormatRow(
intable,
formatter:hopup('改造ローダー') .. '&nbsp;',
string.format(cfg.tactical.format, 0.75 * reload.tactical),
nil, nil, nil, { class = 'no-list-style', headerAlign = 'right', footer = cfg.tactical.unit })
end
renderFormatRow(
intable,
cfg.full.name .. '&nbsp;',
string.format(cfg.full.format, reload.full),
nil, nil, nil, { footer = cfg.full.unit })
if islmg then
renderFormatRow(
intable,
formatter:hopup('改造ローダー') .. '&nbsp;',
string.format(cfg.full.format, 0.75 * reload.full),
nil, nil, nil, { class = 'no-list-style', headerAlign = 'right', footer = cfg.full.unit })
end
elseif islmg then
local time
if incompatible then
time = reload.full
else
time = muls.level3 * reload.full
end
local text = string.format(
cfg.full.format .. cfg.full.unit .. ' <span class="text-separator">/</span> %s ' .. cfg.full.format .. cfg.full.unit,
time,
formatter:hopup('改造ローダー'),
0.75 * time)
renderRow(tbl, cfg.name, text)
else
else
local time
tbl:tag('tr')
if incompatible or ammo == 'special_sniper' then
:tag('td')
time = reload.full
:attr('colspan', 2)
else
:tag('b')
time = muls.level3 * reload.full
:wikitext(cfg.normal)
end
:done()
renderRow(tbl, cfg.name, string.format(cfg.full.format, time) .. cfg.full.unit)
:node(node)
:tag('b')
:wikitext(cfg.anvil_receiver)
:done()
:node(node2)
end
end
elseif reload.tactical ~= nil and reload.tactical ~= reload.full then
elseif stat.spread_charged then
renderRow(tbl, cfg.name, '')
local node2 = Spread.renderSpread(stat.spread_charged , nil, lang)
if frame then
local intable = tbl:tag('tr')
local tabContent = string.format(
:tag('td')
'{{#tab:%s|%s}}{{#tab:%s|%s}}',
:attr('colspan', 2)
cfg.normal, tostring(node),
:tag('table')
cfg.full_charge, tostring(node2))
:addClass('condensedtable')
tbl:tag('tr')
:addClass('listtable')
:tag('td')
renderFormatRow(
:attr('colspan', 2)
intable,
:wikitext(frame:extensionTag { name = 'tabs', content = tabContent, args = { class = 'tabs-intable' }})
cfg.tactical.name .. '&nbsp;',
else
string.format(cfg.tactical.format, reload.tactical),
tbl:tag('tr')
nil,
:tag('td')
string.format(cfg.tactical.format, muls.level2 * reload.tactical),
:attr('colspan', 2)
string.format(cfg.tactical.format, muls.level3 * reload.tactical),
:tag('b')
{ footer = cfg.tactical.unit })
:wikitext(cfg.normal)
if islmg then
:done()
renderFormatRow(
:node(node)
intable,
:tag('b')
formatter:hopup('改造ローダー') .. '&nbsp;',
:wikitext(cfg.full_charge)
string.format(cfg.tactical.format, 0.75 * reload.tactical),
:done()
nil,
:node(node2)
string.format(cfg.tactical.format, 0.75 * muls.level2 * reload.tactical),
string.format(cfg.tactical.format, 0.75 * muls.level3 * reload.tactical),
{ class = 'no-list-style', headerAlign = 'right', footer = cfg.tactical.unit })
end
renderFormatRow(
intable,
cfg.full.name .. '&nbsp;',
string.format(cfg.full.format, reload.full),
nil,
string.format(cfg.full.format, muls.level2 * reload.full),
string.format(cfg.full.format, muls.level3 * reload.full),
{ footer = cfg.full.unit })
if islmg then
renderFormatRow(
intable,
formatter:hopup('改造ローダー') .. '&nbsp;',
string.format(cfg.full.format, 0.75 * reload.full),
nil,
string.format(cfg.full.format, 0.75 * muls.level2 * reload.full),
string.format(cfg.full.format, 0.75 * muls.level3 * reload.full),
{ class = 'no-list-style', headerAlign = 'right', footer = cfg.full.unit })
end
end
else
else
local text = formatter:format(
tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
string.format(cfg.full.format, reload.full),
nil,
string.format(cfg.full.format, muls.level2 * reload.full),
string.format(cfg.full.format, muls.level3 * reload.full),
cfg.full.unit, ' - ')
renderRow(tbl, cfg.name, text)
end
end
end
end


local function renderDraw(tbl, cfg, draw, quickdraw_holster, attachments, ammo)
local function renderSpreadDecayRow(intbl, name, cfg, spread, opts)
if draw == nil then
opts = opts or {}
intbl:tag('tr')
:addClassIf(type(opts.rarity) == 'string', 'row-rarity-one disp-rarity-' .. (opts.rarity or 'common'))
:tag('th')
:wikitext(name)
:done()
:tag('td')
:addClass('cell-type-number')
:attr('align', 'right')
:wikitext(string.format(cfg.rate.format, spread.decay_rate))
:done()
:tag('td')
:wikitext(cfg.rate.unit)
:done()
:tag('td')
:addClass('text-smaller')
:wikitext(cfg.delay.name)
:done()
:tag('td')
:addClass('cell-type-number')
:addClass('text-smaller')
:attr('align', 'right')
:wikitext(string.format(cfg.delay.format, spread.decay_delay))
:done()
:tag('td')
:addClass('text-smaller')
:wikitext(cfg.delay.unit)
end
 
local function renderSpreadDecay(tbl, cfg, stat)
if not (aw.isNumberAndGreaterThanZero(stat.spread.decay_rate) and aw.isNumberAndGreaterThanZero(stat.spread.decay_delay)) then
return
return
end
end
local muls
local cell = createCellInRow(tbl, cfg.name)
if ammo == 'heavy' or ammo == 'special_heavy' then
muls = { level2 = 0.92, level3 = 0.87 }
else
muls = { level2 = 0.95, level3 = 0.9 }
end
local incompatible = not attachments.stock
-- [Hop-up] Anvil Receiver
if incompatible or aw.stringstarts(ammo, "special_") then
if stat.anvil_receiver and stat.anvil_receiver.spread and aw.isNumberAndGreaterThanZero(stat.anvil_receiver.spread.decay_rate) and aw.isNumberAndGreaterThanZero(stat.anvil_receiver.spread.decay_delay) then
local time
local intbl = cell:tag('table')
if incompatible or ammo == 'special_sniper' then
:addClass('condensedtable')
time = draw
:addClass('raritytable')
else
renderSpreadDecayRow(
time = 0.75 * draw
intbl,
end
local text
if quickdraw_holster > 0 then
text = string.format(
cfg.format .. cfg.unit .. ' <span class="text-separator">/</span> %s ' .. formatter:epic(cfg.format .. cfg.unit),
time,
iu.hopup('クイックドローホルスター'),
quickdraw_holster * time)
else
text = string.format(cfg.format, time) .. cfg.unit
end
renderRow(tbl, cfg.name, text)
elseif quickdraw_holster > 0 then
local intable = createCellInRow(tbl, cfg.name)
:tag('table')
:addClass('condensedtable')
renderFormatRow(
intable,
'',
'',
string.format(cfg.format, draw),
cfg,
string.format(cfg.format, 0.85 * draw),
stat.spread)
string.format(cfg.format, 0.80 * draw),
renderSpreadDecayRow(
string.format(cfg.format, 0.75 * draw),
intbl,
{ footer = cfg.unit })
iu.hopup('anvil_receiver') .. '&nbsp;',
renderFormatRow(
cfg,
intable,
stat.anvil_receiver.spread,
iu.hopup('クイックドローホルスター') .. '&nbsp;',
{ rarity = 'legendary' })
string.format(cfg.format, quickdraw_holster * draw),
string.format(cfg.format, 0.85 * quickdraw_holster * draw),
string.format(cfg.format, 0.80 * quickdraw_holster * draw),
string.format(cfg.format, 0.75 * quickdraw_holster * draw),
{ footer = cfg.unit })
else
else
local text = formatter:format(
local text = string.format(cfg.format, stat.spread.decay_rate, stat.spread.decay_delay)
string.format(cfg.format, draw),
cell:wikitext(text)
string.format(cfg.format, 0.85 * draw),
string.format(cfg.format, 0.80 * draw),
string.format(cfg.format, 0.75 * draw),
cfg.unit, ' - ')
renderRow(tbl, cfg.name, text)
end
end
end
end


local function createTable(cfg, stat)
local function createTable(cfg, name, stat, lang, frame)
local islmg = stat.category == 'light_machine_gun'
local isSpecial = aw.stringstarts(stat.ammo, "special_")
local isModdedLoaderAttachable = stat.category == 'light_machine_gun' or stat.ammo == 'minigun'
local tbl = mw.html.create('table')
local tbl = mw.html.create('table')
renderReleaseDate(tbl, cfg.release, stat.release)
renderReleaseDate(tbl, cfg.release, stat.release)
renderCategory(tbl, cfg.category, stat.category)
renderCategory(tbl, cfg.category, stat.category, lang)
renderAmmo(tbl, cfg.ammo, stat.ammo)
renderAmmo(tbl, cfg.ammo, stat.ammo, lang)
renderMode(tbl, cfg.mode, stat.mode)
renderCost(tbl, cfg.cost, stat.cost, stat.ammo)
renderDamage(tbl, cfg.damage, stat.damage, stat.ammo, stat.pellet)
renderMode(tbl, cfg.mode, stat, isSpecial)
renderFirerate(tbl, cfg.firerate, stat)
renderDamage(tbl, cfg.damage, stat, isSpecial)
renderProjectileSpeed(tbl, cfg.projectilespeed, stat.projectile_speed)
if stat.firerate then
renderMagazine(tbl, cfg.magazine, stat.magazine, stat.overheat, stat.firerate, stat.rounds_per_shot, islmg)
renderFirerate(tbl, cfg.firerate, stat, lang)
end
renderProjectileSpeed(tbl, cfg.projectilespeed, stat.projectile_speed, stat.projectile_speed_charged)
renderMoveSpeed(tbl, cfg.movespeed, stat, stat)
renderMagazine(tbl, cfg.magazine, stat, isSpecial, isModdedLoaderAttachable)
if stat.firerate and name ~= 'ボセックコンパウンドボウ' then
renderDPS(tbl, cfg.dps, stat, lang)
end
if stat.time then
if stat.time then
if stat.time.draw then
renderDuration(tbl, cfg.duration, stat, lang)
renderDraw(tbl, cfg.draw, stat.time.draw, stat.time.quickdraw_holster or 0, stat.attachments, stat.ammo)
end
end
if stat.spread then
renderSpread(tbl, cfg.spread, stat, lang, frame)
if stat.time.reload then
renderSpreadDecay(tbl, cfg.spreaddecay, stat)
renderReload(tbl, cfg.reload, stat.time.reload, stat.attachments, stat.ammo, islmg)
end
end
end
renderDPS(tbl, 'DPS', stat)
return tbl
return tbl
end
end


local function renderInfobox(args)
local function renderInfobox(args, frame)
local cfglang = cfg[args and args.lang or 'ja']
local lang = args and args.lang or 'ja'
local cfglang = cfg[lang]
local stat = mw.loadData('Module:Stat/Weapon')[args.name]
local stat = mw.loadData('Module:Stat/Weapon')[args.name]
local div = mw.html.create('div')
local div = mw.html.create('div')
861行目: 868行目:
:addClass('tpl-weapon-header')
:addClass('tpl-weapon-header')
:wikitext(args.name .. iu.ammo(stat.ammo, { size = 40 }))
:wikitext(args.name .. iu.ammo(stat.ammo, { size = 40 }))
div:node(createTable(cfglang, stat))
div:node(createTable(cfglang, args.name, stat, lang, frame))
return div
return div
end
end
867行目: 874行目:
function p._main(args, frame)
function p._main(args, frame)
formatter = require('Module:Utility/Formatter').new(frame)
formatter = require('Module:Utility/Formatter').new(frame)
return tostring(renderInfobox(args))
return tostring(renderInfobox(args, frame))
end
end



2022年8月13日 (土) 12:12時点における最新版

このモジュールについての説明文ページを モジュール:WeaponInfobox/doc に作成できます

require('Module:Utility/mw.html Extensions')

local p = {}
local cfg = mw.loadData('Module:WeaponInfobox/configuration')
local Hopup = mw.loadData('Module:Stat/Hopup')

local aw    = require('Module:Utility/Library')
local apex  = require('Module:Utility/ApexLibrary')
local iu    = require('Module:Utility/Image')
local inu   = require('Module:Utility/ImageWithName')
local nu    = require('Module:Utility/Name')
local proto = require('Module:Utility/Prototypes')
local StringBuilder = require('Module:Utility/StringBuilder')
local formatter -- lazily initialized
local getArgs -- lazily initialized

local function createCellInRow(tbl, name)
	return tbl:tag('tr')
		:tag('th')
			:wikitext(name)
			:done()
		:tag('td')
end

local function renderRow(tbl, name, item)
	createCellInRow(tbl, name):wikitext(item)
end

local function renderFormatRow(tbl, name, default, common, rare, epic, opts)
	opts = opts or {}
	opts.separator = opts.separator or '&nbsp;-&nbsp;'
	local row = tbl:tag('tr')
		:addClassIf(type(opts.class)  == 'string', opts.class)
		:addClassIf(type(opts.rarity) == 'string', 'row-rarity-one disp-rarity-' .. (opts.rarity or 'common'))
	
	if name ~= nil then
		row:tag('th')
			:attrIf(opts.headerAlign and type(opts.headerAlign) == 'string', { align = opts.headerAlign })
			:wikitext(name)
	end

	local first = true
	if default ~= nil then
		first = false
		row:tag('td')
			:addClass('cell-type-number')
			:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
			:wikitext(default)
	end
	
	if common ~= nil then
		if not first then
			row:tag('td'):wikitext(opts.separator)
		end
		first = false
		row:tag('td')
			:addClass('cell-type-number')
			:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
			:tag('span')
				:addClass('text-rarity')
				:addClass('text-rarity-common')
				:wikitext(common)
	end
	
	if rare ~= nil then
		if not first then
			row:tag('td'):wikitext(opts.separator)
		end
		first = false
		row:tag('td')
			:addClass('cell-type-number')
			:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
			:tag('span')
				:addClass('text-rarity')
				:addClass('text-rarity-rare')
				:wikitext(rare)
	end
	
	if epic ~= nil then
		if not first then
			row:tag('td'):wikitext(opts.separator)
		end
		first = false
		row:tag('td')
			:addClass('cell-type-number')
			:attrIf(opts.align and type(opts.align) == 'string', { align = opts.align })
			:tag('span')
				:addClass('text-rarity')
				:addClass('text-rarity-epic')
				:wikitext(epic)
	end
	
	if opts.footer ~= nil then
		row:tag('td')
			:attrIf(opts.footerAlign   and type(opts.footerAlign) == 'string',   { align   = opts.footerAlign }, { align = 'left' })
			:attrIf(opts.footerColspan and type(opts.footerColspan) == 'number', { colspan = opts.footerColspan })
			:wikitext(opts.footer)
	end
	return row
end

local function renderReleaseDate(tbl, cfg, release)
	local r = os.date("*t", release)
	local releaseText = string.format(
		'<time datetime="%04d-%02d-%02dT%02d:00:00.000+0900">%d年%d月%d日 %d時</time>~',
		r.year, r.month, r.day, r.hour, r.year, r.month, r.day, r.hour)
	renderRow(tbl, cfg.name, releaseText)
end

local function renderCategory(tbl, cfg, stat, lang)
	local category = nu.type(stat, lang, 1)
	local item
	if lang == 'ja' then
		item = string.format('[[武器#%s|%s]][[Category:%s]]', category, category, category)
	else
		item = string.format('%s[[Category:%s]]', category, category)
	end
	renderRow(tbl, cfg.name, item)
end

local function renderAmmo(tbl, cfg, stat, lang)
	createCellInRow(tbl, cfg.name)
		:addClass('cell-ammo')
		:wikitext(inu.ammo(stat, { lang = lang, size = 24 }))
end

local function renderCost(tbl, cfg, stat, ammo)
	if stat == nil or aw.stringstarts(ammo, 'special_') then
		return
	end
	
	local text = formatter:format(
		aw.comma(stat[1]),
		aw.comma(stat[2]),
		aw.comma(stat[3]),
		aw.comma(stat[4]),
		'', ' - ')
	renderRow(tbl, cfg.name, cfg.header .. text)
end

local function appendMode(builder, cfg, stat, base)
	if stat.is_semi_auto or (stat.is_semi_auto == nil and base.is_semi_auto) then
		local burstCount = stat.burst_count or (base and base.burst_count) or 1
		if aw.isNumberAndGreaterThanOrEqualToX(burstCount, 2) then
			builder:appendFormat(cfg.burst, burstCount)
			builder:append(cfg.burst_category)
		else
			builder:append(cfg.single, cfg.single_category)
		end
	else
		builder:append(cfg.auto, cfg.auto_category)
	end
end

local function renderMode(tbl, cfg, stat, isSpecial)
	local builder = StringBuilder.new()
	appendMode(builder, cfg, stat)
	if stat.altfire then
		builder:append(cfg.separator)
		appendMode(builder, cfg, stat.altfire, stat)
	end
	if (Hopup.selectfire_receiver.enabled or isSpecial) and stat.selectfire_receiver then
		builder:append(cfg.separator, '<span class="block-rarity disp-rarity-epic">', iu.hopup('selectfire_receiver'), ' ')
		appendMode(builder, cfg, stat.selectfire_receiver, stat)
		builder:append('</span>')
	end
	if (Hopup.double_tap_trigger.enabled or isSpecial) and stat.double_tap_trigger then
		builder:append(cfg.separator, '<span class="block-rarity disp-rarity-epic">', iu.hopup('double_tap_trigger'), ' ')
		appendMode(builder, cfg, stat.double_tap_trigger, stat)
		builder:append('</span>')
	end
	renderRow(tbl, cfg.name, tostring(builder))
end

local HammerpointRoundsProto = {
	hammerpoint_rounds = {
		damage_unshielded_scale = proto.NumberRange(1),
	},
}
local DisruptorRoundsProto = {
	disruptor_rounds = {
		damage_shield_scale = proto.NumberRange(1),
	},
}
local function getDamageText(stat, root, isSpecial)
	local builder = StringBuilder.new()
	local rarity  = isSpecial and 'heirloom'
	local damage, pellet
	if root then
		damage = stat.damage or root.damage
		pellet = stat.pellet or root.pellet or 1
	else
		damage = stat.damage
		pellet = stat.pellet or 1
	end
	if aw.isNumberAndGreaterThanOrEqualToX(pellet, 2) then
		builder:appendFormat(
			'<span class="text-type-number">%s</span>&thinsp;&times;&thinsp;%d',
			damage.base,
			pellet)
		
		if aw.isNumberAndGreaterThanZero(damage.charged) then
			builder:appendFormat(
				'&thinsp;&rarr;&thinsp;<span class="text-type-number">%s</span>&thinsp;&times;&thinsp;%d',
				damage.charged,
				pellet)
		elseif proto.validateTypes(stat, HammerpointRoundsProto) then
			if not rarity then
				rarity = Hopup.hammerpoint_rounds.rarity
			end
			builder:appendFormat(
				'&thinsp;&rarr;&thinsp;<span class="block-rarity disp-rarity-%s text-rarity text-rarity-%s">%s \'\'\'<span class="text-type-number">%s</span>&thinsp;&times;&thinsp;%d\'\'\'</span>',
				rarity,
				rarity,
				iu.hopup('hammerpoint_rounds', { rarity = rarity }),
				math.floor(damage.base * stat.hammerpoint_rounds.damage_unshielded_scale),
				pellet)
		end
	else
		if aw.isNumberAndGreaterThanZero(damage.amped) then
			builder:appendFormat(
				'<span class="text-type-number">%s</span> <span class="text-separator">/</span> %s&nbsp;<span class="text-type-number">%s</span>',
				damage.base,
				iu.item('シールドセル'),
				damage.amped)
		elseif aw.isNumberAndGreaterThanZero(damage.charged) then
			builder:appendFormat(
				'<span class="text-type-number">%s</span>&thinsp;&rarr;&thinsp;<span class="text-type-number">%s</span>',
				damage.base,
				damage.charged)
		elseif proto.validateTypes(stat, HammerpointRoundsProto) then
			if not rarity then
				rarity = Hopup.hammerpoint_rounds.rarity
			end
			builder:appendFormat(
				'<span class="text-type-number">%s</span>&thinsp;&rarr;&thinsp;<span class="block-rarity disp-rarity-%s text-rarity text-rarity-%s">%s \'\'\'<span class="text-type-number">%s</span>\'\'\'</span>',
				damage.base,
				rarity,
				rarity,
				iu.hopup('hammerpoint_rounds', { rarity = rarity }),
				math.floor(damage.base * stat.hammerpoint_rounds.damage_unshielded_scale))
		elseif proto.validateTypes(stat, DisruptorRoundsProto) then
			if not rarity then
				rarity = Hopup.disruptor_rounds.rarity
			end
			builder:appendFormat(
				'<span class="block-rarity disp-rarity-%s text-rarity text-rarity-%s">%s \'\'\'<span class="text-type-number">%s</span>\'\'\'</span>&thinsp;&rarr;&thinsp;<span class="text-type-number">%s</span>',
				rarity,
				rarity,
				iu.hopup('disruptor_rounds', { rarity = rarity }),
				math.floor(damage.base * stat.disruptor_rounds.damage_shield_scale),
				damage.base)
		else
			builder:appendFormat('<span class="text-type-number">%s</span>', damage.base)
		end
	end
	return tostring(builder)
end

local function renderHeadRow(tbl, name, head, cfg, nolist)
	local opts = { align = 'left', footer = cfg.unit }
	if nolist then
		opts.class = 'no-list-style'
		opts.headerAlign = 'right'
	end
	renderFormatRow(
		tbl,
		name,
		nil,
		apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV1),
		apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV2),
		apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV3),
		opts)
end

local function renderHeadEffectiveRange(tbl, cfg, stat, root)
	local headDist = stat.damage_head_distance or root.damage_head_distance
	if aw.isNumberAndGreaterThanZero(headDist) then
		local text = string.format(cfg.head_effective_range, 0.0254 * headDist)
		tbl:tag('tr')
			:addClass('no-list-style')
			:tag('td')
				:attr('align', 'left')
				:attr('colspan', 7)
				:wikitext(text)
	end
end

local function renderLegsRow(tbl, cfg, stat, root)
	local legs = stat.damage_legs_scale or root.damage_legs_scale
	local text
	if aw.isNumberAndGreaterThanZero(stat.legshot_charged) then
		text = string.format(
			'<span class="text-type-number">%s</span> &rarr; <span class="text-type-number">%s</span>%s',
			legs,
			stat.legshot_charged,
			cfg.unit)
	else
		text = string.format(
			'<span class="text-type-number">%s</span>%s',
			legs,
			cfg.unit)
	end
	tbl:tag('tr')
		:tag('th')
			:wikitext(cfg.legs)
			:done()
		:tag('td')
			:attr('align', 'left')
			:attr('colspan', 6)
			:wikitext(text)
end

local DamageProto = {
	damage = {
		base     = proto.NumberRange(1),
	},
	damage_head_scale = proto.NumberRange(1),
	damage_legs_scale = proto.NumberRange(0, 1),
}
local ShatterCapsProto = {
	damage = {
		base     = proto.NumberRange(1),
	},
	damage_head_scale = proto.NumberRange(1),
	damage_legs_scale = proto.NumberRange(0, 1),
	pellet = proto.NumberRange(1),
}
local damageHopups = {
	{
		name = 'selectfire_receiver',
		proto = DamageProto,
		textclass = 'text-rarity-epic',
		dispclass = 'disp-rarity-epic',
	},
	{
		name = 'anvil_receiver',
		proto = DamageProto,
		textclass = 'text-rarity-legendary',
		dispclass = 'disp-rarity-legendary',
	},
	{
		name = 'shatter_caps',
		proto = ShatterCapsProto,
		textclass = 'text-rarity-epic',
		dispclass = 'disp-rarity-epic',
	},
}
local function renderDamage(tbl, cfg, stat, isSpecial)
	if not proto.validateTypes(stat, DamageProto) then
		return
	end
	
	local cattext = string.format(cfg.head_category, stat.damage.headshot_charged or stat.damage_head_scale or 1)
	local cell = createCellInRow(tbl, cfg.name)
	cell:wikitext(cattext .. getDamageText(stat, nil, isSpecial))
		
	-- Headshot
	local head = stat.damage_head_scale or 1
	local intable = cell:tag('table')
		:addClass('condensedtable')
		:addClass('listtable')
	renderHeadRow(intable, cfg.head, head, cfg)
	
	local hlmc = stat.damage.headshot_charged or 1
	if hlmc > 1 then
		local nameC = '→&nbsp;'
		renderHeadRow(intable, nameC, hlmc, cfg, true)
	end
	
	local sprm = stat.damage.skullpiercer_rifling or 1
	if sprm > 1 then
		local nameS = iu.hopup('skullpiercer_rifling') .. '&nbsp;'
		renderHeadRow(intable, nameS, sprm, cfg, true)
	end
	renderHeadEffectiveRange(intable, cfg, stat, stat)
	
	-- Legsshot
	renderLegsRow(intable, cfg, stat, stat)
	
	-- [Hop-Up] Selectfire Receiver, Anvil Receiver & Shatter Caps
	for _, v in ipairs(damageHopups) do
		local hopupStat = stat[v.name]
		if (Hopup[v.name].enabled or isSpecial) and proto.validateTypes(hopupStat, v.proto) then
			local intblS = cell:tag('div')
				:addClass('tpl-weapon-inbox')
				:addClass(specialOnly and 'disp-rarity-heirloom' or v.dispclass)
				:wikitext(iu.hopup(v.name) .. '&nbsp;')
				:tag('span')
					:addClass('text-rarity')
					:addClass(specialOnly and 'text-rarity-heirloom' or v.textclass)
					:wikitext(getDamageText(hopupStat, stat))
					:done()
				:tag('table')
					:addClass('condensedtable')
					:addClass('listtable')
			
			local head = hopupStat.damage_head_scale or stat.damage_head_scale or 1
			renderHeadRow(intblS, cfg.head, head, cfg)
			renderHeadEffectiveRange(intblS, cfg, hopupStat, stat)
			renderLegsRow           (intblS, cfg, hopupStat, stat)
		end
	end
end

local function renderFirerate(tbl, cfg, stat, lang)
	local cell = createCellInRow(tbl, cfg.name)
	local node, newcell = require('Module:WeaponInfobox/Firerate').renderFirerate(stat, lang)
	if newcell then
		tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
	else
		cell:node(node)
	end
end

local function renderProjectileSpeed(tbl, cfg, projectile_speed, projectile_speed_charged)
	if not aw.isNumberAndGreaterThanZero(projectile_speed) then
		return
	end
	
	local text
	if projectile_speed == math.huge then
		text = cfg.hitscan
	elseif aw.isNumberAndGreaterThanZero(move_speed_charged) then
		text = string.format(
			'<span class="text-type-number">%s</span> → <span class="text-type-number">%s</span>%s',
			string.format(cfg.format, aw.comma(aw.roundx(0.0254 * projectile_speed, 2))),
			string.format(cfg.format, aw.comma(aw.roundx(0.0254 * projectile_speed_charged, 2))),
			cfg.unit)
	else
		text = string.format(
			'<span class="text-type-number">%s</span>%s',
			string.format(cfg.format, aw.comma(aw.roundx(0.0254 * projectile_speed, 2))),
			cfg.unit)
	end
	renderRow(tbl, cfg.name, text)
end

local ShatterCapsMoveSpeedProto = {
	shatter_caps = {
		move_speed = proto.NumberRange(0, 1),
	},
}
local function getMoveSpeedText(cfg, moveSpeed)
	return string.format(
		'<span class="text-type-number">%s</span>%s',
		string.format(cfg.format, 100 * (moveSpeed - 1)),
		cfg.unit)
end
local function renderMoveSpeed(tbl, cfg, stat)
	if not aw.isNumberAndGreaterThanZero(stat.move_speed) then
		return
	end
	
	local text
	
	-- [Hop-up] Shatter Caps
	if proto.validateTypes(stat, ShatterCapsMoveSpeedProto) and stat.move_speed ~= stat.shatter_caps.move_speed then
		text = string.format(
			'%s%s<span class="block-rarity disp-rarity-epic text-rarity text-rarity-epic">%s %s</span>',
			getMoveSpeedText(cfg, stat.move_speed),
			cfg.separator,
			iu.hopup('shatter_caps'),
			getMoveSpeedText(cfg, stat.shatter_caps.move_speed))
	elseif aw.isNumberAndGreaterThanZero(stat.move_speed_charged) then
		text = string.format(
			'%s → %s',
			getMoveSpeedText(cfg, stat.move_speed),
			getMoveSpeedText(cfg, stat.move_speed_charged),
			cfg.unit)
	else
		text = getMoveSpeedText(cfg, stat.move_speed)
	end
	renderRow(tbl, cfg.name, text)
end

local function renderDPS(tbl, cfg, stat, lang)
	local sld  = require('Module:Stat/Shield')['reinforcehelmets']
	local node = require('Module:WeaponInfobox/DPS').renderDPS(stat, sld, lang)
	createCellInRow(tbl, cfg.name)
	tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
end

local function renderMagazineRow(intbl, name, mag, rsvmag, cfg, opts)
	opts = opts or {}
	intbl:tag('tr')
		:addClassIf(opts.class and type(opts.class) == 'string', opts.class)
		:tag('th')
			:wikitext(name)
			:done()
		:tag('td')
			:addClass('cell-type-number')
			:attr('align', 'right')
			:wikitext(mag)
			:done()
		:tag('td')
			:wikitext(cfg.unit)
			:done()
		:tag('td')
			:addClass('text-secondary')
			:wikitext('&nbsp;/&nbsp;')
			:done()
		:tag('td')
			:addClass('cell-type-number')
			:attr('align', 'right')
			:wikitext(rsvmag == math.huge and cfg.infinity or rsvmag)
			:done()
		:tag('td')
			:wikitext(cfg.unit)
end

local function calcVirtualMagSize(overheat, firerate, moddedLoader)
	if moddedLoader then
		return math.ceil(1.15 * overheat * firerate)
	else
		return math.ceil(overheat * firerate)
	end
end

local MultipleNumberProto = {
	proto.NumberRange(0),
	proto.NumberRange(0),
	proto.NumberRange(0),
	proto.NumberRange(0),
}
local function renderMagazine(tbl, cfg, stat, isSpecial, isModdedLoaderAttachable)
	local magazine = stat.magazine
	local typename = type(magazine)
	local text
	
	-- 物資投下武器
	if isSpecial or stat.ammo == 'minigun' then
		local magazine2
		if typename == 'table' then
			magazine2 = magazine[4]
		else
			magazine2 = magazine
		end
		
		if aw.isNumberAndGreaterThanZero(stat.magazine_reserve) then
			if isModdedLoaderAttachable then
				local moddedLoaderMagazine2 = apex.calcMagazineWithModdedLoader(magazine2)
				local moddedLoaderReserve   = stat.magazine_reserve - (moddedLoaderMagazine2 - magazine2)
				local intbl = createCellInRow(tbl, cfg.name)
					:tag('table')
						:addClass('condensedtable')
				renderMagazineRow(intbl, '', magazine2, stat.magazine_reserve, cfg)
				renderMagazineRow(intbl, iu.passive('modded_loader') .. '&nbsp;', moddedLoaderMagazine2, moddedLoaderReserve, cfg)
				return
			elseif magazine2 == math.huge then
				text = string.format(
					'%s <span class="text-separator">/</span> <span class="text-type-number">%s</span>%s',
					cfg.infinity,
					stat.magazine_reserve == math.huge and cfg.infinity or stat.magazine_reserve,
					cfg.unit)
			else
				text = string.format(
					'<span class="text-type-number">%d</span>%s <span class="text-separator">/</span> <span class="text-type-number">%s</span>%s',
					magazine2,
					cfg.unit,
					stat.magazine_reserve == math.huge and cfg.infinity or stat.magazine_reserve,
					cfg.unit)
			end
		else
			text = string.format('<span class="text-type-number">%d</span>%s', magazine2, cfg.unit)
		end
	
	-- 拡張マガジンあり
	elseif typename == 'table' then
		if isModdedLoaderAttachable then
			local intable = createCellInRow(tbl, cfg.name)
				:tag('table')
					:addClass('condensedtable')
			renderFormatRow(
				intable,
				'',
				magazine[1], magazine[2], magazine[3], magazine[4],
				{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
			local moddedLoaderMagazine = apex.calcMagazinesWithModdedLoader(magazine)
			renderFormatRow(
				intable,
				iu.passive('modded_loader') .. '&nbsp;',
				moddedLoaderMagazine[1],
				moddedLoaderMagazine[2],
				moddedLoaderMagazine[3],
				moddedLoaderMagazine[4],
				{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
			return
		
		-- Boosted Loader
		elseif stat.boosted_loader and proto.validateTypes(stat.boosted_loader.magazine, MultipleNumberProto) then
			local intable = createCellInRow(tbl, cfg.name)
				:tag('table')
					:addClass('condensedtable')
					:addClass('raritytable')
			renderFormatRow(
				intable,
				'',
				magazine[1], magazine[2], magazine[3], magazine[4],
				{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
			renderFormatRow(
				intable,
				iu.hopup('boosted_loader') .. '&nbsp;',
				stat.boosted_loader.magazine[1],
				stat.boosted_loader.magazine[2],
				stat.boosted_loader.magazine[3],
				stat.boosted_loader.magazine[4],
				{ rarity = 'legendary', separator = '&thinsp;-&thinsp;', footer = cfg.unit })
			return
		
		else
			text = formatter:format(magazine[1], magazine[2], magazine[3], magazine[4], cfg.unit, ' - ')
		end
	
	-- 拡張マガジンなし
	elseif typename == 'number' then
		if magazine == math.huge then
			if aw.isNumberAndGreaterThanZero(stat.firerate) then
				if proto.validateTypes(stat.overheat, MultipleNumberProto) then
					local intable = createCellInRow(tbl, cfg.name):tag('table'):addClass('condensedtable')
					renderFormatRow(
						intable,
						'',
						calcVirtualMagSize(stat.overheat[1], stat.firerate),
						calcVirtualMagSize(stat.overheat[2], stat.firerate),
						calcVirtualMagSize(stat.overheat[3], stat.firerate),
						calcVirtualMagSize(stat.overheat[4], stat.firerate),
						{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
					renderFormatRow(
						intable,
						cfg.seconds.name,
						string.format(cfg.seconds.format, stat.overheat[1]),
						string.format(cfg.seconds.format, stat.overheat[2]),
						string.format(cfg.seconds.format, stat.overheat[3]),
						string.format(cfg.seconds.format, stat.overheat[4]),
						{ class = 'no-list-style text-secondary text-smaller', headerAlign = 'right', separator = '&thinsp;-&thinsp;', footer = cfg.seconds.unit })
					if isModdedLoaderAttachable then
						renderFormatRow(
							intable,
							iu.passive('modded_loader') .. '&nbsp;',
							calcVirtualMagSize(stat.overheat[1], stat.firerate, true),
							calcVirtualMagSize(stat.overheat[2], stat.firerate, true),
							calcVirtualMagSize(stat.overheat[3], stat.firerate, true),
							calcVirtualMagSize(stat.overheat[4], stat.firerate, true),
							{ separator = '&thinsp;-&thinsp;', footer = cfg.unit })
						renderFormatRow(
							intable,
							cfg.seconds.name,
							string.format(cfg.seconds.format, 1.15 * stat.overheat[1]),
							string.format(cfg.seconds.format, 1.15 * stat.overheat[2]),
							string.format(cfg.seconds.format, 1.15 * stat.overheat[3]),
							string.format(cfg.seconds.format, 1.15 * stat.overheat[4]),
							{ class = 'no-list-style text-secondary text-smaller', headerAlign = 'right', separator = '&thinsp;-&thinsp;', footer = cfg.seconds.unit })
					end
					return
				elseif aw.isNumberAndGreaterThanZero(stat.overheat) then
					text = string.format(
						'%s (<span class="text-type-number">%d</span>%s <span class="text-separator">/</span> %s <span class="text-type-number">%d</span>%s)',
						cfg.infinity,
						1 + math.floor(stat.overheat * stat.firerate),
						cfg.unit,
						iu.passive('modded_loader'),
						1 + math.floor(1.15 * stat.overheat * stat.firerate),
						cfg.unit)
				else
					text = cfg.infinity
				end
			else
				text = cfg.infinity
			end
			
		elseif aw.isNumberAndGreaterThanX(stat.ammo_per_shot, 1) then
			local times = magazine / stat.ammo_per_shot
			local timesText
			if type(cfg.times.format) == 'table' then
				if times > 2 then
					timesText = string.format(cfg.times.format[3], times)
				else
					timesText = cfg.times.format[times]
				end
			else
				timesText = string.format(cfg.times.format, times)
			end
			
			text = string.format(
				'<span class="text-type-number">%d</span>%s <span class="text-secondary"><small>(%s)</small></span>',
				magazine, cfg.unit, timesText)
			
		else
			text = string.format('<span class="text-type-number">%d</span>%s', magazine, cfg.unit)
		end
	end
	
	renderRow(tbl, cfg.name, text)
end

local function renderDuration(tbl, cfg, stat, lang)
	local node, isSimple = require('Module:WeaponInfobox/Duration').renderDuration(stat, lang)
	local cell = createCellInRow(tbl, cfg.name)
	if isSimple then
		cell:node(node)
	else
		tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
	end
end

local function renderSpread(tbl, cfg, stat, lang, frame)
	local Spread = require('Module:WeaponInfobox/Spread')
	local node = Spread.renderSpread(stat.spread, stat.attachments.laser_sight, stat.quickdraw_holster and stat.quickdraw_holster.spread, lang)
	local cell = createCellInRow(tbl, cfg.name)
	if node.tagName == 'span' then
		cell:node(node)
	elseif Hopup.anvil_receiver.enabled and stat.anvil_receiver and stat.anvil_receiver.spread then
		local node2 = Spread.renderSpread(stat.anvil_receiver.spread, stat.attachments.laser_sight, nil, lang)
		if frame then
			local tabContent = string.format(
				'{{#tab:%s|%s}}{{#tab:%s|%s}}',
				cfg.normal, tostring(node),
				cfg.anvil_receiver, tostring(node2))
			tbl:tag('tr')
				:tag('td')
					:attr('colspan', 2)
					:wikitext(frame:extensionTag { name = 'tabs', content = tabContent, args = { class = 'tabs-intable' }})
		else
			tbl:tag('tr')
				:tag('td')
					:attr('colspan', 2)
					:tag('b')
						:wikitext(cfg.normal)
						:done()
					:node(node)
					:tag('b')
						:wikitext(cfg.anvil_receiver)
						:done()
					:node(node2)
		end
	elseif stat.spread_charged then
		local node2 = Spread.renderSpread(stat.spread_charged , nil, lang)
		if frame then
			local tabContent = string.format(
				'{{#tab:%s|%s}}{{#tab:%s|%s}}',
				cfg.normal, tostring(node),
				cfg.full_charge, tostring(node2))
			tbl:tag('tr')
				:tag('td')
					:attr('colspan', 2)
					:wikitext(frame:extensionTag { name = 'tabs', content = tabContent, args = { class = 'tabs-intable' }})
		else
			tbl:tag('tr')
				:tag('td')
					:attr('colspan', 2)
					:tag('b')
						:wikitext(cfg.normal)
						:done()
					:node(node)
					:tag('b')
						:wikitext(cfg.full_charge)
						:done()
					:node(node2)
		end
	else
		tbl:tag('tr'):tag('td'):attr('colspan', 2):node(node)
	end
end

local function renderSpreadDecayRow(intbl, name, cfg, spread, opts)
	opts = opts or {}
	intbl:tag('tr')
		:addClassIf(type(opts.rarity) == 'string', 'row-rarity-one disp-rarity-' .. (opts.rarity or 'common'))
		:tag('th')
			:wikitext(name)
			:done()
		:tag('td')
			:addClass('cell-type-number')
			:attr('align', 'right')
			:wikitext(string.format(cfg.rate.format, spread.decay_rate))
			:done()
		:tag('td')
			:wikitext(cfg.rate.unit)
			:done()
		:tag('td')
			:addClass('text-smaller')
			:wikitext(cfg.delay.name)
			:done()
		:tag('td')
			:addClass('cell-type-number')
			:addClass('text-smaller')
			:attr('align', 'right')
			:wikitext(string.format(cfg.delay.format, spread.decay_delay))
			:done()
		:tag('td')
			:addClass('text-smaller')
			:wikitext(cfg.delay.unit)
end

local function renderSpreadDecay(tbl, cfg, stat)
	if not (aw.isNumberAndGreaterThanZero(stat.spread.decay_rate) and aw.isNumberAndGreaterThanZero(stat.spread.decay_delay)) then
		return
	end
	
	local cell = createCellInRow(tbl, cfg.name)
	
	-- [Hop-up] Anvil Receiver
	if stat.anvil_receiver and stat.anvil_receiver.spread and aw.isNumberAndGreaterThanZero(stat.anvil_receiver.spread.decay_rate) and aw.isNumberAndGreaterThanZero(stat.anvil_receiver.spread.decay_delay) then
		local intbl = cell:tag('table')
			:addClass('condensedtable')
			:addClass('raritytable')
		renderSpreadDecayRow(
			intbl,
			'',
			cfg,
			stat.spread)
		renderSpreadDecayRow(
			intbl,
			iu.hopup('anvil_receiver') .. '&nbsp;',
			cfg,
			stat.anvil_receiver.spread,
			{ rarity = 'legendary' })
	else
		local text = string.format(cfg.format, stat.spread.decay_rate, stat.spread.decay_delay)
		cell:wikitext(text)
	end
end

local function createTable(cfg, name, stat, lang, frame)
	local isSpecial = aw.stringstarts(stat.ammo, "special_")
	local isModdedLoaderAttachable = stat.category == 'light_machine_gun' or stat.ammo == 'minigun'
	local tbl = mw.html.create('table')
	renderReleaseDate(tbl, cfg.release, stat.release)
	renderCategory(tbl, cfg.category, stat.category, lang)
	renderAmmo(tbl, cfg.ammo, stat.ammo, lang)
	renderCost(tbl, cfg.cost, stat.cost, stat.ammo)
	renderMode(tbl, cfg.mode, stat, isSpecial)
	renderDamage(tbl, cfg.damage, stat, isSpecial)
	if stat.firerate then
		renderFirerate(tbl, cfg.firerate, stat, lang)
	end
	renderProjectileSpeed(tbl, cfg.projectilespeed, stat.projectile_speed, stat.projectile_speed_charged)
	renderMoveSpeed(tbl, cfg.movespeed, stat, stat)
	renderMagazine(tbl, cfg.magazine, stat, isSpecial, isModdedLoaderAttachable)
	if stat.firerate and name ~= 'ボセックコンパウンドボウ' then
		renderDPS(tbl, cfg.dps, stat, lang)
	end
	if stat.time then
		renderDuration(tbl, cfg.duration, stat, lang)
	end
	if stat.spread then
		renderSpread(tbl, cfg.spread, stat, lang, frame)
		renderSpreadDecay(tbl, cfg.spreaddecay, stat)
	end
	return tbl
end

local function renderInfobox(args, frame)
	local lang = args and args.lang or 'ja'
	local cfglang = cfg[lang]
	local stat = mw.loadData('Module:Stat/Weapon')[args.name]
	local div = mw.html.create('div')
		:addClass('tpl-infobox-right')
		:addClass('tpl-weapon')
	if aw.stringstarts(stat.ammo, "special_") then
		div:addClass('tpl-weapon-special')
	else
		div:addClass('tpl-weapon-' .. stat.ammo)
	end
	
	div:tag('div')
		:addClass('tpl-weapon-header')
		:wikitext(args.name .. iu.ammo(stat.ammo, { size = 40 }))
	div:node(createTable(cfglang, args.name, stat, lang, frame))
	return div
end

function p._main(args, frame)
	formatter = require('Module:Utility/Formatter').new(frame)
	return tostring(renderInfobox(args, frame))
end

function p.main(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	args = getArgs(frame)
	return p._main(args, frame)
end

return p