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

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

提供:Apex Data
ナビゲーションに移動 検索に移動
(スカルピアサーライフリングへの対応)
(ダメージ表記の書式を改善)
2行目: 2行目:


local stat = require('Module:Stat/Weapon')
local stat = require('Module:Stat/Weapon')
local formatter -- lazily initialized
local getArgs -- lazily initialized
local getArgs -- lazily initialized


115行目: 116行目:
end
end


local function renderDamage(table, name, stat, ammo, pellet, frame)
local function renderDamage(table, name, stat, ammo, pellet)
local base = stat.base
local base = stat.base
local item
if pellet ~= nil then
if pellet ~= nil then
item = tostring(base) .. ' × ' .. tostring(pellet) .. '片'
local item = tostring(base) .. ' × ' .. tostring(pellet) .. '片'
renderRow(table, name, item)
else
else
item = tostring(base)
renderRow(table, name, tostring(base))
end
end
128行目: 129行目:
local hlm2 = convertDecimalToFractional(0.4 + 0.6 * stat.headshot)
local hlm2 = convertDecimalToFractional(0.4 + 0.6 * stat.headshot)
local hlm3 = convertDecimalToFractional(0.5 + 0.5 * stat.headshot)
local hlm3 = convertDecimalToFractional(0.5 + 0.5 * stat.headshot)
local leg = convertDecimalToFractional(stat.legshot)
local sprm = stat.skullpiercer_rifling or 1
local sprm = stat.skullpiercer_rifling or 1
local headText
if frame ~= nil then
local ul = mw.html.create('ul')
headText = '頭 '
if sprm > 1 then
.. head .. ' '
local spr0 = convertDecimalToFractional(sprm)
.. frame:expandTemplate { title = 'Common', args = { hlm1 }} .. ' → '
local spr1 = convertDecimalToFractional(0.2 + 0.8 * sprm)
.. frame:expandTemplate { title = 'Rare', args = { hlm2 }} .. ' → '
local spr2 = convertDecimalToFractional(0.4 + 0.6 * sprm)
.. frame:expandTemplate { title = 'Epic', args = { hlm3 }} .. '倍'
local spr3 = convertDecimalToFractional(0.5 + 0.5 * sprm)
if sprm > 1 then
local spr0 = convertDecimalToFractional(sprm)
local intable = mw.html.create('table'):addClass('condensedtable')
local spr1 = convertDecimalToFractional(0.2 + 0.8 * sprm)
local row1 = intable:tag('tr')
local spr2 = convertDecimalToFractional(0.4 + 0.6 * sprm)
row1:tag('td'):wikitext('頭')
local spr3 = convertDecimalToFractional(0.5 + 0.5 * sprm)
row1:tag('td'):wikitext(head)
headText = headText
row1:tag('td'):wikitext('→')
.. '<br>'
row1:tag('td'):wikitext(formatter:common(hlm1))
.. frame:expandTemplate { title = 'Hopup', args = { "スカルピアサーライフリング", size = 16 }}
row1:tag('td'):wikitext('→')
.. ' '
row1:tag('td'):wikitext(formatter:rare(hlm2))
.. spr0 .. ' → '
row1:tag('td'):wikitext('→')
.. frame:expandTemplate { title = 'Common', args = { spr1 }} .. ' → '
row1:tag('td'):wikitext(formatter:epic(hlm3))
.. frame:expandTemplate { title = 'Rare', args = { spr2 }} .. ' → '
row1:tag('td'):wikitext('倍')
.. frame:expandTemplate { title = 'Epic', args = { spr3 }} .. '倍'
end
local row2 = intable:tag('tr')
row2:tag('td'):wikitext(formatter:hopup('スカルピアサーライフリング'))
row2:tag('td'):wikitext(spr0)
row2:tag('td'):wikitext('→')
row2:tag('td'):wikitext(formatter:common(spr1))
row2:tag('td'):wikitext('→')
row2:tag('td'):wikitext(formatter:rare(spr2))
row2:tag('td'):wikitext('→')
row2:tag('td'):wikitext(formatter:epic(spr3))
row2:tag('td'):wikitext('倍')
ul:tag('li'):node(intable)
else
else
headText = '頭 '
local headText = '頭 '
.. head .. ' → '
.. head .. ' → '
.. hlm1 .. ' → '
.. formatter:common(hlm1) .. ' → '
.. hlm2 .. ' → '
.. formatter:rare(hlm2) .. ' → '
.. hlm3 .. '倍'
.. formatter:epic(hlm3) .. '倍'
if sprm > 1 then
ul:tag('li'):wikitext(headText)
local spr0 = convertDecimalToFractional(sprm)
local spr1 = convertDecimalToFractional(0.2 + 0.8 * sprm)
local spr2 = convertDecimalToFractional(0.4 + 0.6 * sprm)
local spr3 = convertDecimalToFractional(0.5 + 0.5 * sprm)
headText = headText
.. '<br>スカピ '
.. spr0 .. ' → '
.. spr1 .. ' → '
.. spr2 .. ' → '
.. spr3 .. '倍'
end
end
end
local leg = convertDecimalToFractional(stat.legshot)
ul:tag('li'):wikitext('脚 ' .. leg .. '倍')
local legText = '脚 ' .. leg .. '倍'
table:tag('tr')
:tag('td')
local ul = mw.html.create('ul')
:attr('colspan', 2)
ul:tag('li'):wikitext(headText)
:node(ul)
ul:tag('li'):wikitext(legText)
renderRow(table, name, item .. tostring(ul))
end
end


