| 🌟 | 現在、 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:WeaponNavbox」の版間の差分
ナビゲーションに移動
検索に移動
(クラス名の付与形態を変更) |
(分類による武器一覧の生成ロジックを追加) |
||
| 5行目: | 5行目: | ||
local function stringStarts(str, start) | local function stringStarts(str, start) | ||
return string.sub(str, 1, string.len(start)) == start | return string.sub(str, 1, string.len(start)) == start | ||
end | |||
local TypeDict = { | |||
assault_rifle = "アサルトライフル", | |||
sub_machine_gun = "サブマシンガン", | |||
light_machine_gun = "ライトマシンガン", | |||
sniper = "スナイパーライフル", | |||
shotgun = "ショットガン", | |||
pistol = "ピストル", | |||
} | |||
local function createRowForType(tbl, name, weaponsByType) | |||
local type = TypeDict[name] | |||
local page = '武器#' .. type | |||
local list = tbl:tag('tr') | |||
:tag('th') | |||
:wikitext('[[' .. page .. '|' .. type .. ']]') | |||
:done() | |||
:tag('td') | |||
:tag('ul') | |||
:addClass('tpl-navbox-list') | |||
for _, value in ipairs(weaponsByType) do | |||
list:tag('li') | |||
:wikitext(string.format('[[%s]]', value)) | |||
end | |||
end | end | ||
| 14行目: | 38行目: | ||
shotgun = "ショットガン", | shotgun = "ショットガン", | ||
} | } | ||
local function createRowForAmmo(tbl, name, weaponsByAmmo) | |||
local function | |||
local item | local item | ||
if name == 'special' then | if name == 'special' then | ||
| 38行目: | 61行目: | ||
end | end | ||
local function renderNavbox( | local function renderNavbox(keys, names, fn) | ||
local tbl = mw.html.create('table') | local tbl = mw.html.create('table') | ||
:addClass('tpl-navbox-table') | :addClass('tpl-navbox-table') | ||
| 65行目: | 70行目: | ||
:addClass('tpl-navbox-table-title') | :addClass('tpl-navbox-table-title') | ||
:wikitext('武器') | :wikitext('武器') | ||
for _, name in ipairs( | for _, name in ipairs(keys) do | ||
fn(tbl, name, names[name]) | |||
end | end | ||
return tbl:done() | return tbl:done() | ||
end | end | ||
function p. | 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 | |||
function p.bytype(frame) | |||
formatter = require('Module:Utility/Formatter').new(frame) | formatter = require('Module:Utility/Formatter').new(frame) | ||
return tostring( | return tostring(renderNavboxByType(args)) | ||
end | end | ||
function p. | function p.byammo(frame) | ||
formatter = require('Module:Utility/Formatter').new(frame) | |||
return tostring(renderNavboxByAmmo(args)) | |||
end | end | ||
return p | return p | ||
2021年2月8日 (月) 10:55時点における版
このモジュールについての説明文ページを モジュール:WeaponNavbox/doc に作成できます
local p = {}
local formatter -- lazily initialized
local function stringStarts(str, start)
return string.sub(str, 1, string.len(start)) == start
end
local TypeDict = {
assault_rifle = "アサルトライフル",
sub_machine_gun = "サブマシンガン",
light_machine_gun = "ライトマシンガン",
sniper = "スナイパーライフル",
shotgun = "ショットガン",
pistol = "ピストル",
}
local function createRowForType(tbl, name, weaponsByType)
local type = TypeDict[name]
local page = '武器#' .. type
local list = tbl:tag('tr')
:tag('th')
:wikitext('[[' .. page .. '|' .. type .. ']]')
:done()
:tag('td')
:tag('ul')
:addClass('tpl-navbox-list')
for _, value in ipairs(weaponsByType) do
list:tag('li')
:wikitext(string.format('[[%s]]', value))
end
end
local AmmoDict = {
light = "ライト",
heavy = "ヘビー",
energy = "エネルギー",
sniper = "スナイパー",
shotgun = "ショットガン",
}
local function createRowForAmmo(tbl, name, weaponsByAmmo)
local item
if name == 'special' then
item = formatter:ammo('専用スナイパー', 20) .. ' ケアパッケージ'
else
local ammo = AmmoDict[name]
local page = '弾による武器一覧#' .. ammo .. 'アモ'
item = formatter:ammo(ammo, 20, page) .. ' [[' .. page .. '|' .. ammo .. 'アモ]]'
end
local list = tbl:tag('tr')
:tag('th')
:wikitext(item)
:done()
:tag('td')
:tag('ul')
:addClass('tpl-navbox-list')
for _, value in ipairs(weaponsByAmmo) do
list:tag('li')
:wikitext(string.format('[[%s]]', value))
end
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
fn(tbl, name, names[name])
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
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
return p