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

「モジュール:Utility/Image」の版間の差分

提供:Apex Data
ナビゲーションに移動 検索に移動
(弾薬のデフォルトリンク設定が反映されていない不具合の修正)
(物資投下武器時の連射速度上昇の画像読み込みに対応)
 
(同じ利用者による、間の18版が非表示)
20行目: 20行目:
end
end


local function imagecore(cfg2, name, opts)
local function imagecore(cfg2, name, opts, altname)
if opts.link and opts.link ~= '' then
if opts.link and opts.link ~= '' then
opts.link = string.format(opts.link, name)
opts.link = string.format(opts.link, name)
end
end
local filename  = string.format(cfg2.filename, name)
local filename  = opts.filename or string.format(cfg2.filename, name)
local classtext = buildClasses(cfg.classes, opts)
local classtext = buildClasses(cfg2.classes or cfg.classes, opts)
return string.format(
return string.format(
'[[File:%s|%dpx|link=%s|alt=%s|class=%s]]',
'[[File:%s|%dpx|link=%s|alt=%s|class=%s]]',
filename, opts.size, opts.link, name, classtext)
filename, opts.size, opts.link, altname or name, classtext)
end
end


35行目: 35行目:
local newopts = opts and aw.shallowCopy(opts) or {}
local newopts = opts and aw.shallowCopy(opts) or {}
newopts.link  = newopts.link  or cfg.attachment.default_link or cfg.default_link
newopts.link  = newopts.link  or cfg.attachment.default_link or cfg.default_link
newopts.rarity = newopts.rarity or cfg.attachment.levels[math.min(5, 1 + level)]
newopts.rarity = newopts.rarity or cfg.levels[math.min(5, 1 + level)]
newopts.size  = newopts.size  or cfg.attachment.default_size or cfg.default_size
newopts.size  = newopts.size  or cfg.attachment.default_size or cfg.default_size
return imagecore(cfg.attachment, name, newopts)
return imagecore(cfg.attachment, name, newopts)
end
function p.gear(id, level, opts)
local newopts = opts and aw.shallowCopy(opts) or {}
newopts.link  = newopts.link  or cfg.gear.default_link or cfg.default_link
newopts.rarity = newopts.rarity or cfg.levels[math.min(6, 1 + level)]
newopts.size  = newopts.size  or cfg.gear.default_size or cfg.default_size
local lang    = newopts.lang or 'ja'
local name    = nu.gear(id, 'ja')
local altname = nu.gear(id, lang)
if id == 'backpack' then
newopts.filename = string.format(cfg.gear.filename_backpack, math.max(1, math.min(level, 3)))
end
return imagecore(cfg.gear, name, newopts, altname)
end
end


function p.ammo(id, opts)
function p.ammo(id, opts)
local name = nu.ammo(id)
opts      = opts      or { lang = 'ja' }
opts.lang = opts.lang or 'ja'
local linkname, name, altname
if aw.stringends(id, '_revved_up') then
local baseid
if aw.stringstarts(id, 'special_') then
baseid = string.sub(id, 9, string.len(id) - 10)
else
baseid = string.sub(id, 1, string.len(id) - 10)
end
linkname = nu.ammo(baseid)
name    = '連射速度上昇時' .. linkname
altname  = '連射速度上昇時' .. nu.ammo(baseid, opts.lang)
elseif aw.stringends(id, '_amped') then
local baseid = string.sub(id, 1, string.len(id) - 6)
linkname = nu.ammo(baseid)
name     = '増幅時' .. linkname
altname  = '増幅時' .. nu.ammo(baseid, opts.lang)
else
linkname = nu.ammo(id)
name    = linkname
altname  = nu.ammo(id, opts.lang)
end
local newopts = opts and aw.shallowCopy(opts) or {}
local newopts = opts and aw.shallowCopy(opts) or {}
newopts.link = newopts.link or cfg.ammo.default_link or cfg.default_link
newopts.link = newopts.link or cfg.ammo.default_link or cfg.default_link
47行目: 85行目:
if newopts.link and newopts.link ~= '' then
if newopts.link and newopts.link ~= '' then
newopts.link = string.format(newopts.link, name)
newopts.link = string.format(newopts.link, linkname)
end
end
local filename  = string.format(cfg.ammo.filename, name)
local filename  = string.format(cfg.ammo.filename, name)
return string.format(
return string.format(
'[[File:%s|%dpx|link=%s|alt=%s|class=image-ammo]]',
'[[File:%s|x%dpx|link=%s|alt=%s]]',
filename, newopts.size, newopts.link, name)
filename, newopts.size, newopts.link, altname)
end
end


