| 🌟 | 現在、  鉄壁ヘッドショットには対応済みです。 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 | 
「モジュール:Utility/Formatter」の版間の差分
		
		
		
		
		
		ナビゲーションに移動
		検索に移動
		
				
		
		
	
|  (弾薬のリンクに対応) |  (未使用の関数を削除) | ||
| (同じ利用者による、間の15版が非表示) | |||
| 2行目: | 2行目: | ||
| local withFrame = {} | local withFrame = {} | ||
| function withFrame.common(self, text) | function withFrame.common(self, text, class) | ||
| 	return self.frame:expandTemplate { title = 'Common', args = { text }} | 	return self.frame:expandTemplate { title = 'Common', args = { text, class = class }} | ||
| end | end | ||
| function withFrame.rare(self, text) | function withFrame.rare(self, text, class) | ||
| 	return self.frame:expandTemplate { title = 'Rare', args = { text }} | 	return self.frame:expandTemplate { title = 'Rare', args = { text, class = class }} | ||
| end | end | ||
| function withFrame.epic(self, text) | function withFrame.epic(self, text, class) | ||
| 	return self.frame:expandTemplate { title = 'Epic', args = { text }} | 	return self.frame:expandTemplate { title = 'Epic', args = { text, class = class }} | ||
| end | end | ||
| function withFrame.legendary(self, text) | function withFrame.legendary(self, text, class) | ||
| 	return self.frame:expandTemplate { title = 'Legendary', args = { text }} | 	return self.frame:expandTemplate { title = 'Legendary', args = { text, class = class }} | ||
| end | end | ||
| function withFrame.heirloom(self, text) | function withFrame.heirloom(self, text, class) | ||
| 	return self.frame:expandTemplate { title = 'Heirloom', args = { text }} | 	return self.frame:expandTemplate { title = 'Heirloom', args = { text, class = class }} | ||
| end | end | ||
| local function _withFrame_format(that, default, common, rare, epic) | local function _withFrame_format(that, default, common, rare, epic, separator) | ||
| 	if common ~= nil then | |||
| 		default = default .. separator .. that:common(common) | |||
| 	end | |||
| 	if rare ~= nil then | |||
| 		default = default .. separator .. that:rare(rare) | |||
| 	end | |||
| 	if epic ~= nil then | |||
| 		default = default .. separator .. that:epic(epic) | |||
| 	end | |||
| 	return default | |||
| end | end | ||
| function withFrame.format(self, default, common, rare, epic, footer) | function withFrame.format(self, default, common, rare, epic, footer, separator) | ||
| 	separator = separator or ' → ' | |||
| 	if footer ~= nil then | 	if footer ~= nil then | ||
| 		return _withFrame_format(self, default, common, rare, epic) .. footer | 		return _withFrame_format(self, default, common, rare, epic, separator) .. footer | ||
| 	else | 	else | ||
| 		return _withFrame_format(self, default, common, rare, epic) | 		return _withFrame_format(self, default, common, rare, epic, separator) | ||
| 	end | 	end | ||
| end | end | ||
| function withFrame. | function withFrame.hopup(self, text, opts) | ||
| 	opts = opts or {} | |||
| 	return self.frame:expandTemplate { | |||
| 		title = 'Hopup', | |||
| 		args = { | |||
| 			text, | |||
| 			size = opts.size or 16, | |||
| 			link = opts.link, | |||
| 			rariry = opts.rariry, | |||
| 		}, | |||
| 	} | |||
| 	return self.frame:expandTemplate { title = ' | |||
| end | end | ||
| 67行目: | 64行目: | ||
| 	withFrame.heirloom, | 	withFrame.heirloom, | ||
| } | } | ||
| function withFrame.level(self, level, text) | function withFrame.level(self, level, text, class) | ||
| 	return levelTableWithFrame[level](self, text) | 	if level <= 0 then | ||
| 		if class then | |||
| 			local html = mw.html.create('span') | |||
| 				:addClass(class) | |||
| 				:wikitext(text) | |||
| 			return tostring(html) | |||
| 		else | |||
| 			return text | |||
| 		end | |||
| 	else | |||
| 		return levelTableWithFrame[level](self, text, class) | |||
| 	end | |||
| end | end | ||
| 74行目: | 82行目: | ||
| local withoutFrame = {} | local withoutFrame = {} | ||
| function withoutFrame.common(self, text) | function withoutFrame.common(self, text, class) | ||
| 	local html = mw.html.create('span') | 	local html = mw.html.create('span') | ||
| 		:addClass(class) | |||
| 		:css('color', '#A8A8A8') | 		:css('color', '#A8A8A8') | ||
| 		:wikitext(text) | 		:wikitext(text) | ||
| 81行目: | 90行目: | ||
| end | end | ||
| function withoutFrame.rare(self, text) | function withoutFrame.rare(self, text, class) | ||
| 	local html = mw.html.create('span') | 	local html = mw.html.create('span') | ||
| 		:addClass(class) | |||
| 		:css('color', '#51A8D6') | 		:css('color', '#51A8D6') | ||
| 		:wikitext(text) | 		:wikitext(text) | ||
| 88行目: | 98行目: | ||
| end | end | ||
| function withoutFrame.epic(self, text) | function withoutFrame.epic(self, text, class) | ||
| 	local html = mw.html.create('span') | 	local html = mw.html.create('span') | ||
| 		:addClass(class) | |||
| 		:css('color', '#B237C8') | 		:css('color', '#B237C8') | ||
| 		:wikitext(text) | 		:wikitext(text) | ||
| 95行目: | 106行目: | ||
| end | end | ||
| function withoutFrame.legendary(self, text) | function withoutFrame.legendary(self, text, class) | ||
| 	local html = mw.html.create('span') | 	local html = mw.html.create('span') | ||
| 		:addClass(class) | |||
| 		:css('color', '#CEAD21') | 		:css('color', '#CEAD21') | ||
| 		:wikitext(text) | 		:wikitext(text) | ||
| 102行目: | 114行目: | ||
| end | end | ||
| function withoutFrame.heirloom(self, text) | function withoutFrame.heirloom(self, text, class) | ||
| 	local html = mw.html.create('span') | 	local html = mw.html.create('span') | ||
| 		:addClass(class) | |||
| 		:css('color', '#FF4E1D') | 		:css('color', '#FF4E1D') | ||
| 		:wikitext(text) | 		:wikitext(text) | ||
| 109行目: | 122行目: | ||
| end | end | ||
| function withoutFrame.format(self, default, common, rare, epic, footer) | function withoutFrame.format(self, default, common, rare, epic, footer, separator) | ||
| 	footer = footer or '' | 	footer = footer or '' | ||
| 	return default ..  | 	separator = separator or ' → ' | ||
| 		.. self:common(common) ..  | 	return default .. separator | ||
| 		.. self:rare(rare) ..  | 		.. self:common(common) .. separator | ||
| 		.. self:rare(rare) .. separator | |||
| 		.. self:epic(epic) .. footer | 		.. self:epic(epic) .. footer | ||
| end | end | ||
| function withoutFrame.hopup(self, text, opts) | |||
| function withoutFrame.hopup(self, text,  | |||
| 	if text == 'スカルピアサーライフリング' then | 	if text == 'スカルピアサーライフリング' then | ||
| 		return '[スカピ]' | 		return '[スカピ]' | ||
| 	elseif text == 'ハンマーポイント弾' then | |||
| 		return '🔨' | |||
| 	else | 	else | ||
| 		return '[' .. text .. ']' | 		return '[' .. text .. ']' | ||
| 148行目: | 148行目: | ||
| 	withoutFrame.heirloom, | 	withoutFrame.heirloom, | ||
| } | } | ||
| function withoutFrame.level(self, level, text) | function withoutFrame.level(self, level, text, class) | ||
| 	return levelTableWithoutFrame[level](self, text) | 	if level <= 0 then | ||
| 		if class then | |||
| 			local html = mw.html.create('span') | |||
| 				:addClass(class) | |||
| 				:wikitext(text) | |||
| 			return tostring(html) | |||
| 		else | |||
| 			return text | |||
| 		end | |||
| 	else | |||
| 		return levelTableWithoutFrame[level](self, text, class) | |||
| 	end | |||
| end | end | ||
2021年5月14日 (金) 18:07時点における最新版
このモジュールについての説明文ページを モジュール:Utility/Formatter/doc に作成できます
-- frame変数がある場合のFormatter
local withFrame = {}
function withFrame.common(self, text, class)
	return self.frame:expandTemplate { title = 'Common', args = { text, class = class }}
