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

スポーツなどにおける順位表を作成するためのモジュール「モジュール:Sports table」のうち、一般的な「勝利/引分/敗戦」で表すのに用いるスタイルサブモジュールです。

なお、一部「英語版で実装されていて、日本語版に実装されていないオプション」がありますので、英語版の翻訳の際には注意が必要です。

使い方 編集

基本的な書式 編集

基本的なコマンドは{{#invoke:Sports table|main|style=WDL}}で、これにいくつかのオプションを追記して表を作成します。チーム名には当該モジュール内でのみ通用する、アルファベット3文字程度の略称を設定する必要があります。勝ち点と得失点差は自動計算されます(勝ち点に制御を加えることも可能。後述)。

最低限必要なオプション
オプション 内容
|team1=|team2=、… 戦績表における表示順(=順位)
|name_TTT= 「TTT」に定義されるチームの名前
|win_TTT= 「TTT」で定義されるチームの勝利数
|draw_TTT= 「TTT」で定義されるチームの引き分け数
|lose_TTT= 「TTT」で定義されるチームの敗戦数
|gf_TTT= 「TTT」で定義されるチームの総得点
|ga_TTT= 「TTT」で定義されるチームの総失点
作成例
{{#invoke:Sports table|main|style=WDL

|team1=JPN |team2=BBB |team3=CCC |team4=DDD |team5=EEE

|win_JPN=5             |loss_JPN=0 |gf_JPN=10 |ga_JPN=0
|win_BBB=3 |draw_BBB=1 |loss_BBB=1 |gf_BBB= 3 |ga_BBB=2
|win_CCC=3             |loss_CCC=2 |gf_CCC= 3 |ga_CCC=3
|win_DDD=1 |draw_DDD=1 |loss_DDD=3 |gf_DDD= 1 |ga_DDD=4
|win_EEE=0             |loss_EEE=5 |gf_EEE= 0 |ga_EEE=6

|name_JPN={{fbu|23|JPN}}
|name_BBB=Team 2
|name_CCC=Team 3
|name_DDD=Team 4
|name_EEE={{fb|GIB}}
}}
表示例
チーム
1  日本 5 5 0 0 10 0 +10 15
2 Team 2 5 3 1 1 3 2 +1 10
3 Team 3 5 3 0 2 3 3 0 9
4 Team 4 5 1 1 3 1 4 −3 4
5  ジブラルタル 5 0 0 5 0 6 −6 0
最終更新は不明日の試合終了時. 出典: [要出典]

結果とステータス 編集

対戦に対する結果を表示させるときには以下のオプションを追加します。チーム名同様、資格等に対する略称を設定する必要があります。

結果表示に必要なオプション
オプション 内容
|result1=|result2=、… 順位に対応する資格
|res_col_header= 結果列の見出し。
Q='出場権', QR='出場権または降格', P='昇格', PQR='昇格、出場権または降格', PR='昇格または降格', R='降格' のいずれかを選択
|col_RRR= 「RRR」で定義される資格に対する背景色
|text_RRR= 「RRR」で定義される資格の説明文
作成例
{{#invoke:Sports table|main|style=WDL

| team1 = AAA | team2 = BBB | team3 = CCC | team4 = DDD | team5 = EEE 
| result1 = WC | result2 = PO | result3 = PO | result4 = RPO | result5 = rel 

| name_AAA = Team A 
| name_BBB = Team B 
| name_CCC = Team C 
| name_DDD = Team D 
| name_EEE = Team E 

| res_col_header = QR 
| col_WC = green1 | text_WC = [[ワールドカップ]]への予選
| col_PO = blue1 | text_PO =プレーオフの資格
| col_RPO = red2 | text_RPO =降格のプレーオフの資格
| col_rel = red1 | text_rel =下位部門への降格
}}
表示例
チーム 出場権または降格
1 Team A 0 0 0 0 0 0 0 0 ワールドカップへの予選
2 Team B 0 0 0 0 0 0 0 0 プレーオフの資格
3 Team C 0 0 0 0 0 0 0 0
4 Team D 0 0 0 0 0 0 0 0 降格のプレーオフの資格
5 Team E 0 0 0 0 0 0 0 0 下位部門への降格
最終更新は不明日の試合終了時. 出典: [要出典]

なお、背景色には以下の種類が用意されています。

色に関するオプション
green1 green2 green3 green4
blue1 blue2 blue3 blue4
yellow1 yellow2 yellow3 yellow4
red1 red2 red3 red4
black1 black2 black3 black4
オレンジ orange1 orange2 white1

チーム名表記に以下のステータス表記(アルファベット1文字)を追記することができます。|status_TTT=で指定します。

標準で設定されているステータスは以下のとおりです。

A='上位ラウンド進出', C='優勝', D='失格', E='敗退', G='招待', H='開催地', O='プレーオフ勝者', P='昇格', Q='出場権獲得', R='降格', T='出場権獲得だが、出場ラウンドは未確定'

また、任意のステータスを設定することができます(X, Y, Zを使用)

作成例
{{#invoke:Sports table|main|style=WDL
|status_pos=after

|team1=AAA 
|result1=RRR

|status_AAA=ACHXYZ

|name_AAA=Team A

|res_col_header=PQR
|col_RRR= |text_RRR=任意のテキスト

|status_text_X=任意ステータス1
|status_text_Y=任意ステータス2
|status_text_Z=任意ステータス3
}}
表示例
チーム 昇格、出場権または降格
1 Team A (A, C, H, X, Y, Z) 0 0 0 0 0 0 0 0 任意のテキスト
最終更新は不明日の試合終了時. 出典: [要出典]
(A) 上位ラウンド進出; (C) 優勝; (H) 開催地; (X) 任意ステータス1; (Y) 任意ステータス2; (Z) 任意ステータス3.

その他のオプション 編集

ヘッダー部のオプション
オプション 内容
|show_groups=yes これを指定すると「グループ」の列を表示する。各チームのグループは「|group_TTT=」で設定。
|postitle= 順位部の見出し表記(デフォルトで「順」。abbrタグを使用)
|team_header= チーム名部の見出し表記(デフォルトで「チーム」)
|teamwidth= チーム名の幅(数字で指定。デフォルトで190)
|team_order=TTT, SSS,… |teamN=」の替わりに順位を1行で表す
|loss_before_draw=true これを設定すると、「引分」の列が「敗戦」の列の後ろに来る。
|draw_header= 「引分」の列のヘッダー表示を差し替える。(引分以外の要素を表す際に使用。abbrタグを使用)
|for_against_style= 「引分」列を引分数以外の表記に使う場合に用いる。
  • goals - 得点
  • point - ポイント
|use_goal_ratio=yes これを設定すると、ゴール比率(得点÷失点)の列を表示する。
|use_goal_percentage=yes これを設定すると、ゴール比率(得点÷失点)の列を表示する。(パーセント表示)
メイン部のオプション
オプション 内容
|winpoints= 勝利時の勝点を設定する。(デフォルトで3)
|drawpoints= 引分時の勝点を設定する。(デフォルトで1)
|losspoints= 敗戦時の勝点を設定する。(デフォルトで0、減点の設定も可能)
|splitN=yes これを設定すると、Nチーム目の行の下を太線にして表が分かれているように見せる。(Nは数字に置き換えて使用)
|splitN+1=を設定しないとその下の行すべてが太線になるので注意。
|pos_TTT= 「TTT」で定義されたチームの順位表記を変更する場合(上位と同率の場合など)に順位を入力する。
|adjust_points_TTT
|startpoints_TTT
「TTT」で定義されたチームに対して勝ち点の補正を行う(勝敗で算出された勝ち点に対する「補正値」を入力)。
|hth_TTT 「TTT」で定義されたチームに対して勝ち点についての脚注を設定する。
|hth_TTT=SSS」とした場合は、「|hth_SSS」で設定した脚注を共通使用する。
|showteam=TTT 「TTT」で定義されたチームを強調表示させる(太字表記)。
|show_limit= showteamで指定されたチームを中心として表示させるチーム数を数字で指定。
(例えば |show_limit=5と指定すれば、全体で6チーム以上あっても5チーム分(当該チーム+上2チーム+下2チーム)だけの順位表を表示)
フッタ部のオプション
オプション 内容
|class_rules= 順位決定方法を脚注として追記

-- Style for football tables
local pp = {}

function pp.header(t,Args,p_sub,pos_label,group_col,VTE_text,full_table,results_header_txt)
	-- Load relevant modules
	local yesno = require('Module:Yesno')
	
	-- Create table header
	-- Pre stuff
	local team_width = Args['teamwidth'] or '190'
	local sort_text = ''
	local sort_table_val = Args['sortable_table'] 	or 'no'
	if yesno(sort_table_val) then sort_text = 'sortable' end
	table.insert(t,'{|class="wikitable '..sort_text..'" style="text-align:center;"\n')            			-- Open table
	
	-- Custom header options
	local pos_head_text = Args['postitle'] or '<abbr title="順位">順</abbr>'
	local draw_head_text = Args['draw_header'] or '<abbr title="引分数">分</abbr>'
	local team_head_text = Args['team_header'] or 'チーム'
	local loss_first = Args['loss_before_draw'] or false
	-- Use points instead of goals for/against
	local for_against_style = Args['for_against_style'] 	or 'goals'
	local fa_letter, fa_word_sing, fa_word_plur
	-- First convert to lower case if it is a string
	for_against_style = string.lower(for_against_style)
	if for_against_style=='g' or for_against_style=='goal' or for_against_style=='goals' then
		fa_letter = '得'
		fa_word_sing = '得'
		fa_word_plur = '点'
	elseif for_against_style=='p' or for_against_style=='point' or for_against_style=='points' then
		fa_letter = 'ポ'
		fa_word_sing = 'ポイント'
		fa_word_plur = 'ポイント'
	else
		fa_letter = '得'
		fa_word_sing = '得'
		fa_word_plur = '点'
	end
	-- Whether to use goal ratio (goal average) instead
	local use_ratio_val = Args['use_goal_ratio'] 	or 'no'
	local do_ratio = false
	-- True if exist, false otherwise
	if yesno(use_ratio_val) then do_ratio = true end
	
	-- Whether to use goal percentage instead
	local use_percentage_val = Args['use_goal_percentage'] 	or 'no'
	local do_percentage = false
	-- True if exist, false otherwise
	if yesno(use_percentage_val) then do_percentage = true end
	
	-- Initialize
	local tt = {}
	tt.count = 0 		-- Up by one after every call
	tt.tab_text = t		-- Actual text
	-- Actual headers
	tt = p_sub.colhead(tt,16,pos_head_text)							-- Position col
	-- Add group header
	if full_table and group_col then
		tt = p_sub.colhead(tt,16,'<abbr title="グループ">グ</abbr>')			-- Group col
	end
	tt = p_sub.colhead(tt,team_width,team_head_text..VTE_text)						-- Team col
	tt = p_sub.colhead(tt,16,'<abbr title="試合数">試</abbr>')				-- Matches played col
	if full_table then
		tt = p_sub.colhead(tt,16,'<abbr title="勝利数">勝</abbr>')				-- Win col
		if loss_first then
			tt = p_sub.colhead(tt,16,'<abbr title="敗戦数">敗</abbr>')				-- Loss col
			tt = p_sub.colhead(tt,16,draw_head_text)							-- Draw col
		else
			tt = p_sub.colhead(tt,16,draw_head_text)							-- Draw col
			tt = p_sub.colhead(tt,16,'<abbr title="敗戦数">敗</abbr>')				-- Loss col
		end
		tt = p_sub.colhead(tt,16,'<abbr title="得点数">得</abbr>')		-- For col
		tt = p_sub.colhead(tt,16,'<abbr title="失点数">失</abbr>')	-- Against col
		if do_ratio then
			tt = p_sub.colhead(tt,16,'<abbr title="得点率">'..fa_letter..'率</abbr>')	-- Ratio col
		elseif do_percentage then
			tt = p_sub.colhead(tt,16,'<abbr title="得点割合">%</abbr>')	-- Percentage col
		else
			tt = p_sub.colhead(tt,16,'<abbr title="得失点差">差</abbr>')	-- Difference col
		end
	end
	tt = p_sub.colhead(tt,16,'<abbr title="勝点">点</abbr>')				-- Points col
	if full_table then
		tt.count = tt.count+1
		table.insert(tt.tab_text,results_header_txt)
	end
	
	return tt
end

function pp.row(frame,t,Args,p_sub,notes_exist,hth_id_list,full_table,rand_val,team_list,team_code_ii,ii_start,ii_end,ii_fw,bg_col,N_teams,ii,ii_show)
	-- Build the inner parts of individual rows
	
	-- Sub-module usage
	local mm = require('Module:Math')
	local yesno = require('Module:Yesno')
	
	-- Get custom/default options for in table
	local win_points = tonumber(Args['winpoints'])				or 3
	local draw_points = tonumber(Args['drawpoints'])			or 1
	local loss_points = tonumber(Args['losspoints'])			or 0
	
	-- Order of draws and losses --
	local loss_first = Args['loss_before_draw']                 or false	
	
	-- Get some input
	local wins = tonumber(Args['win_'..team_code_ii])			or 0
	local draws = tonumber(Args['draw_'..team_code_ii]) 		or 0
	local losses = tonumber(Args['loss_'..team_code_ii])		or 0
	local gfor = tonumber(Args['gf_'..team_code_ii]) or	tonumber(Args['pf_'..team_code_ii]) or 0
	local gaig = tonumber(Args['ga_'..team_code_ii]) or	tonumber(Args['pa_'..team_code_ii]) or 0
	local s_pts = tonumber(Args['adjust_points_'..team_code_ii]) or tonumber(Args['startpoints_'..team_code_ii]) or 0
	local hth_local = Args['hth_'..team_code_ii]				or nil
	-- Then calculate some values
	local matches = wins + draws + losses
	local points = win_points*wins + draw_points*draws + loss_points*losses + s_pts
	
	-- Comparison of for against
	local gcomp
	-- Whether to use goal ratio (goal average) or goal percentage instead
	local use_ratio_val = Args['use_goal_ratio'] 	or 'no'
	local use_percentage_val = Args['use_goal_percentage'] 	or 'no'
	local skip_sign
	if yesno(use_ratio_val) then
		-- Now it is the goal ratio/goal average
		if gaig == 0 then
			gcomp = '&mdash;'
		else
			gcomp = mm._precision_format(gfor / gaig, 3)
		end
	elseif yesno(use_percentage_val) then
		-- Now it is the percentage
		if gaig == 0 then
			gcomp = '&mdash;'
		else
			gcomp = mm._precision_format(100 * gfor / gaig , 1)
		end
	else
		-- It's goal difference
		gcomp = gfor - gaig
		-- Formatting with signs
		if gcomp>0 then
			gcomp='+'..gcomp
		elseif gcomp < 0 then
			gcomp='&minus;'..-gcomp
		end
	end
	
	-- Some local vars	
	local hth_string
	local tt_return = p_sub.hth(frame,Args,full_table,hth_id_list,hth_local,notes_exist,team_list,team_code_ii,ii_start,ii_end,rand_val)
	hth_string = tt_return.str
	hth_id_list = tt_return.list
	notes_exist = tt_return.notes_exist
	
	-- Row building
	table.insert(t,'| style="'..ii_fw..bg_col..'" |'..matches..'\n') 		-- Played
	if full_table then
		table.insert(t,'| style="'..ii_fw..bg_col..'" |'..wins..'\n') 		-- Won
		
		if loss_first then
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n') 	-- Lost
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..draws..'\n') 		-- Drawn
		else
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..draws..'\n') 		-- Drawn
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n') 	-- Lost
		end
		
		table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gfor..'\n') 		-- GF
		table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gaig..'\n')		-- GA
		table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gcomp..'\n')      -- Goal comparison
	end
	-- Add &minus; for negative point totals
	table.insert(t,'| style="font-weight: bold;'..bg_col..'" | ')
	if points<0 then
		table.insert(t,'&minus;'..-points..hth_string)
	else
		table.insert(t,points..hth_string)
	end
	table.insert(t,'\n')
	
	return {t=t, notes_exist=notes_exist, hth_id_list=hth_id_list}
