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

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

提供:Apex Data
ナビゲーションに移動 検索に移動
(フルチャージ時ヘッドショット倍率に対する参照変数が間違えていた問題の修正)
(ローカライズに対応)
4行目: 4行目:
local iu = require('Module:Utility/Image')
local iu = require('Module:Utility/Image')
local nu = require('Module:Utility/Name')
local nu = require('Module:Utility/Name')
local formatter -- lazily initialized
local getArgs -- lazily initialized


local function createRow(tbl, text)
local function createRow(tbl, text)
16行目: 16行目:
end
end


local function createRowForType(tbl, name)
local function createRowForType(lang)
local type = nu.type(name)
return function(tbl, name)
return createRow(tbl, type)
local type = nu.type(name, lang)
return createRow(tbl, type)
end
end
end


local function createRowForAmmo(tbl, name)
local function createRowForAmmo(lang)
local item
return function(tbl, name)
local opts = { size = 20 }
local item
if name == 'special' then
local opts = { size = 20 }
item = iu.ammo('special_sniper', opts) .. ' <span class="text-ammo-special">物資投下</span>'
if name == 'special' then
else
item = iu.ammo('special_sniper', opts) .. ' <span class="text-ammo-special">物資投下</span>'
item = string.format('%s <span class="text-ammo-%s">%s</span>', iu.ammo(name, opts), name, nu.ammo(name))
else
item = string.format('%s <span class="text-ammo-%s">%s</span>', iu.ammo(name, opts), name, nu.ammo(name, lang))
end
return createRow(tbl, item)
end
end
return createRow(tbl, item)
end
end


56行目: 60行目:
end
end


local function renderNavboxByType()
local function renderNavboxByType(args)
local stat = mw.loadData('Module:Stat/Weapon')
local stat = mw.loadData('Module:Stat/Weapon')
68行目: 72行目:
return renderNavbox(
return renderNavbox(
{ 'assault_rifle', 'sub_machine_gun', 'light_machine_gun', 'marksman_weapons', 'sniper', 'shotgun', 'pistol' },
{ 'assault_rifle', 'sub_machine_gun', 'light_machine_gun', 'marksman_weapons', 'sniper', 'shotgun', 'pistol' },
weaponsByTypes, createRowForType)
weaponsByTypes, createRowForType(args.lang))
end
end


local function renderNavboxByAmmo()
local function renderNavboxByAmmo(args)
local stat = mw.loadData('Module:Stat/Weapon')
local stat = mw.loadData('Module:Stat/Weapon')
92行目: 96行目:
return renderNavbox(
return renderNavbox(
{ 'light', 'heavy', 'energy', 'sniper', 'shotgun', 'arrows', 'special' },
{ 'light', 'heavy', 'energy', 'sniper', 'shotgun', 'arrows', 'special' },
weaponsByAmmos, createRowForAmmo)
weaponsByAmmos, createRowForAmmo(args.lang))
end
end


local function renderNavboxByHSMultiplier()
local function renderNavboxByHSMultiplier(args)
local stat = mw.loadData('Module:Stat/Weapon')
local stat = mw.loadData('Module:Stat/Weapon')
112行目: 116行目:
keys,
keys,
weaponsByHSMultipliers, createRowForHSMultiplier)
weaponsByHSMultipliers, createRowForHSMultiplier)
end
local function preload(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame)
args.lang = args.lang or 'ja'
return args
end
end


function p.bytype(frame)
function p.bytype(frame)
formatter = require('Module:Utility/Formatter').new(frame)
local args = preload(frame)
return tostring(renderNavboxByType(args))
return tostring(renderNavboxByType(args))
end
end


function p.byammo(frame)
function p.byammo(frame)
formatter = require('Module:Utility/Formatter').new(frame)
local args = preload(frame)
return tostring(renderNavboxByAmmo(args))
return tostring(renderNavboxByAmmo(args))
end
end


function p.byhsmul(frame)
function p.byhsmul(frame)
formatter = require('Module:Utility/Formatter').new(frame)
local args = preload(frame)
return tostring(renderNavboxByHSMultiplier(args))
return tostring(renderNavboxByHSMultiplier(args))
end
end


return p
return p

2021年5月14日 (金) 15:18時点における版

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