end
function withFrame.rare(self, text, class)
	return self.frame:expandTemplate { title = 'Rare', args = { text, class = class }}
end
function withFrame.epic(self, text, class)
	return self.frame:expandTemplate { title = 'Epic', args = { text, class = class }}
end
function withFrame.legendary(self, text, class)
	return self.frame:expandTemplate { title = 'Legendary', args = { text, class = class }}
end
function withFrame.heirloom(self, text, class)
	return self.frame:expandTemplate { title = 'Heirloom', args = { text, class = class }}
end
local function _withFrame_format(that, default, common, rare, epic, separator)
	if common ~= nil then
		default = default .. separator .. that:common(common)
	end
	if rare ~= nil then
		default = default .. separator .. that:rare(rare)
	end
	if epic ~= nil then
		default = default .. separator .. that:epic(epic)
	end
	return default
end
function withFrame.format(self, default, common, rare, epic, footer, separator)
	separator = separator or ' → '
	if footer ~= nil then
		return _withFrame_format(self, default, common, rare, epic, separator) .. footer
	else
		return _withFrame_format(self, default, common, rare, epic, separator)
	end
end
function withFrame.hopup(self, text, opts)
	opts = opts or {}
	return self.frame:expandTemplate {
		title = 'Hopup',
		args = {
			text,
			size = opts.size or 16,
			link = opts.link,
			rariry = opts.rariry,
		},
	}
