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

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

提供:Apex Data
ナビゲーションに移動 検索に移動
(フォーマット用の関数を追加)
(format関数のfooterがnilのケースに対処)
20行目: 20行目:
function withFrame.heirloom(self, text)
function withFrame.heirloom(self, text)
return self.frame:expandTemplate { title = 'Heirloom', args = { text }}
return self.frame:expandTemplate { title = 'Heirloom', args = { text }}
end
local function _withFrame_format(that, default, common, rare, epic)
return default .. ' → '
.. that:common(common) .. ' → '
.. that:rare(rare) .. ' → '
.. that:epic(epic)
end
end


function withFrame.format(self, default, common, rare, epic, footer)
function withFrame.format(self, default, common, rare, epic, footer)
return default .. ' → '
if footer ~= nil then
.. self:common(common) .. ' → '
return _withFrame_format(self, default, common, rare, epic) .. footer
.. self:rare(rare) .. ' → '
else
.. self:epic(epic) .. footer
return _withFrame_format(self, default, common, rare, epic)
end
end
end


function withFrame.format_to4(self, default, common, rare, epic, legendary, footer)
function withFrame.format_to4(self, default, common, rare, epic, legendary, footer)
return self:format(default, common, rare, epic) .. ' → '
footer = footer or ''
return _withFrame_format(self, default, common, rare, epic) .. ' → '
.. self:legendary(legendary) .. footer
.. self:legendary(legendary) .. footer
end
end


function withFrame.format_and5(self, default, common, rare, epic, heirloom, footer)
function withFrame.format_and5(self, default, common, rare, epic, heirloom, footer)
return self:format(default, common, rare, epic) .. ' → '
footer = footer or ''
return _withFrame_format(self, default, common, rare, epic) .. ' → '
.. self:heirloom(heirloom) .. footer
.. self:heirloom(heirloom) .. footer
end
end
94行目: 104行目:


function withoutFrame.format(self, default, common, rare, epic, footer)
function withoutFrame.format(self, default, common, rare, epic, footer)
footer = footer or ''
return default .. ' → '
return default .. ' → '
.. self:common(common) .. ' → '
.. self:common(common) .. ' → '
101行目: 112行目:


function withoutFrame.format_to4(self, default, common, rare, epic, legendary, footer)
function withoutFrame.format_to4(self, default, common, rare, epic, legendary, footer)
footer = footer or ''
return self:format(default, common, rare, epic) .. ' → '
return self:format(default, common, rare, epic) .. ' → '
.. self:legendary(legendary) .. footer
.. self:legendary(legendary) .. footer
106行目: 118行目:


function withoutFrame.format_and5(self, default, common, rare, epic, heirloom, footer)
function withoutFrame.format_and5(self, default, common, rare, epic, heirloom, footer)
footer = footer or ''
return self:format(default, common, rare, epic) .. ' → '
return self:format(default, common, rare, epic) .. ' → '
.. self:heirloom(heirloom) .. footer
.. self:heirloom(heirloom) .. footer

2021年1月29日 (金) 11:40時点における版

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

-- frame変数がある場合のFormatter
local withFrame = {}

function withFrame.common(self, text)
	return self.frame:expandTemplate { title = 'Common', args = { text }}
end

function withFrame.rare(self, text)
	return self.frame:expandTemplate { title = 'Rare', args = { text }}
end

function withFrame.epic(self, text)
	return self.frame:expandTemplate { title = 'Epic', args = { text }}
end

function withFrame.legendary(self, text)
	return self.frame:expandTemplate { title = 'Legendary', args = { text }}
end

function withFrame.heirloom(self, text)
	return self.frame:expandTemplate { title = 'Heirloom', args = { text }}
end

local function _withFrame_format(that, default, common, rare, epic)
	return default .. ' → '
		.. that:common(common) .. ' → '
		.. that:rare(rare) .. ' → '
		.. that:epic(epic)
end

function withFrame.format(self, default, common, rare, epic, footer)
	if footer ~= nil then
		return _withFrame_format(self, default, common, rare, epic) .. footer
	else
		return _withFrame_format(self, default, common, rare, epic)
	end
end

function withFrame.format_to4(self, default, common, rare, epic, legendary, footer)
	footer = footer or ''
	return _withFrame_format(self, default, common, rare, epic) .. ' → '
		.. self:legendary(legendary) .. footer
end

function withFrame.format_and5(self, default, common, rare, epic, heirloom, footer)
	footer = footer or ''
	return _withFrame_format(self, default, common, rare, epic) .. ' → '
		.. self:heirloom(heirloom) .. footer
end

function withFrame.hopup(self, text, size)
	size = size or 24
	return self.frame:expandTemplate { title = 'Hopup', args = { text, size = size }}
end

local levelTableWithFrame = {
	withFrame.common,
	withFrame.rare,
	withFrame.epic,
	withFrame.legendary,
	withFrame.heirloom,
}
function withFrame.level(self, level, text)
	return levelTableWithFrame[level](self, text)
end

-- frame変数がない場合のFormatter
local withoutFrame = {}

function withoutFrame.common(self, text)
	local html = mw.html.create('span')
		:css('color', '#A8A8A8')
		:wikitext(text)
	return tostring(html)
end

function withoutFrame.rare(self, text)
	local html = mw.html.create('span')
		:css('color', '#51A8D6')
		:wikitext(text)
	return tostring(html)
end

function withoutFrame.epic(self, text)
	local html = mw.html.create('span')
		:css('color', '#B237C8')
		:wikitext(text)
	return tostring(html)
end

function withoutFrame.legendary(self, text)
	local html = mw.html.create('span')
		:css('color', '#CEAD21')
		:wikitext(text)
	return tostring(html)
end

function withoutFrame.heirloom(self, text)
	local html = mw.html.create('span')
		:css('color', '#FF4E1D')
		:wikitext(text)
	return tostring(html)
end

function withoutFrame.format(self, default, common, rare, epic, footer)
	footer = footer or ''
	return default .. ' → '
		.. self:common(common) .. ' → '
		.. self:rare(rare) .. ' → '
		.. self:epic(epic) .. footer
end

function withoutFrame.format_to4(self, default, common, rare, epic, legendary, footer)
	footer = footer or ''
	return self:format(default, common, rare, epic) .. ' → '
		.. self:legendary(legendary) .. footer
end

function withoutFrame.format_and5(self, default, common, rare, epic, heirloom, footer)
	footer = footer or ''
	return self:format(default, common, rare, epic) .. ' → '
		.. self:heirloom(heirloom) .. footer
end

function withoutFrame.hopup(self, text, size)
	if text == "スカルピアサーライフリング" then
		return "[スカピ]"
	else
		return text
	end
end

local levelTableWithoutFrame = {
	withoutFrame.common,
	withoutFrame.rare,
	withoutFrame.epic,
	withoutFrame.legendary,
	withoutFrame.heirloom,
}
function withoutFrame.level(self, level, text)
	return levelTableWithoutFrame[level](self, text)
end

-- コンストラクター
local p = {}

function p.new(frame)
	local obj
	if frame ~= nil then
		obj = setmetatable({
			frame = frame,
		}, { __index = withFrame })
	else
		obj = setmetatable({}, { __index = withoutFrame })
	end
	return obj
end

return p