local p = {}

local aw = require('Module:Utility/Library')
local iu = require('Module:Utility/Image')
local nu = require('Module:Utility/Name')
local getArgs -- lazily initialized

local function createRow(tbl, text)
	return tbl:tag('tr')
		:tag('th')
			:wikitext(text)
			:done()
		:tag('td')
			:tag('ul')
				:addClass('tpl-navbox-list')
end

local function createRowForType(lang)
	return function(tbl, name)
		local type = nu.type(name, lang)
		return createRow(tbl, type)
	end
end

local function createRowForAmmo(lang)
	return function(tbl, name)
		local item
		local opts = { size = 20 }
		if name == 'special' then
			item = iu.ammo('special_sniper', opts) .. ' <span class="text-ammo-special">物資投下</span>'
		else
			item = string.format('%s <span class="text-ammo-%s">%s</span>', iu.ammo(name, opts), name, nu.ammo(name, lang))
		end
		
		return createRow(tbl, item)
	end
end

local function createRowForHSMultiplier(tbl, hsmul)
	return createRow(tbl, string.format('%s倍', hsmul))
end

local function renderNavbox(keys, names, fn)
	local tbl = mw.html.create('table')
			:addClass('tpl-navbox-table')
			:addClass('tpl-navbox-table-containstitle')
	tbl:tag('tr')
		:tag('th')
			:attr('colspan', 2)
			:addClass('tpl-navbox-table-title')
			:wikitext('武器')
	for _, name in ipairs(keys) do
		local list = fn(tbl, name)
		for _, value in ipairs(names[name]) do
			list:tag('li')
				:wikitext(string.format('[[%s]]', value))
		end
	end
	return tbl:done()
end

local function renderNavboxByType(args)
	local stat = mw.loadData('Module:Stat/Weapon')
	
	local weaponsByTypes = {}
	for key, value in pairs(stat) do
		if weaponsByTypes[value.category] == nil then
			weaponsByTypes[value.category] = {}
		end
		table.insert(weaponsByTypes[value.category], key)
	end
	return renderNavbox(
		{ 'assault_rifle', 'sub_machine_gun', 'light_machine_gun', 'marksman_weapons', 'sniper', 'shotgun', 'pistol' },
		weaponsByTypes, createRowForType(args.lang))
end

local function renderNavboxByAmmo(args)
	local stat = mw.loadData('Module:Stat/Weapon')
	
	local weaponsByAmmos = {}
	for key, value in pairs(stat) do
		local target
		if aw.stringstarts(value.ammo, "special_") then
			if weaponsByAmmos.special == nil then
				weaponsByAmmos.special = {}
			end
			target = weaponsByAmmos.special
		else
			if weaponsByAmmos[value.ammo] == nil then
				weaponsByAmmos[value.ammo] = {}
			end
			target = weaponsByAmmos[value.ammo]
		end
		table.insert(target, key)
	end
	return renderNavbox(
		{ 'light', 'heavy', 'energy', 'sniper', 'shotgun', 'arrows', 'special' },
		weaponsByAmmos, createRowForAmmo(args.lang))
end

local function renderNavboxByHSMultiplier(args)
	local stat = mw.loadData('Module:Stat/Weapon')
	
	local weaponsByHSMultipliers = {}
	for key, value in pairs(stat) do
		local headshot = value.damage.headshot_charged or value.damage.headshot or 2
		if weaponsByHSMultipliers[headshot] == nil then
			weaponsByHSMultipliers[headshot] = {}
		end
		table.insert(weaponsByHSMultipliers[headshot], key)
	end
	
	local keys = aw.getTableKeys(weaponsByHSMultipliers)
	table.sort(keys)
	return renderNavbox(
		keys,
		weaponsByHSMultipliers, createRowForHSMultiplier)
end

local function preload(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	
	local args = getArgs(frame)
	args.lang = args.lang or 'ja'
	return args
end

function p.bytype(frame)
	local args = preload(frame)
	return tostring(renderNavboxByType(args))
end

function p.byammo(frame)
	local args = preload(frame)
	return tostring(renderNavboxByAmmo(args))
end

function p.byhsmul(frame)
	local args = preload(frame)
	return tostring(renderNavboxByHSMultiplier(args))
end

return p