end
local levelTableWithFrame = {
	withFrame.common,
	withFrame.rare,
	withFrame.epic,
	withFrame.legendary,
	withFrame.heirloom,
}
function withFrame.level(self, level, text, class)
	if level <= 0 then
		if class then
			local html = mw.html.create('span')
				:addClass(class)
				:wikitext(text)
			return tostring(html)
		else
			return text
		end
	else
		return levelTableWithFrame[level](self, text, class)
	end
end
-- frame変数がない場合のFormatter
local withoutFrame = {}
function withoutFrame.common(self, text, class)
	local html = mw.html.create('span')
		:addClass(class)
		:css('color', '#A8A8A8')
		:wikitext(text)
	return tostring(html)
end
function withoutFrame.rare(self, text, class)
	local html = mw.html.create('span')
		:addClass(class)
		:css('color', '#51A8D6')
		:wikitext(text)
	return tostring(html)
end
function withoutFrame.epic(self, text, class)
	local html = mw.html.create('span')
		:addClass(class)
		:css('color', '#B237C8')
		:wikitext(text)
	return tostring(html)
end
function withoutFrame.legendary(self, text, class)
	local html = mw.html.create('span')
		:addClass(class)
		:css('color', '#CEAD21')
		:wikitext(text)
	return tostring(html)
end
function withoutFrame.heirloom(self, text, class)
	local html = mw.html.create('span')
		:addClass(class)
		:css('color', '#FF4E1D')
		:wikitext(text)
	return tostring(html)
end
function withoutFrame.format(self, default, common, rare, epic, footer, separator)
	footer = footer or ''
	separator = separator or ' → '
	return default .. separator
		.. self:common(common) .. separator
		.. self:rare(rare) .. separator
		.. self:epic(epic) .. footer
end
function withoutFrame.hopup(self, text, opts)
	if text == 'スカルピアサーライフリング' then
		return '[スカピ]'
	elseif 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, class)
	if level <= 0 then
		if class then
			local html = mw.html.create('span')
				:addClass(class)
				:wikitext(text)
			return tostring(html)
		else
			return text
		end
	else
		return levelTableWithoutFrame[level](self, text, class)
	end
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