211行目: 211行目:
renderAmmo(table, '弾薬', weaponStat.ammo, frame)
renderAmmo(table, '弾薬', weaponStat.ammo, frame)
renderMode(table, '射撃モード', weaponStat.mode)
renderMode(table, '射撃モード', weaponStat.mode)
renderDamage(table, 'ダメージ', weaponStat.damage, weaponStat.ammo, weaponStat.pellet, frame)
renderDamage(table, 'ダメージ', weaponStat.damage, weaponStat.ammo, weaponStat.pellet)
renderMagazine(table, '装填数', weaponStat.magazine, frame)
renderMagazine(table, '装填数', weaponStat.magazine, frame)
return table
return table
217行目: 217行目:


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

2021年1月29日 (金) 11:07時点における版

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

local p = {}

local stat = require('Module:Stat/Weapon')
local formatter -- lazily initialized
local getArgs -- lazily initialized

local function renderRow(table, name, item)
	local row = table:tag('tr')
	row:tag('th'):wikitext(name)
	row:tag('td'):wikitext(item)
end

local CategoryDict = {
	assault_rifle = "アサルトライフル",
	sub_machine_gun = "サブマシンガン",
	light_machine_gun = "ライトマシンガン",
	sniper = "スナイパーライフル",
	shotgun = "ショットガン",
	pistol = "ピストル",
}
local function renderCategory(table, name, stat)
	local category = CategoryDict[stat]
	renderRow(table, name, category)
end

local AmmoDict = {
	light = "ライト",
	heavy = "ヘビー",
	energy = "エネルギー",
	sniper = "スナイパー",
	shotgun = "ショットガン",
	special_light = "専用ライト",
	special_heavy = "専用ヘビー",
	special_energy = "専用エネルギー",
	special_sniper = "専用スナイパー",
	special_shotgun = "専用ショットガン",
}
local function renderAmmo(table, name, stat, frame)
	local ammo = AmmoDict[stat]
	if frame ~= nil then
		renderRow(
			table,
			'弾薬',
			frame:expandTemplate { title = 'Ammo', args = { ammo, size = 28 }} .. ' ' .. ammo .. 'アモ')
	else
		renderRow(table, name, ammo .. 'アモ')
	end
end

local function convertDecimalToFractional(num)
	local integer = math.floor(num)
	local decimal = tonumber(string.format("%.3f", num - integer))
	local decimalText
	if decimal == 0.125 then
		decimalText = '⅛'
	elseif decimal == 0.2 then
		decimalText = '⅕'
	elseif decimal == 0.25 then
		decimalText = '¼'
	elseif decimal == 1/3 then
		decimalText = '⅓'
	elseif decimal == 0.375 then
		decimalText = '⅜'
	elseif decimal == 0.4 then
		decimalText = '⅖'
	elseif decimal == 0.5 then
		decimalText = '½'
	elseif decimal == 0.6 then
		decimalText = '⅗'
	elseif decimal == 0.625 then
		decimalText = '⅝'
	elseif decimal == 2/3 then
		decimalText = '⅔'
	elseif decimal == 0.75 then
		decimalText = '¾'
	elseif decimal == 0.8 then
		decimalText = '⅘'
	elseif decimal == 0.875 then
		decimalText = '⅞'
	else
		decimalText = ''
	end
	
	if decimalText == '' then
		return tostring(num)
	elseif integer == 0 then
		return decimalText
	else
		return tostring(integer) .. decimalText
	end
end

