| 🌟 | 現在、 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:DamageTables」の版間の差分
ナビゲーションに移動
検索に移動
(言語設定機能の追加) |
(ローカライズ機能の実装) |
||
| 1行目: | 1行目: | ||
local p = {} | local p = {} | ||
local cfg = mw.loadData('Module:DamageTables/configuration') | |||
local aw = require('Module:Utility/Library') | local aw = require('Module:Utility/Library') | ||
| 88行目: | 89行目: | ||
end | end | ||
local function appendGroupTables(builder, name, args, idx, mul, | local function appendGroupTables(builder, name, args, idx, mul, ctx, opts) | ||
if not opts.notCreateNewGroup then | if not opts.notCreateNewGroup then | ||
builder | builder | ||
| 115行目: | 116行目: | ||
args2.passthroughsup = args.passthrough | args2.passthroughsup = args.passthrough | ||
end | end | ||
builder:append(DamageTable._main(args2, frame)) | builder:append(DamageTable._main(args2, ctx.frame)) | ||
if args.amped then | if args.amped then | ||
local ampedCover = inu.tactical('amped_cover') | local ampedCover = inu.tactical('amped_cover', { lang = ctx.lang }) | ||
if name == | if name == ctx.res.normal then | ||
args2.caption = ampedCover | args2.caption = ampedCover | ||
else | else | ||
| 133行目: | 134行目: | ||
function p._main(args, frame) | function p._main(args, frame) | ||
-- load resources | |||
local lang = args.lang or 'ja' | |||
args.lang = lang | |||
local res = cfg[lang] | |||
local ctx = { | |||
frame = frame, | |||
lang = lang, | |||
cfg = cfg, | |||
res = res, | |||
} | |||
-- init value | -- init value | ||
local initValues = { | local initValues = { | ||
| 160行目: | 172行目: | ||
builder:append('<div class="group-container">\n') | builder:append('<div class="group-container">\n') | ||
appendGroupTables(builder, | appendGroupTables(builder, res.normal, args, 1, 1, ctx, { notCreateNewGroup = true }) | ||
if args.passthrough < 1 then | if args.passthrough < 1 then | ||
local caption = string.format( | local caption = string.format(cfg.caption_format, res.piercing_shots, args.passthrough) | ||
appendGroupTables(builder, caption, args, 1, 1, | appendGroupTables(builder, caption, args, 1, 1, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true }) | ||
end | end | ||
for i = 2, maxcount do | for i = 2, maxcount do | ||
local varname = string.format('name%d', i) | local varname = string.format('name%d', i) | ||
if args[varname] then | if args[varname] then | ||
appendGroupTables(builder, args[varname], args, i, 1, | appendGroupTables(builder, args[varname], args, i, 1, ctx, empty) | ||
if args.passthrough < 1 then | if args.passthrough < 1 then | ||
local caption = string.format('% | local caption = string.format('%s%s' .. cfg.caption_format, args[varname], cfg.separator, res.piercing_shots, args.passthrough) | ||
appendGroupTables(builder, caption, args, i, 1, | appendGroupTables(builder, caption, args, i, 1, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true }) | ||
end | end | ||
end | end | ||
| 177行目: | 189行目: | ||
if args.disruptor > 1 then | if args.disruptor > 1 then | ||
local caption = string.format('%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor) | local caption = string.format('%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor) | ||
appendGroupTables(builder, caption, args, 1, 1, | appendGroupTables(builder, caption, args, 1, 1, ctx, { useDisruptor = true }) | ||
end | end | ||
if args.hammerpoint > 1 then | if args.hammerpoint > 1 then | ||
local caption = string.format('%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint) | local caption = string.format('%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint) | ||
appendGroupTables(builder, caption, args, 1, 1, | appendGroupTables(builder, caption, args, 1, 1, ctx, { useHammerpoint = true }) | ||
end | end | ||
| 189行目: | 201行目: | ||
builder | builder | ||
:append('</div>\n') | :append('</div>\n') | ||
:append( | :append(string.format(cfg.passive_park, res.lowprofile)) | ||
:append('<div class="group-container">\n') | :append('<div class="group-container">\n') | ||
appendGroupTables(builder, | appendGroupTables(builder, res.lowprofile, args, 1, lowprofile, ctx, { notCreateNewGroup = true }) | ||
if args.passthrough < 1 then | if args.passthrough < 1 then | ||
local caption = string.format(' | local caption = string.format('%s%s' .. cfg.caption_format, res.lowprofile, cfg.separator, res.piercing_shots, args.passthrough) | ||
appendGroupTables(builder, caption, args, 1, lowprofile, | appendGroupTables(builder, caption, args, 1, lowprofile, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true }) | ||
end | end | ||
for i = 2, maxcount do | for i = 2, maxcount do | ||
local varname = string.format('name%d', i) | local varname = string.format('name%d', i) | ||
if args[varname] then | if args[varname] then | ||
local caption = string.format('%s%s%s', res.lowprofile, cfg.separator, args[varname]) | |||
appendGroupTables(builder, caption, args, i, lowprofile, ctx, empty) | |||
if args.passthrough < 1 then | if args.passthrough < 1 then | ||
local caption = string.format(' | local caption = string.format('%s%s%s%s' .. cfg.caption_format, res.lowprofile, cfg.separator, args[varname], cfg.separator, res.piercing_shots, args.passthrough) | ||
appendGroupTables(builder, caption, args, i, lowprofile, | appendGroupTables(builder, caption, args, i, lowprofile, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true }) | ||
end | end | ||
end | end | ||
| 209行目: | 222行目: | ||
if args.disruptor > 1 then | if args.disruptor > 1 then | ||
local caption = string.format('小柄+%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor) | local caption = string.format('小柄+%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor) | ||
appendGroupTables(builder, caption, args, 1, lowprofile, | appendGroupTables(builder, caption, args, 1, lowprofile, ctx, { useDisruptor = true }) | ||
end | end | ||
if args.hammerpoint > 1 then | if args.hammerpoint > 1 then | ||
local caption = string.format('小柄+%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint) | local caption = string.format('小柄+%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint) | ||
appendGroupTables(builder, caption, args, 1, lowprofile, | appendGroupTables(builder, caption, args, 1, lowprofile, ctx, { useHammerpoint = true }) | ||
end | end | ||
end | end | ||
| 222行目: | 235行目: | ||
builder | builder | ||
:append('</div>\n') | :append('</div>\n') | ||
:append( | :append(string.format(cfg.passive_park, res.fortified)) | ||
:append('<div class="group-container">\n') | :append('<div class="group-container">\n') | ||
appendGroupTables(builder, | appendGroupTables(builder, res.fortified, args, 1, fortified, ctx, { notCreateNewGroup = true }) | ||
if args.passthrough < 1 then | if args.passthrough < 1 then | ||
local caption = string.format(' | local caption = string.format('%s%s' .. cfg.caption_format, res.fortified, cfg.separator, res.piercing_shots, args.passthrough) | ||
appendGroupTables(builder, caption, args, 1, fortified, | appendGroupTables(builder, caption, args, 1, fortified, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true }) | ||
end | end | ||
for i = 2, maxcount do | for i = 2, maxcount do | ||
local varname = string.format('name%d', i) | local varname = string.format('name%d', i) | ||
if args[varname] then | if args[varname] then | ||
local caption = string.format('%s%s%s', res.fortified, cfg.separator, args[varname]) | |||
appendGroupTables(builder, caption, args, i, fortified, ctx, empty) | |||
if args.passthrough < 1 then | if args.passthrough < 1 then | ||
local caption = string.format(' | local caption = string.format('%s%s%s%s' .. cfg.caption_format, res.fortified, cfg.separator, args[varname], cfg.separator, res.piercing_shots, args.passthrough) | ||
appendGroupTables(builder, caption, args, i, fortified, | appendGroupTables(builder, caption, args, i, fortified, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true }) | ||
end | end | ||
end | end | ||
| 242行目: | 256行目: | ||
if args.disruptor > 1 then | if args.disruptor > 1 then | ||
local caption = string.format('鉄壁+%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor) | local caption = string.format('鉄壁+%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor) | ||
appendGroupTables(builder, caption, args, 1, fortified, | appendGroupTables(builder, caption, args, 1, fortified, ctx, { useDisruptor = true }) | ||
end | end | ||
if args.hammerpoint > 1 then | if args.hammerpoint > 1 then | ||
local caption = string.format('鉄壁+%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint) | local caption = string.format('鉄壁+%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint) | ||
appendGroupTables(builder, caption, args, 1, fortified, | appendGroupTables(builder, caption, args, 1, fortified, ctx, { useHammerpoint = true }) | ||
end | end | ||
end | end | ||
2021年5月9日 (日) 18:39時点における版
このモジュールについての説明文ページを モジュール:DamageTables/doc に作成できます
local p = {}
local cfg = mw.loadData('Module:DamageTables/configuration')
local aw = require('Module:Utility/Library')
local iu = require('Module:Utility/Image')
local inu = require('Module:Utility/ImageWithName')
local DamageTable = require('Module:DamageTable')
local getArgs -- lazily initialized
local indexableValues = {
damage = 20,
beamdamage = 0,
ticks = 0,
pellet = 1,
head = 2,
leg = 0.8,
rps = 0,
}
local copiedValues = {
damagemin = 1000,
damagemax = 0,
beamdamagemin = 0,
beamdamagemax = 0,
pelletmin = 0,
pelletmax = 0,
headmax = -1,
legmin = 0,
mulmin = 0.85,
mulmax = 1.05,
skullpiercer = 1,
rpsratio1 = 0,
rpsratio2 = 0,
rpsratio3 = 0,
raise = 0,
reload = 0,
reloadratio2 = 0.95,
reloadratio3 = 0.9,
extmag0 = 0,
extmag1 = 0,
extmag2 = 0,
extmag3 = 0,
}
local copiedBooleanValues = {
round = false,
amped = false,
forcegunshield = false,
}
local copiedStringValues = {
skullpiercerrarity = 'legendary',
lang = 'ja',
}
local function rebuildArguments(base, idx, mul)
local ret = {}
-- 再構築する変数
for key, value in pairs(indexableValues) do
local temp = aw.getAsNumber(base[key .. idx], -1)
if temp < 0 then
temp = aw.getAsNumber(base[key], -1)
if temp < 0 then
temp = value
end
end
ret[key] = temp
end
-- コピーする変数
for key, value in pairs(copiedValues) do
local temp = aw.getAsNumber(base[key], -1)
if temp < 0 then
temp = value
end
ret[key] = temp
end
for key, value in pairs(copiedBooleanValues) do
ret[key] = aw.getAsBoolean(base[key], value)
end
for key, value in pairs(copiedStringValues) do
ret[key] = base[key] or value
end
return ret
end
local function appendGroupTables(builder, name, args, idx, mul, ctx, opts)
if not opts.notCreateNewGroup then
builder
:append('</div>\n')
:append('<div class="group-container">\n')
end
local args2 = rebuildArguments(args, idx, mul)
args2.amped = false
args2.caption = name
args2.mul = mul
args2.shieldinfo = args.shieldinfo
if opts.useDisruptor then
args2.disruptor = args.disruptor
else
args2.disruptorsup = args.disruptor
end
if opts.useHammerpoint then
args2.hammerpoint = args.hammerpoint
else
args2.hammerpointsup = args.hammerpoint
end
if opts.usePassthrough then
args2.passthrough = args.passthrough
else
args2.passthroughsup = args.passthrough
end
builder:append(DamageTable._main(args2, ctx.frame))
if args.amped then
local ampedCover = inu.tactical('amped_cover', { lang = ctx.lang })
if name == ctx.res.normal then
args2.caption = ampedCover
else
args2.caption = string.format('%s+%s', name, ampedCover)
end
args2.amped = true
builder:append(DamageTable._main(args2, frame))
end
end
local maxcount = 5
local empty = {}
function p._main(args, frame)
-- load resources
local lang = args.lang or 'ja'
args.lang = lang
local res = cfg[lang]
local ctx = {
frame = frame,
lang = lang,
cfg = cfg,
res = res,
}
-- init value
local initValues = {
lowprofile = -1,
fortified = -1,
disruptor = 1,
hammerpoint = 1,
passthrough = 1,
}
-- load shield info
args.shieldpreset = args.shieldpreset or 'removelowprofile'
local shieldinfo = require('Module:Stat/Shield')[args.shieldpreset]
args.shieldinfo = shieldinfo
-- fix arguments
for key, value in pairs(initValues) do
args[key] = aw.getAsNumber(args[key], value)
if args[key] == -1 then
args[key] = nil
end
end
args.amped = aw.getAsBoolean(args.amped, shieldinfo.ampedCover)
-- build node
local builder = require('Module:Utility/StringBuilder').new()
builder:append('<div class="group-container">\n')
appendGroupTables(builder, res.normal, args, 1, 1, ctx, { notCreateNewGroup = true })
if args.passthrough < 1 then
local caption = string.format(cfg.caption_format, res.piercing_shots, args.passthrough)
appendGroupTables(builder, caption, args, 1, 1, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true })
end
for i = 2, maxcount do
local varname = string.format('name%d', i)
if args[varname] then
appendGroupTables(builder, args[varname], args, i, 1, ctx, empty)
if args.passthrough < 1 then
local caption = string.format('%s%s' .. cfg.caption_format, args[varname], cfg.separator, res.piercing_shots, args.passthrough)
appendGroupTables(builder, caption, args, i, 1, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true })
end
end
end
if args.disruptor > 1 then
local caption = string.format('%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor)
appendGroupTables(builder, caption, args, 1, 1, ctx, { useDisruptor = true })
end
if args.hammerpoint > 1 then
local caption = string.format('%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint)
appendGroupTables(builder, caption, args, 1, 1, ctx, { useHammerpoint = true })
end
-- low profile
local lowprofile = args.lowprofile or shieldinfo.lowprofile
if lowprofile > 1 then
builder
:append('</div>\n')
:append(string.format(cfg.passive_park, res.lowprofile))
:append('<div class="group-container">\n')
appendGroupTables(builder, res.lowprofile, args, 1, lowprofile, ctx, { notCreateNewGroup = true })
if args.passthrough < 1 then
local caption = string.format('%s%s' .. cfg.caption_format, res.lowprofile, cfg.separator, res.piercing_shots, args.passthrough)
appendGroupTables(builder, caption, args, 1, lowprofile, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true })
end
for i = 2, maxcount do
local varname = string.format('name%d', i)
if args[varname] then
local caption = string.format('%s%s%s', res.lowprofile, cfg.separator, args[varname])
appendGroupTables(builder, caption, args, i, lowprofile, ctx, empty)
if args.passthrough < 1 then
local caption = string.format('%s%s%s%s' .. cfg.caption_format, res.lowprofile, cfg.separator, args[varname], cfg.separator, res.piercing_shots, args.passthrough)
appendGroupTables(builder, caption, args, i, lowprofile, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true })
end
end
end
if args.disruptor > 1 then
local caption = string.format('小柄+%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor)
appendGroupTables(builder, caption, args, 1, lowprofile, ctx, { useDisruptor = true })
end
if args.hammerpoint > 1 then
local caption = string.format('小柄+%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint)
appendGroupTables(builder, caption, args, 1, lowprofile, ctx, { useHammerpoint = true })
end
end
-- fortified
local fortified = args.fortified or shieldinfo.fortified
if fortified < 1 then
builder
:append('</div>\n')
:append(string.format(cfg.passive_park, res.fortified))
:append('<div class="group-container">\n')
appendGroupTables(builder, res.fortified, args, 1, fortified, ctx, { notCreateNewGroup = true })
if args.passthrough < 1 then
local caption = string.format('%s%s' .. cfg.caption_format, res.fortified, cfg.separator, res.piercing_shots, args.passthrough)
appendGroupTables(builder, caption, args, 1, fortified, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true })
end
for i = 2, maxcount do
local varname = string.format('name%d', i)
if args[varname] then
local caption = string.format('%s%s%s', res.fortified, cfg.separator, args[varname])
appendGroupTables(builder, caption, args, i, fortified, ctx, empty)
if args.passthrough < 1 then
local caption = string.format('%s%s%s%s' .. cfg.caption_format, res.fortified, cfg.separator, args[varname], cfg.separator, res.piercing_shots, args.passthrough)
appendGroupTables(builder, caption, args, i, fortified, ctx, { notCreateNewGroup = not args.amped, usePassthrough = true })
end
end
end
if args.disruptor > 1 then
local caption = string.format('鉄壁+%s <span class="text-rarity text-rarity-epic">ディスラプター弾 (x%s)</span>', iu.hopup('disruptor_rounds'), args.disruptor)
appendGroupTables(builder, caption, args, 1, fortified, ctx, { useDisruptor = true })
end
if args.hammerpoint > 1 then
local caption = string.format('鉄壁+%s <span class="text-rarity text-rarity-epic">ハンマーポイント弾 (x%s)</span>', iu.hopup('hammerpoint_rounds'), args.hammerpoint)
appendGroupTables(builder, caption, args, 1, fortified, ctx, { useHammerpoint = true })
end
end
-- close tag
builder:append('</div>')
return tostring(builder)
end
function p.main(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
args = getArgs(frame)
return p._main(args, frame)
end
return p