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

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

提供:Apex Data
ナビゲーションに移動 検索に移動
(ヘッドショット倍率による武器一覧の生成ロジックを追加)
(弾薬や種類のUI生成をLuaライブラリーの使用に切り替え)
2行目: 2行目:


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


18行目: 20行目:
end
end


local TypeDict = {
assault_rifle = "アサルトライフル",
sub_machine_gun = "サブマシンガン",
light_machine_gun = "ライトマシンガン",
sniper = "スナイパーライフル",
shotgun = "ショットガン",
pistol = "ピストル",
}
local function createRowForType(tbl, name)
local function createRowForType(tbl, name)
local type = TypeDict[name]
local type = nu.type(name)
return createRow(tbl, type)
return createRow(tbl, type)
end
end


local AmmoDict = {
light = "ライトアモ",
heavy = "ヘビーアモ",
energy = "エネルギーアモ",
sniper = "スナイパーアモ",
shotgun = "ショットガンアモ",
}
local function createRowForAmmo(tbl, name)
local function createRowForAmmo(tbl, name)
local item
local item
local opts = { size = 20 }
if name == 'special' then
if name == 'special' then
item = formatter:ammo('専用スナイパーアモ', 20) .. ' 物資投下'
item = iu.ammo('special_sniper', opts) .. ' 物資投下'
else
else
local ammo = AmmoDict[name]
item = string.format('%s %s', iu.ammo(name, opts), nu.ammo(name))
item = string.format('%s %s', formatter:ammo(ammo, 20), ammo)
end
end

2021年2月19日 (金) 20:50時点における版

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

local p = {}

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

local function stringStarts(str, start)
	return string.sub(str, 1, string.len(start)) == start
end

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(tbl, name)
	local type = nu.type(name)
	return createRow(tbl, type)
end

local function createRowForAmmo(tbl, name)
	local item
	local opts = { size = 20 }
	if name == 'special' then
		item = iu.ammo('special_sniper', opts) .. ' 物資投下'
	else
		item = string.format('%s %s', iu.ammo(name, opts), nu.ammo(name))
	end
	
	return createRow(tbl, item)
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()
	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', 'sniper', 'shotgun', 'pistol' },
		weaponsByTypes, createRowForType)
end

local function renderNavboxByAmmo()
	local stat = mw.loadData('Module:Stat/Weapon')
	
	local weaponsByAmmos = {}
	for key, value in pairs(stat) do
		local target
		if 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', 'special' },
		weaponsByAmmos, createRowForAmmo)
end

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

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

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

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

return p