local function image(cfg2, name, opts)
local function image(cfg2, name, opts, altname, rarity)
opts = opts and aw.shallowCopy(opts) or {}
opts = opts and aw.shallowCopy(opts) or {}
opts.link  = opts.link  or cfg2.items[name].default_link  or cfg2.default_link  or cfg.default_link
opts.link  = opts.link  or cfg2.items and cfg2.items[name].default_link  or cfg2.default_link  or cfg.default_link
opts.rarity = opts.rarity or cfg2.items[name].default_rarity or cfg2.default_rarity or cfg.default_rarity
opts.rarity = opts.rarity or cfg2.items and cfg2.items[name].default_rarity or cfg2.default_rarity or cfg.default_rarity
opts.size  = opts.size  or cfg2.items[name].default_size  or cfg2.default_size  or cfg.default_size
opts.size  = opts.size  or cfg2.items and cfg2.items[name].default_size  or cfg2.default_size  or cfg.default_size
return imagecore(cfg2, name, opts)
return imagecore(cfg2, name, opts, altname)
end
end


function p.hopup(name, opts)
function p.grenade(name, opts)
return image(cfg.hopup, name, opts)
return image(cfg.grenade, name, opts)
end
 
function p.hopup(id, opts)
opts = opts or {}
local name   = nu.hopup(id, 'ja')
local altname = nu.hopup(id, opts and opts.lang)
if not opts.rarity then
opts.rarity = mw.loadData('Module:Stat/Hopup')[id].rarity
end
return image(cfg.hopup, name, opts, altname, rarity)
end
end


74行目: 123行目:
function p.scope(name, opts)
function p.scope(name, opts)
return image(cfg.scope, name, opts)
return image(cfg.scope, name, opts)
end
function p.passive(id, opts)
local name = nu.passive(id, 'ja')
local altname = nu.passive(id, opts and opts.lang)
return image(cfg.passive, name, opts, altname)
end
function p.tactical(id, opts)
local name = nu.tactical(id, 'ja')
local altname = nu.tactical(id, opts and opts.lang)
return image(cfg.tactical, name, opts, altname)
end
end


return p
return p

2022年8月10日 (水) 14:01時点における最新版

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

local p = {}
local cfg = mw.loadData('Module:Utility/Image/configuration')

local aw = require('Module:Utility/Library')
local nu = require('Module:Utility/Name')

local function buildClasses(base, params)
	local classes = {}
	for _, value in ipairs({ 'body', 'rarity', 'size' }) do
		local baseClassName = base[value]
		local param = params[value]
		if param ~= nil then
			local classname = string.format(baseClassName, param)
			table.insert(classes, classname)
		else
			table.insert(classes, baseClassName)
		end
	end
	return table.concat(classes, ' ')
end

local function imagecore(cfg2, name, opts, altname)
	if opts.link and opts.link ~= '' then
		opts.link = string.format(opts.link, name)
	end
	
	local filename  = opts.filename or string.format(cfg2.filename, name)
	local classtext = buildClasses(cfg2.classes or cfg.classes, opts)
	return string.format(
		'[[File:%s|%dpx|link=%s|alt=%s|class=%s]]',
		filename, opts.size, opts.link, altname or name, classtext)
end

function p.attachment(name, level, opts)
	local newopts = opts and aw.shallowCopy(opts) or {}
	newopts.link   = newopts.link   or cfg.attachment.default_link or cfg.default_link
	newopts.rarity = newopts.rarity or cfg.levels[math.min(5, 1 + level)]
	newopts.size   = newopts.size   or cfg.attachment.default_size or cfg.default_size
	return imagecore(cfg.attachment, name, newopts)
