| 🌟 | 現在、 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:Utility/ImageWithName」の版間の差分
ナビゲーションに移動
検索に移動
(言語設定が正しく渡されていない不具合の修正) |
(ホップアップへの対応) |
||
| 1行目: | 1行目: | ||
local p = {} | local p = {} | ||
local cfg = mw.loadData('Module:Utility/ImageWithName/configuration') | local cfg = mw.loadData('Module:Utility/ImageWithName/configuration') | ||
local function buildClasses(opts) | local function buildClasses(opts) | ||
| 23行目: | 23行目: | ||
local nu = require('Module:Utility/Name') | local nu = require('Module:Utility/Name') | ||
local function getSimpleResource(key, id, opts, imagefunc, namefunc) | local function getSimpleResource(key, id, opts, imagefunc, namefunc, rarityfunc) | ||
opts = opts or { lang = 'ja' } | opts = opts or { lang = 'ja' } | ||
opts.lang = opts.lang or 'ja' | opts.lang = opts.lang or 'ja' | ||
| 37行目: | 37行目: | ||
if cfg2.hasLink then | if cfg2.hasLink then | ||
table.insert(params, name) | table.insert(params, name) | ||
end | |||
-- レアリティー | |||
if cfg2.hasRarity then | |||
table.insert(params, opts.rarity or rarityfunc(id)) | |||
end | end | ||
| 55行目: | 60行目: | ||
function p.ammo(id, opts) | function p.ammo(id, opts) | ||
return getSimpleResource('ammo', id, opts, iu.ammo, nu.ammo) | return getSimpleResource('ammo', id, opts, iu.ammo, nu.ammo) | ||
end | |||
function p.hopup(id, opts) | |||
local rarityFunction = function(id) | |||
return mw.loadData('Module:Stat/Hopup')[id].rarity | |||
end | |||
return getSimpleResource('hopup', id, opts, iu.hopup, nu.hopup, rarityFunction) | |||
end | end | ||
2021年8月17日 (火) 05:31時点における版
このモジュールについての説明文ページを モジュール:Utility/ImageWithName/doc に作成できます
local p = {}
local cfg = mw.loadData('Module:Utility/ImageWithName/configuration')
local function buildClasses(opts)
local classes
if type(opts.classes) == 'string' then
if opts.desktopOnly then
classes = ' ' .. opts.classes .. ' text-desktoponly'
else
classes = ' ' .. opts.classes
end
else
if opts.desktopOnly then
classes = ' text-desktoponly'
else
classes = ''
end
end
return classes
end
local iu = require('Module:Utility/Image')
local nu = require('Module:Utility/Name')
local function getSimpleResource(key, id, opts, imagefunc, namefunc, rarityfunc)
opts = opts or { lang = 'ja' }
opts.lang = opts.lang or 'ja'
local classes = buildClasses(opts)
local name = namefunc(id, opts.lang)
local cfg2 = cfg[opts.lang][key]
local params = {
imagefunc(id) -- 画像
}
-- リンク
if cfg2.hasLink then
table.insert(params, name)
end
-- レアリティー
if cfg2.hasRarity then
table.insert(params, opts.rarity or rarityfunc(id))
end
-- クラス用ID
if cfg2.hasId then
table.insert(params, id)
end
-- 追加クラス
table.insert(params, classes)
-- 表示名
table.insert(params, name)
return string.format(cfg2.format, unpack(params))
end
function p.ammo(id, opts)
return getSimpleResource('ammo', id, opts, iu.ammo, nu.ammo)
end
function p.hopup(id, opts)
local rarityFunction = function(id)
return mw.loadData('Module:Stat/Hopup')[id].rarity
end
return getSimpleResource('hopup', id, opts, iu.hopup, nu.hopup, rarityFunction)
end
function p.tactical(id, opts)
return getSimpleResource('tactical', id, opts, iu.tactical, nu.tactical)
end
local function getLevelResource(level, opts, namefunc)
level = level or 0
opts = opts or { lang = 'ja' }
opts.lang = opts.lang or 'ja'
if level == 0 and opts.useShortLabel then
return cfg[lang].level.none
end
if level > 5 then
level = 5
end
local classes = buildClasses(opts)
if level == 0 and classes == '' then
return string.format(
cfg[opts.lang].level.none_format,
iu.attachment(namefunc('ja'), level),
namefunc(opts.lang))
end
return string.format(
cfg[opts.lang].level.format[1 + level],
iu.attachment(namefunc('ja'), level),
classes,
namefunc(opts.lang))
end
function p.extmag(id, level, opts)
return getLevelResource(level, opts, function(lang)
return nu.extmag(id, lang)
end)
end
function p.bolt(level, opts)
return getLevelResource(level, opts, function(lang)
return nu.bolt(lang)
end)
end
return p