モジュール:スポーツ前次王座

モジュールの解説[表示] [編集] [履歴] [キャッシュを破棄]

Template:スポーツ前次王座の内部モジュール。

使用法[編集]

{{#invoke:スポーツ前次王座|main}}

local p = {}

-- エラー
function p.error ( message )
	return '<strong class="error">エラー:' ..message ..'</strong>'
end

-- 文字装飾
function p.small ( text )
	return '<span style="font-size: 80%;">' ..text ..'</span>'
end

function p.bold ( text )
	return '<span style="font-weight: bold;">' ..text ..'</span>'
end

function p.itaric ( text )
	return '<span style="font-style: italic;">' ..text ..'</span>'
end

-- 本体
function p.main( frame )
	local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:スポーツ前次王座', removeBlanks = false })

	local num		= args[1] or args['歴代数']		or '' -- 歴代数
	local group		= args[2] or args['認定団体']	or '' -- 認定団体
	local class		= args[3] or args['階級']		or '' -- 階級
	local before	= args[4] or args['前王者']		or '' -- 前王者
	local after		= args[5] or args['次王者']		or '' -- 次王者
	local reign		= args[6] or args['在位期間']	or '' -- 在位期間

	local type		= args[7] or args['type'] or args['表示タイプ'] or '' -- 表示タイプ

	-- typeが空欄の場合とりあえず1 (Championshiptitle) を入れておく
	if type == '' then
		type = '1'
	end

	-- 先代・次代が空欄の場合 [[n/a|N/A]] にリンク
	if before == '' then
		before = 'n/a|N/A'
	end
	if after == '' then
		after = 'n/a|N/A'
	end

	local before_link = before
	local after_link = after
	-- num, group, class, before, after, reignを3枠に配置
	local L_cell = before -- no link
	local C_cell = reign
	local R_cell = after -- no link
	if string.find(before, '(?[)') == nil then
		before_link = '[[' ..before ..']]'
	end
	if string.find(after, '(?[)') == nil then
		if string.find(after, '消滅') == nil then
			after_link = '[[' ..after ..']]'
		end
	end

	local title = p.bold ( num ..group ..class ..'王者' )
	local blank = p.bold ( '空位<br />' )

	-- Championshiptitle先空
	if type == '先空' or type == '前空' then
		L_cell = blank ..'(前タイトル獲得者:' ..before_link ..')'
		R_cell = after_link

	-- Championshiptitle次空
	elseif type == '次空' then
		L_cell = before_link
		R_cell = blank ..'(次タイトル獲得者:' ..after_link ..')'

	-- Championshiptitle先次空
	elseif type == '先次空' or type == '前次空' then
		L_cell = blank ..'(前タイトル獲得者:' ..before_link ..')'
		R_cell = blank ..'(次タイトル獲得者:' ..after_link ..')'

	-- Championshiptitleスーパー王座1 - 3
	elseif type == 'スーパー王座1' or type == 'スーパー王座2' or type == 'スーパー王座3' then
		title  = p.bold ( '[[世界ボクシング協会|WBA]]' ..num ..group ..class ..'[[スーパー王者]]' )
		L_cell = before_link
		R_cell = after_link

	-- Championshiptitle
	elseif type == '1' then
		L_cell = before_link
		R_cell = after_link

	-- Championshiptitle-1
	elseif type == '1-1' then
		L_cell = before
		R_cell = after_link

	-- Championshiptitle-2
	elseif type == '1-2' then
		L_cell = before_link

	-- Championshiptitle-3 / Championshiptitle0
	elseif type == '1-3' or type == '0' then
	-- 何もしない

	-- Championshiptitle暫定王座1
	elseif type == '暫定王座1' then
		title  = p.bold ( num ..group ..class ..'[[暫定王座|暫定王者]]' )
		L_cell = '暫定王者決定戦' ..p.bold( '対戦者:' ) ..'[[' ..string.gsub(before_link, '%p', '') ..']]'
		if string.find(after, '消滅') == nil then
			after_link = '[[' ..after ..']]'
		end
		R_cell = p.bold( '次暫定王者:' ) ..after_link

	-- Championshiptitle暫定王座2
	elseif type == '暫定王座2' then
		title  = p.bold ( num ..group ..class ..'[[暫定王座|暫定王者]]' )
		L_cell = p.bold( '前暫定王者:' ) ..'[[' ..string.gsub(before_link, '%p', '') ..']]'
		if string.find(after, '消滅') == nil then
			after_link = '[[' ..after ..']]'
		end
		R_cell = p.bold( '次暫定王者:' ) ..after_link


	-- Championshiptitle2
	elseif type == '2' then
		title  = p.bold ( num ..group ..class ..'優勝' )
		L_cell = before_link
		R_cell = after_link

	-- Championshiptitle2-1
	elseif type == '2-1' then
		title  = p.bold ( num ..group ..class ..'優勝' )
		R_cell = after_link

	-- Championshiptitle2-2
	elseif type == '2-2' then
		title  = p.bold ( num ..group ..class ..'優勝' )
		L_cell = before_link

	-- Championshiptitle2-3
	elseif type == '2-3' then
		title  = p.bold ( num ..group ..class ..'優勝' )

	else
		return p.error( '入力された表示タイプに設定がありません' )
	end

	return p.outbox( L_cell, C_cell, R_cell, title )
end

-- 外枠
function p.outbox( L_cell, C_cell, R_cell, title )
	-- NavTable
	local table = '<table style="width: 80%; margin: 0px auto; border: 1px solid #aaa; text-align: center; background: #fff; font-size: 95%; clear:both;">'
		..'<tr><td colspan="3" style="background: #ccf;">' ..title ..'<div style="float: right; text-align: right; font-size: 80%;">[[Template:スポーツ前次王座|[表示]]]</div></td></tr>'
		..'<tr style="background: #ddf; font-weight: bold;">'
		..'<td>前</td><td>在位期間</td><td>後</td>'
		..'</tr>'

		-- under cell
		..'<tr>'
		..'<td style="width:30%;">' ..L_cell ..'</td>'
		..'<td style="border-left: #ccc 1px solid; border-right: #ccc 1px solid; width:20%;">' ..C_cell ..'</td>'
		..'<td style="width:30%;">' ..R_cell ..'</td>'
		..'</tr></table>'
	return table
end

return p