end

function p.gear(id, level, opts)
	local newopts = opts and aw.shallowCopy(opts) or {}
	newopts.link   = newopts.link   or cfg.gear.default_link or cfg.default_link
	newopts.rarity = newopts.rarity or cfg.levels[math.min(6, 1 + level)]
	newopts.size   = newopts.size   or cfg.gear.default_size or cfg.default_size
	
	local lang    = newopts.lang or 'ja'
	local name    = nu.gear(id, 'ja')
	local altname = nu.gear(id, lang)
	if id == 'backpack' then
		newopts.filename = string.format(cfg.gear.filename_backpack, math.max(1, math.min(level, 3)))
	end
	return imagecore(cfg.gear, name, newopts, altname)
end

function p.ammo(id, opts)
	opts      = opts      or { lang = 'ja' }
	opts.lang = opts.lang or 'ja'
	
	local linkname, name, altname
	if aw.stringends(id, '_revved_up') then
		local baseid
		if aw.stringstarts(id, 'special_') then
			baseid = string.sub(id, 9, string.len(id) - 10)
		else
			baseid = string.sub(id, 1, string.len(id) - 10)
		end
		linkname = nu.ammo(baseid)
		name     = '連射速度上昇時' .. linkname
		altname  = '連射速度上昇時' .. nu.ammo(baseid, opts.lang)
	elseif aw.stringends(id, '_amped') then
		local baseid = string.sub(id, 1, string.len(id) - 6)
		linkname = nu.ammo(baseid)
		name     = '増幅時' .. linkname
		altname  = '増幅時' .. nu.ammo(baseid, opts.lang)
	else
		linkname = nu.ammo(id)
		name     = linkname
		altname  = nu.ammo(id, opts.lang)
	end
	local newopts = opts and aw.shallowCopy(opts) or {}
	newopts.link = newopts.link or cfg.ammo.default_link or cfg.default_link
	newopts.size = newopts.size or cfg.ammo.default_size or cfg.default_size
	
	if newopts.link and newopts.link ~= '' then
		newopts.link = string.format(newopts.link, linkname)
	end
	
	local filename  = string.format(cfg.ammo.filename, name)
	return string.format(
		'[[File:%s|x%dpx|link=%s|alt=%s]]',
		filename, newopts.size, newopts.link, altname)
end

local function image(cfg2, name, opts, altname, rarity)
	opts = opts and aw.shallowCopy(opts) or {}
	opts.link   = opts.link   or cfg2.items and cfg2.items[name].default_link   or cfg2.default_link   or cfg.default_link
	opts.rarity = opts.rarity or cfg2.items and cfg2.items[name].default_rarity or cfg2.default_rarity or cfg.default_rarity
	opts.size   = opts.size   or cfg2.items and cfg2.items[name].default_size   or cfg2.default_size   or cfg.default_size
	return imagecore(cfg2, name, opts, altname)
end

function p.grenade(name, opts)
	return image(cfg.grenade, name, opts)
end

function p.hopup(id, opts)
	opts = opts or {}
	
	local name    = nu.hopup(id, 'ja')
	local altname = nu.hopup(id, opts and opts.lang)
	if not opts.rarity then
		opts.rarity = mw.loadData('Module:Stat/Hopup')[id].rarity
	end
	return image(cfg.hopup, name, opts, altname, rarity)
end

function p.item(name, opts)
	return image(cfg.item, name, opts)
end

function p.scope(name, opts)
	return image(cfg.scope, name, opts)
end

function p.passive(id, opts)
	local name = nu.passive(id, 'ja')
	local altname = nu.passive(id, opts and opts.lang)
	return image(cfg.passive, name, opts, altname)
end

function p.tactical(id, opts)
	local name = nu.tactical(id, 'ja')
	local altname = nu.tactical(id, opts and opts.lang)
	return image(cfg.tactical, name, opts, altname)
end

return p