Module:Sports games
| This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome. |
This module is similar to Module:Sports results, but the matches are arranged linearly by game number similar to Module:Sports rbr table/matchup.
Usage
{{#invoke:Sports games|table
| title = <!-- Optional title for the table -->
| team_order = AAA, BBB, CCC, DDD <!-- Abbreviated names for the teams in order -->
| name_AAA = <!-- Wikilinked name for team AAA --->
| name_BBB = <!-- Wikilinked name for team BBB --->
| name_CCC = <!-- Wikilinked name for team CCC --->
| name_CCC = <!-- Wikilinked name for team DDD --->
<!-- Week 1 -->
| m1_AAA_BBB = 100–90 <!-- Score for 1st week match between AAA vs. BBB -->
| m1_BBB_AAA = auto <!-- Auto key word flips the score from the first AAA vs. BBB match -->
| m1_CCC_DDD = 101–89 <!-- Score for 1st week match between CCC vs. DDD -->
| m1_DDD_CCC = auto <!-- Auto key word flips the score from the first CCC vs. DDD match -->
<!-- Week 2 -->
| m2_AAA_CCC = 99–96 <!-- Score for 2nd week match between AAA vs. CCC -->
| m2_CCC_AAA = auto <!-- Auto key word flips the score from the first AAA vs. CCC match -->
| m2_BBB_DDD = 120–111* <!-- Score for 2nd week match between BBB vs. DDD -->
| m2_DDD_BBB = auto <!-- Auto key word flips the score from the first BBB vs. DDD match -->
<!-- Week 3 -->
| m3_AAA_DDD = 89–90 <!-- Score for 3rd week match between AAA vs. DDD -->
| m3_DDD_AAA = auto <!-- Auto key word flips the score from the first AAA vs. DDD match -->
| m3_BBB_CCC = 103–101 <!-- Score for 3rd week match between BBB vs. CCC -->
| m3_CCC_BBB = auto <!-- Auto key word flips the score from the first BBB vs. CCC match -->
| source = <!-- <ref></ref> or [https://... link] to a source -->
}}
- An asterisk can be appended to indicate an overtime result.
- For events where teams only play each other once, the
autokeyword can be used to automatically fill in the score for the other team. - To override the default match column width, use
|match_col_width=with a width in pixels. - To override the default table font size, use
|font_size=with the size as a percentage (note that less than 85% is discouraged).
Example
{{#invoke:Sports games|table
| title = 2023–24 PBA Commissioner's Cup results table
| team_order = BGSM, BWB, CON, MAG, MER, NLEX, NP, PHX, ROS, SMB, TER, TNT
<!-- Barangay Ginebra -->
| name_BGSM = [[2023–24 Barangay Ginebra San Miguel season|Barangay Ginebra]]
| m1_BGSM_CON = 100–86
| m2_BGSM_MAG = [[Manila Clasico|91–93]]
| m3_BGSM_ROS = 107–102
| m4_BGSM_BWB = 90–87
| m5_BGSM_TER = 110–99
| m6_BGSM_PHX = 77–82
| m7_BGSM_SMB = 82–95
| m8_BGSM_MER = 110–96
| m9_BGSM_TNT = 86–78
| m10_BGSM_NP = 103–93
| m11_BGSM_NLEX = 103–99
<!-- Blackwater -->
| name_BWB = [[2023–24 Blackwater Bossing season|Blackwater]]
| m1_BWB_CON = 103–84
| m2_BWB_MER = 84–91
| m3_BWB_TER = 87–97
| m4_BWB_PHX = 106–111
| m5_BWB_BGSM = auto
| m6_BWB_ROS = 110–115
| m7_BWB_MAG = 84–105
| m8_BWB_TNT = 96–105
| m9_BWB_NLEX = 97–104
| m10_BWB_NP = 89–106
| m11_BWB_SMB = 117–125
<!-- Converge -->
| name_CON = [[2023–24 Converge FiberXers season|Converge]]
| m1_CON_BWB = auto
| m2_CON_TNT = 98–101*
| m3_CON_BGSM = auto
| m4_CON_SMB = 96–105
| m5_CON_PHX = 98–99
| m6_CON_NP = 95–111
| m7_CON_TER = 103–94*
| m8_CON_MER = 99–105
| m9_CON_MAG = 80–88
| m10_CON_NLEX = 103–107
| m11_CON_ROS = 111–112
<!-- Magnolia -->
| name_MAG = [[2023–24 Magnolia Hotshots season|Magnolia]]
| m1_MAG_TNT = 110–102
| m2_MAG_PHX = 107–92
| m3_MAG_NP = 112–74
| m4_MAG_BGSM = auto
| m5_MAG_NLEX = 99–72
| m6_MAG_BWB = 105–84
| m7_MAG_SMB = 94–90
| m8_MAG_ROS = 110–113
| m9_MAG_TER = 104–91
| m10_MAG_CON = 88–80
| m11_MAG_MER = 80–85
<!-- Meralco -->
| name_MER = [[2023–24 Meralco Bolts season|Meralco]]
| m1_MER_ROS = 107–102
| m2_MER_BWB = 91–84
| m3_MER_SMB = 83–93
| m4_MER_TNT = 109–95
| m5_MER_NLEX = 96–94
| m6_MER_NP = 125–99
| m7_MER_CON = 105–99
| m8_MER_BGSM = 96–110
| m9_MER_MAG = 85–80
| m10_MER_PHX = 83–93
| m11_MER_TER = 109–102
<!-- NLEX -->
| name_NLEX = [[2023–24 NLEX Road Warriors season|NLEX]]
| m1_NLEX_PHX = 101–113
| m2_NLEX_SMB = auto
| m3_NLEX_TER = 112–113
| m4_NLEX_NP = 112–104
| m5_NLEX_MAG = 72–99
| m6_NLEX_MER = 94–96
| m7_NLEX_ROS = 101–113
| m8_NLEX_TNT = 97–113
| m9_NLEX_BWB = 104–97
| m10_NLEX_CON = 107–103
| m11_NLEX_BGSM = 99–103
<!-- NorthPort -->
| name_NP = [[2023–24 NorthPort Batang Pier season|NorthPort]]
| m1_NP_TER = 108–103
| m2_NP_ROS = 113–103
| m3_NP_MAG = 74–112
| m4_NP_NLEX = 104–112
| m5_NP_TNT = 128–123*
| m6_NP_CON = 111–95
| m7_NP_SMB = 115–101
| m8_NP_MER = 99–125
| m9_NP_PHX = 104–113
| m10_NP_BWB = 106–89
| m11_NP_BGSM = 93–103
<!-- Phoenix Super LPG -->
| name_PHX = [[2023–24 Phoenix Super LPG Fuel Masters season|Phoenix Super LPG]]
| m1_PHX_NLEX = 113–101
| m2_PHX_MAG = 92–107
| m3_PHX_ROS = 99–98
| m4_PHX_BWB = 111–106
| m5_PHX_TER = 103–84
| m6_PHX_CON = 99–98
| m7_PHX_BGSM = 82–77
| m8_PHX_NP = 113–104
| m9_PHX_SMB = 96–117
| m10_PHX_MER = 93–83
| m11_PHX_TNT = 96–116
<!-- Rain or Shine -->
| name_ROS = [[2023–24 Rain or Shine Elasto Painters season|Rain or Shine]]
| m1_ROS_MER = auto
| m2_ROS_NP = 103–113
| m3_ROS_PHX = 98–99
| m4_ROS_BGSM = auto
| m5_ROS_SMB = 110–115
| m6_ROS_BWB = 115–110
| m7_ROS_NLEX = 113–101
| m8_ROS_MAG = 113–110
| m9_ROS_TER = 116–105
| m10_ROS_TNT = 119–112
| m11_ROS_CON = 112–111
<!-- San Miguel -->
| name_SMB = [[2023–24 San Miguel Beermen season|San Miguel]]
| m1_SMB_NLEX = 113–117*
| m2_SMB_MER = 93–83
| m3_SMB_CON = 105–96
| m4_SMB_ROS = 115–110
| m5_SMB_NP = 101–115
| m6_SMB_MAG = 90–94
| m7_SMB_BGSM = 95–82
| m8_SMB_TNT = 98–93
| m9_SMB_PHX = 117–96
| m10_SMB_TER = 132–110
| m11_SMB_BWB = 125–117
<!-- Terrafirma -->
| name_TER = [[2023–24 Terrafirma Dyip season|Terrafirma]]
| m1_TER_NP = auto
| m2_TER_BWB = 97–87
| m3_TER_NLEX = 113–112
| m4_TER_TNT = 93–133
| m5_TER_PHX = 84–103
| m6_TER_BGSM = 99–110
| m7_TER_CON = 94–103*
| m8_TER_MAG = 91–104
| m9_TER_ROS = 105–116
| m10_TER_SMB = 110–132
| m11_TER_MER = 102–109
<!-- TNT -->
| name_TNT = [[2023–24 TNT Tropang Giga season|TNT]]
| m1_TNT_MAG = auto
| m2_TNT_CON = 101–98*
| m3_TNT_TER = 133–93
| m4_TNT_MER = 95–109
| m5_TNT_NP = 123–128*
| m6_TNT_NLEX = 113–97
| m7_TNT_BWB = 105–96
| m8_TNT_SMB = 93–98
| m9_TNT_BGSM = 78–86
| m10_TNT_ROS = 112–119
| m11_TNT_PHX = 116–96
| source = [https://web.archive.org/web/20240115060813/https://www.pba.ph/recap PBA.ph results]
}}
| Team | Game | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
| Barangay Ginebra (BGSM) | CON 100–86 | MAG 91–93 | ROS 107–102 | BWB 90–87 | TER 110–99 | PHX 77–82 | SMB 82–95 | MER 110–96 | TNT 86–78 | NP 103–93 | NLEX 103–99 |
| Blackwater (BWB) | CON 103–84 | MER 84–91 | TER 87–97 | PHX 106–111 | BGSM 87–90 | ROS 110–115 | MAG 84–105 | TNT 96–105 | NLEX 97–104 | NP 89–106 | SMB 117–125 |
| Converge (CON) | BWB 84–103 | TNT 98–101* | BGSM 86–100 | SMB 96–105 | PHX 98–99 | NP 95–111 | TER 103–94* | MER 99–105 | MAG 80–88 | NLEX 103–107 | ROS 111–112 |
| Magnolia (MAG) | TNT 110–102 | PHX 107–92 | NP 112–74 | BGSM 93–91 | NLEX 99–72 | BWB 105–84 | SMB 94–90 | ROS 110–113 | TER 104–91 | CON 88–80 | MER 80–85 |
| Meralco (MER) | ROS 107–102 | BWB 91–84 | SMB 83–93 | TNT 109–95 | NLEX 96–94 | NP 125–99 | CON 105–99 | BGSM 96–110 | MAG 85–80 | PHX 83–93 | TER 109–102 |
| NLEX | PHX 101–113 | SMB 117–113* | TER 112–113 | NP 112–104 | MAG 72–99 | MER 94–96 | ROS 101–113 | TNT 97–113 | BWB 104–97 | CON 107–103 | BGSM 99–103 |
| NorthPort (NP) | TER 108–103 | ROS 113–103 | MAG 74–112 | NLEX 104–112 | TNT 128–123* | CON 111–95 | SMB 115–101 | MER 99–125 | PHX 104–113 | BWB 106–89 | BGSM 93–103 |
| Phoenix Super LPG (PHX) | NLEX 113–101 | MAG 92–107 | ROS 99–98 | BWB 111–106 | TER 103–84 | CON 99–98 | BGSM 82–77 | NP 113–104 | SMB 96–117 | MER 93–83 | TNT 96–116 |
| Rain or Shine (ROS) | MER 102–107 | NP 103–113 | PHX 98–99 | BGSM 102–107 | SMB 110–115 | BWB 115–110 | NLEX 113–101 | MAG 113–110 | TER 116–105 | TNT 119–112 | CON 112–111 |
| San Miguel (SMB) | NLEX 113–117* | MER 93–83 | CON 105–96 | ROS 115–110 | NP 101–115 | MAG 90–94 | BGSM 95–82 | TNT 98–93 | PHX 117–96 | TER 132–110 | BWB 125–117 |
| Terrafirma (TER) | NP 103–108 | BWB 97–87 | NLEX 113–112 | TNT 93–133 | PHX 84–103 | BGSM 99–110 | CON 94–103* | MAG 91–104 | ROS 105–116 | SMB 110–132 | MER 102–109 |
| TNT | MAG 102–110 | CON 101–98* | TER 133–93 | MER 95–109 | NP 123–128* | NLEX 113–97 | BWB 105–96 | SMB 93–98 | BGSM 78–86 | ROS 112–119 | PHX 116–96 |
Updated to match(es) played on unknown. Source: PBA.ph results
Legend: Blue = win; Red = loss; Matches with lighter background shading were decided after overtime. (*) Number of asterisks denotes number of overtime periods
Legend: Blue = win; Red = loss; Matches with lighter background shading were decided after overtime. (*) Number of asterisks denotes number of overtime periods
See also
-- Module to build Sports games table
-- See documentation for details
require('strict')
local p = {}
-- Helper functions
local function get_team_label(team_abbr, team_name)
if team_name == nil then
team_name = team_abbr
end
local team_text = team_name
if team_text:match('^%[%[[^%|%[%]]*%|([^%|%[%]]*)%]%]') then
team_text = team_text:match('^%[%[[^%|%[%]]*%|([^%|%[%]]*)%]%]')
end
if team_text:match('^%[%[([^%|%[%]]*)%]%]') then
team_text = team_text:match('^%[%[([^%|%[%]]*)%]%]')
end
local team_label = team_name
if team_text ~= team_abbr then
team_label = team_label .. '<br>(' .. team_abbr .. ')'
end
return team_label
end
local function get_score_background(s, c)
local s1, s2
-- Define the colouring
local wc, lc, tc
if c == 'level2' then
wc, lc, tc = '#CCF9FF', '#FCC', '#FFC' -- blue2, red2, yellow2
elseif c == 'level3' then
wc, lc, tc = '#DDFCFF', '#FDD', '#FFD' -- blue3, red3, yellow3
elseif c == 'level4' then
wc, lc, tc = '#EEFFFF', '#FEE', '#FFE' -- blue4, red4, yellow4
else
wc, lc, tc = '#BBF3FF', '#FBB', '#FFB' -- blue1, red1, yellow1
end
-- check for override
if s:match('^%s*<span%s+style%s*=["\'%s]*background[%-colr]*%s*:([^\'";<>]*).-$') then
local c = mw.ustring.gsub(s,'^%s*<span%s+style%s*=["\'%s]*background[%-colr]*%s*:([^\'";<>]*).-$', '%1')
return c
end
-- delink if necessary
if s:match('^%s*%[%[[^%[%]]*%|([^%[%]]*)%]%]') then
s = s:match('^%s*%[%[[^%[%]]*%|([^%[%]]*)%]%]')
end
if s:match('^%s*%[[^%[%]%s]*%s([^%[%]]*)%]') then
s = s:match('^%s*%[[^%[%]%s]*%s([^%[%]]*)%]')
end
if s:match('<span[^<>]*>(.-)</span>') then
s = s:match('<span[^<>]*>(.-)</span>')
end
-- get the scores
s1 = tonumber(mw.ustring.gsub( s or '',
'^%s*([%d%.]+)%s*–%s*([%d%.]+).*', '%1' ) or '') or ''
s2 = tonumber(mw.ustring.gsub( s or '',
'^%s*([%d%.]+)%s*–%s*([%d%.]+).*', '%2' ) or '') or ''
-- return colouring if possible
if s1 ~= '' and s2 ~= '' then
return (s1 > s2) and wc or ((s2 > s1) and lc or tc)
else
return 'transparent'
end
end
local function format_score(s)
s = mw.ustring.gsub(s or '', '^%s*([%d%.]+)%s*[–−—%-]%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*([%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*%-%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*%-%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')
return s
end
local function flip_score(s)
s = format_score(s)
s = mw.ustring.gsub(s, '([%d%.]+)–([%d%.]+)', '%2–%1')
return s
end
local function is_overtime(s)
if s:match('%d+–%d+[%s%]]*%*') then
return true
end
return false
end
-- Main function
function p.table(frame)
-- Get the args, stripping out blank values
local getArgs = require('Module:Arguments').getArgs
local Args = getArgs(frame, {parentFirst = true})
-- Exit early if we are using section transclusion for a different section
local tsection = frame:getParent().args['transcludesection'] or frame:getParent().args['section'] or ''
local bsection = frame.args['section'] or ''
if( tsection ~= '' and bsection ~= '' ) then
if( tsection ~= bsection ) then
return ''
end
end
if Args['team_order'] and Args['team_order'] ~= '' then
local tlist = mw.text.split(Args['team_order'], '%s*[;,]%s*')
for k, tname in ipairs(tlist) do
if tname ~= '' then
Args['team' .. k] = tname
end
end
end
-- Build team list
local team_list = {}
local other_team_table = {}
local k = 1
while Args['team' .. k] do
team_list[k] = Args['team' .. k]
other_team_table[Args['team' .. k]] = {}
k = k + 1
end
-- Store the results
local total_games = 0
for k,v in pairs(Args) do
if v and v ~= '' and k:match('^m%d+_[^_]+_[^_]+$') then
local g = k:match('^m(%d+)_[^_]+_[^_]+$')
local t1 = k:match('^m%d+_([^_]+)_[^_]+$')
local t2 = k:match('^m%d+_[^_]+_([^_]+)$')
if other_team_table[t1] then
other_team_table[t1][tonumber(g)] = t2
end
total_games = (tonumber(g) > total_games) and tonumber(g) or total_games
end
end
-- Start the div
local root = mw.html.create('div')
:css('overflow-x', 'auto')
:css('white-space', 'nowrap')
-- Start table
local t = root:tag('table')
:addClass('wikitable')
:addClass('plainrowheaders')
:css('text-align', 'center')
:css('font-size', Args['font_size'])
-- Table title
if Args['title'] and Args['title'] ~= '' then
t:tag('caption'):wikitext(Args['title'])
end
-- Header rows
local match_col_width = Args['match_col_width'] and (Args['match_col_width'] .. 'px') or nil
local row = t:tag('tr')
row:tag('th')
:attr('scope', 'col')
:attr('rowspan', 2)
:wikitext('Team')
row:tag('th')
:attr('scope', 'col')
:attr('colspan', total_games)
:wikitext('Game')
row = t:tag('tr')
for jj = 1,total_games do
row:tag('th')
:attr('scope', 'col')
:css('width', match_col_width)
:wikitext(jj)
end
-- Results rows
local ot_note = false
for ii=1,#team_list do
local team_abbr = team_list[ii]
local team_label = get_team_label(team_abbr, Args['name_' .. team_abbr])
row = t:tag('tr')
row:tag('th')
:attr('scope', 'row')
:css('background', 'inherit')
:css('color', 'inherit')
:wikitext(team_label)
for jj=1,total_games do
local other_team_abbr = other_team_table[team_abbr][jj] or ''
local result = ''
if other_team_abbr ~= '' then
result = Args['m' .. jj .. '_' .. team_abbr .. '_' .. other_team_abbr] or ''
if result == other_team_abbr or result == 'auto' then
for kk=1,total_games do
local other_result = Args['m' .. kk .. '_' .. other_team_abbr .. '_' .. team_abbr]
if other_result then
result = flip_score(other_result)
end
end
end
end
local ot_flag = is_overtime(result)
if (ot_flag) then
ot_note = true
end
local bg = get_score_background(result, ot_flag and 'level3' or 'level1')
if bg == 'transparent' then bg = bg .. ';color:inherit' end
if result ~= '' then
result = other_team_abbr .. '<br>' .. format_score(result)
end
row:tag('td')
:css('background', bg)
:wikitext(result)
end
end
-- footer
local t_footer = {}
local update = Args['update'] or 'unknown'
local start_date = Args['start_date'] or 'unknown'
local source = Args['source']
or frame:expandTemplate{ title = 'citation needed',
args = { reason='No source parameter defined', date=os.date('%B %Y') } }
-- Date updating
if string.lower(update)=='complete' then
-- Do nothing
elseif update=='' then
-- Empty parameter
table.insert(t_footer,'Updated to match(es) played on unknown. ')
elseif string.lower(update)=='future' then
-- Future start date
table.insert(t_footer,'First match(es) will be played: '..start_date..'. ')
else
table.insert(t_footer,'Updated to match(es) played on '..update..'. ')
end
table.insert(t_footer,'Source: '..source)
table.insert(t_footer, '<br />Legend: Blue = win; Red = loss')
if ot_note then
table.insert(t_footer, '; Matches with lighter background shading were decided after overtime.')
table.insert(t_footer, ' (*) Number of asterisks denotes number of overtime periods')
end
t_footer = mw.html.create('div')
:css('font-size', '90%')
:css('margin-bottom', '0.5em')
:wikitext(table.concat(t_footer))
return tostring(root) .. tostring(t_footer)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.