end

function pp.status(Args)
	-- Declare status options
	-- ------------------------------------------------------------
	-- NOTE: If you add to status_code, also add to status_called and status_letters!!
	-- Or functionality will be compromised
	-- ------------------------------------------------------------
	local status_code, status_called = {}
	status_code = {	A='上位ラウンド進出', C='優勝', D='失格', 
		E='敗退', G='招待', H='開催地', O='プレーオフ勝者', P='昇格', Q='出場権獲得',
		R='降格', T='出場権獲得だが、出場ラウンドは未確定',
		X='?', Y='?', Z='?'}
	status_called = {	A=false, C=false, D=false, E=false, G=false, H=false, O=false, P=false,
		Q=false, R=false, T=false, X=false, Y=false, Z=false}
	local status_letters = 'ACDEGHOPQRTXYZ'
	
	-- Status position (before or after read and default)
	local stat_pos_val = Args['status_pos'] or ''
	local status_position = 'after' 	-- Default location
	stat_pos_val = string.lower(stat_pos_val)
	if stat_pos_val=='before' then
		status_position = 'before'
	elseif stat_pos_val=='after' then
		status_position = 'after'
	end
	
	-- Read in custom status options
	if Args['status_text_X'] then status_code.X = Args['status_text_X'] end
	if Args['status_text_Y'] then status_code.Y = Args['status_text_Y'] end
	if Args['status_text_Z'] then status_code.Z = Args['status_text_Z'] end
	
	return {code=status_code, called=status_called, letters=status_letters, position=status_position}
end

return pp