🌟 | 現在、 鉄壁ヘッドショットには対応済みです。 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:WeaponNavbox」の版間の差分
ナビゲーションに移動
検索に移動
(アルティメットの出力に対応) |
(武器が存在しない場合にエラーが出る不具合の修正) |
||
(同じ利用者による、間の6版が非表示) | |||
1行目: | 1行目: | ||
local p = {} | local p = {} | ||
local table = require('Module:TableExtensions') | |||
local aw = require('Module:Utility/Library') | local aw = require('Module:Utility/Library') | ||
local iu = require('Module:Utility/Image') | local iu = require('Module:Utility/Image') | ||
12行目: | 13行目: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
:addClass('tpl-navbox-list') | |||
:tag('ul') | :tag('ul') | ||
end | end | ||
44行目: | 45行目: | ||
end | end | ||
local function | local function getCreateRowForNumbers(fmt) | ||
return function(tbl, num) | |||
return createRow(tbl, fmt(num)) | |||
end | |||
end | end | ||
local function renderNavbox(keys, names, fn) | local function renderNavbox(keys, names, fn, stat, fmt) | ||
fmt = fmt or function(value, name) | |||
return string.format('[[%s]]', value) | |||
end | |||
local tbl = mw.html.create('table') | local tbl = mw.html.create('table') | ||
:addClass('tpl-navbox-table') | :addClass('tpl-navbox-table') | ||
58行目: | 65行目: | ||
:wikitext('武器') | :wikitext('武器') | ||
for _, name in ipairs(keys) do | for _, name in ipairs(keys) do | ||
local list = fn(tbl, name, # | local target = names[name] | ||
if target then | |||
local list = fn(tbl, name, #target) | |||
for _, value in ipairs(target) do | |||
list:tag('li') | |||
:wikitext(fmt(value, stat)) | |||
end | |||
end | end | ||
end | end | ||
return tbl:done() | return tbl:done() | ||
end | |||
local function formatAmmoText(value, stat) | |||
local ammoraw = stat[value].ammo | |||
local ammo | |||
if aw.stringstarts(ammoraw, 'special_') then | |||
ammo = 'special' | |||
else | |||
ammo = ammoraw | |||
end | |||
return string.format('[[%s|<span class="text-ammo text-ammo-%s">%s</span>]]', value, ammo, value) | |||
end | end | ||
79行目: | 100行目: | ||
return renderNavbox( | return renderNavbox( | ||
{ 'assault_rifle', 'sub_machine_gun', 'light_machine_gun', 'marksman_weapon', 'sniper', 'shotgun', 'pistol', 'ultimate' }, | { 'assault_rifle', 'sub_machine_gun', 'light_machine_gun', 'marksman_weapon', 'sniper', 'shotgun', 'pistol', 'ultimate' }, | ||
weaponsByTypes, createRowForType(args.lang)) | weaponsByTypes, createRowForType(args.lang), stat, formatAmmoText) | ||
end | end | ||
106行目: | 127行目: | ||
end | end | ||
local function | local function renderNavboxByNumbers(args, selector, formatter) | ||
local stat = mw.loadData('Module:Stat/Weapon') | local stat = mw.loadData('Module:Stat/Weapon') | ||
local | local weaponsByNumbers = {} | ||
for key, value in pairs(stat) do | for key, value in pairs(stat) do | ||
local | local num = selector(value) | ||
if | if weaponsByNumbers[num] == nil then | ||
weaponsByNumbers[num] = {} | |||
end | end | ||
table.insert( | table.insert(weaponsByNumbers[num], key) | ||
end | end | ||
local keys = | local keys = table.keys(weaponsByNumbers) | ||
table.sort(keys) | table.sort(keys) | ||
return renderNavbox( | return renderNavbox( | ||
keys, | keys, | ||
weaponsByNumbers, getCreateRowForNumbers(formatter), stat, formatAmmoText) | |||
end | end | ||
143行目: | 164行目: | ||
local args = preload(frame) | local args = preload(frame) | ||
return tostring(renderNavboxByAmmo(args)) | return tostring(renderNavboxByAmmo(args)) | ||
end | |||
local function formatMultiplier(num) | |||
return string.format('%s倍', num) | |||
end | end | ||
function p.byhsmul(frame) | function p.byhsmul(frame) | ||
local args = preload(frame) | local args = preload(frame) | ||
return tostring( | local selector = function(stat) | ||
return stat.damage.headshot_charged or stat.damage_head_scale or 2 | |||
end | |||
return tostring(renderNavboxByNumbers(args, selector, formatMultiplier)) | |||
end | |||
function p.bylsmul(frame) | |||
local args = preload(frame) | |||
local selector = function(stat) | |||
return stat.damage.legshot_charged or stat.damage_legs_scale or 0.8 | |||
end | |||
return tostring(renderNavboxByNumbers(args, selector, formatMultiplier)) | |||
end | end | ||
return p | return p |
2022年8月10日 (水) 12:25時点における最新版
このモジュールについての説明文ページを モジュール:WeaponNavbox/doc に作成できます
local p = {} local table = require('Module:TableExtensions') 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') :addClass('tpl-navbox-list') :tag('ul') end local function createRowForType(lang) return function(tbl, name, num) local type = nu.type(name, lang, num) 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 = string.format( '%s <span class="text-ammo-special">%s</span>', iu.ammo('special_sniper', opts), nu.type('supply_drop', lang)) 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 getCreateRowForNumbers(fmt) return function(tbl, num) return createRow(tbl, fmt(num)) end end local function renderNavbox(keys, names, fn, stat, fmt) fmt = fmt or function(value, name) return string.format('[[%s]]', value) end 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 target = names[name] if target then local list = fn(tbl, name, #target) for _, value in ipairs(target) do list:tag('li') :wikitext(fmt(value, stat)) end end end return tbl:done() end local function formatAmmoText(value, stat) local ammoraw = stat[value].ammo local ammo if aw.stringstarts(ammoraw, 'special_') then ammo = 'special' else ammo = ammoraw end return string.format('[[%s|<span class="text-ammo text-ammo-%s">%s</span>]]', value, ammo, value) 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_weapon', 'sniper', 'shotgun', 'pistol', 'ultimate' }, weaponsByTypes, createRowForType(args.lang), stat, formatAmmoText) 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 renderNavboxByNumbers(args, selector, formatter) local stat = mw.loadData('Module:Stat/Weapon') local weaponsByNumbers = {} for key, value in pairs(stat) do local num = selector(value) if weaponsByNumbers[num] == nil then weaponsByNumbers[num] = {} end table.insert(weaponsByNumbers[num], key) end local keys = table.keys(weaponsByNumbers) table.sort(keys) return renderNavbox( keys, weaponsByNumbers, getCreateRowForNumbers(formatter), stat, formatAmmoText) 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 local function formatMultiplier(num) return string.format('%s倍', num) end function p.byhsmul(frame) local args = preload(frame) local selector = function(stat) return stat.damage.headshot_charged or stat.damage_head_scale or 2 end return tostring(renderNavboxByNumbers(args, selector, formatMultiplier)) end function p.bylsmul(frame) local args = preload(frame) local selector = function(stat) return stat.damage.legshot_charged or stat.damage_legs_scale or 0.8 end return tostring(renderNavboxByNumbers(args, selector, formatMultiplier)) end return p