local function renderMode(table, name, stat)
	local mode = nil
	if stat.auto then
		mode = 'オート'
	end
	
	if stat.burst > 1 then
		if mode == nil then
			mode = stat.burst .. '点バースト'
		else
			mode = mode .. ',' .. stat.burst .. '点バースト'
		end
	end
	
	if stat.single then
		if mode == nil then
			mode = '単発'
		else
			mode = mode .. ',単発'
		end
	end
	
	renderRow(table, name, mode)
end

local function renderDamage(table, name, stat, ammo, pellet)
	local base = stat.base
	if pellet ~= nil then
		local item = tostring(base) .. ' × ' .. tostring(pellet) .. '片'
		renderRow(table, name, item)
	else
		renderRow(table, name, tostring(base))
	end
	
	local head = convertDecimalToFractional(stat.headshot)
	local hlm1 = convertDecimalToFractional(0.2 + 0.8 * stat.headshot)
	local hlm2 = convertDecimalToFractional(0.4 + 0.6 * stat.headshot)
	local hlm3 = convertDecimalToFractional(0.5 + 0.5 * stat.headshot)
	local leg = convertDecimalToFractional(stat.legshot)
	local sprm = stat.skullpiercer_rifling or 1
	
	local ul = mw.html.create('ul')
	if sprm > 1 then
		local spr0 = convertDecimalToFractional(sprm)
		local spr1 = convertDecimalToFractional(0.2 + 0.8 * sprm)
		local spr2 = convertDecimalToFractional(0.4 + 0.6 * sprm)
		local spr3 = convertDecimalToFractional(0.5 + 0.5 * sprm)
		
		local intable = mw.html.create('table'):addClass('condensedtable')
		local row1 = intable:tag('tr')
		row1:tag('td'):wikitext('頭')
		row1:tag('td'):wikitext(head)
		row1:tag('td'):wikitext('→')
		row1:tag('td'):wikitext(formatter:common(hlm1))
		row1:tag('td'):wikitext('→')
		row1:tag('td'):wikitext(formatter:rare(hlm2))
		row1:tag('td'):wikitext('→')
		row1:tag('td'):wikitext(formatter:epic(hlm3))
		row1:tag('td'):wikitext('倍')
		
		local row2 = intable:tag('tr')
		row2:tag('td'):wikitext(formatter:hopup('スカルピアサーライフリング'))
		row2:tag('td'):wikitext(spr0)
		row2:tag('td'):wikitext('→')
		row2:tag('td'):wikitext(formatter:common(spr1))
		row2:tag('td'):wikitext('→')
		row2:tag('td'):wikitext(formatter:rare(spr2))
		row2:tag('td'):wikitext('→')
		row2:tag('td'):wikitext(formatter:epic(spr3))
		row2:tag('td'):wikitext('倍')
		
		ul:tag('li'):node(intable)
	else
		local headText = '頭 '
			.. head .. ' → '
			.. formatter:common(hlm1) .. ' → '
			.. formatter:rare(hlm2) .. ' → '
			.. formatter:epic(hlm3) .. '倍'
		ul:tag('li'):wikitext(headText)
	end
	
	ul:tag('li'):wikitext('脚 ' .. leg .. '倍')
	table:tag('tr')
		:tag('td')
			:attr('colspan', 2)
			:node(ul)
end

local function renderMagazine(table, name, stat, frame)
	if type(stat) == 'table' then
		local text
		if frame ~= nil then
			text = stat[1] .. ' → '
				.. frame:expandTemplate { title = 'Common', args = { stat[2] }} .. ' → '
				.. frame:expandTemplate { title = 'Rare', args = { stat[3] }} .. ' → '
				.. frame:expandTemplate { title = 'Epic', args = { stat[4] }}
		else
			text = stat[1] .. ' → '
				.. stat[2] .. ' → '
				.. stat[3] .. ' → '
				.. stat[4]
		end
		renderRow(table, name, text)
	elseif type(stat) == 'number' then
		if stat == math.huge then
			renderRow(table, name, '∞')
		else
			renderRow(table, name, stat)
		end
	else
		renderRow(table, name, '???')
	end
end

local function renderTable(args, frame)
	local weaponStat = stat[args.name]
	local table = mw.html.create('table')
	renderCategory(table, '種類', weaponStat.category)
	renderAmmo(table, '弾薬', weaponStat.ammo, frame)
	renderMode(table, '射撃モード', weaponStat.mode)
	renderDamage(table, 'ダメージ', weaponStat.damage, weaponStat.ammo, weaponStat.pellet)
	renderMagazine(table, '装填数', weaponStat.magazine, frame)
	return table
end

function p._main(args, frame)
	formatter = require('Module:Utility/Formatter').new(frame)
	return tostring(renderTable(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