Module:Sports table/Chess

MyWikiBiz, Author Your Legacy — Tuesday December 03, 2024
< Module:Sports table
Revision as of 07:20, 16 July 2021 by Zoran (talk | contribs) (Pywikibot 6.4.0)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Template:Module rating

This style for Lua-based Module:Sports table is meant to build group and league tables for chess round-robin competitions with a crosstable. Unlike the WDL style, in this style wins and total points are calculated from match data that is provided. Therefore, if you want to use this style without a crosstable, you still need to provide all of the information that would appear in a crosstable, so you might want to explore other options, such as the WDL style. This documentation explains how to use this module with the Chess style in an article or template; check the table of contents for specific items.

Usage

Basic usage

In its simplest form only several parameters need to be used to build a table.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The main command is the {{#invoke:Sports table|main|style=Chess}} statement which calls the module with the Chess style and enables you to set everything up. Then you list the positions of the teams as Template:Para, Template:Para, etc for however many teams you need in the table. You can use full team names there without spaces as the team codes if you want, but using short codes (as in the example) can make it easier. For each team, you now define the Template:Para parameters (with TTT replaced by the team code) which determine what name is shown in the table; you can use wiki markup and templates in here as well, as shown in the example. The points and wins will default to 0 if no match data is provided. See #Points to see how to provide this data. See #Footer options and #Dating to see how to change the source and update date.

Points

Points are calculated using match data.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The match data that is used to calculate points is given by Template:Para where XXX and YYY are different team codes. This parameter takes a value of W+B, where W is the result as white and B is the result as black. The results use the character 1 for a win, ½ for a draw, and 0 for a loss. Note that incomplete information such as ½+ is allowed, and still calculates correctly. As a default, a win is worth 1 point, a draw 0.5 points and a loss 0 points, these values can be overwritten to what you need by Template:Para, Template:Para and Template:Para, if such parameters are provided. Head-to-head values are not calculated automatically, and are given by the parameter Template:Para. The parameter Template:Para determines whether the calculated points and head-to-head values (if any are given) are displayed as fractions or decimals. Note that this parameter should only be set to yes if Template:Para, Template:Para and Template:Para are a multiple of Template:Frac. Otherwise, an incorrect fraction will be displayed.

Crosstable

Because the match data already needs to be provided for use with this style, very little additional data is needed to create the crosstables.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The Template:Para parameter determines whether the crosstable is shown, and defaults to no. In the crosstable, the values given by Template:Para are shown. The headers for the columns are given by Template:Para. If no value for Template:Para is given, then one is created automatically from the team code, with appropriate wikilinks and {{flagathlete}} data included. It is recommended to set the value of Template:Para using the {{Abbr}} template with a short abbreviation (possibly the player's initials) to appear in header of the columns of the crosstable.

Customizing the crosstable

There are a few parameters that can be used to customize crosstables.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.
What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

As shown in this example, no parameter is needed to determine the number of games per match. This is calculated automatically from the largest number of plus signs in the match data. In the previous example, when no Template:Para parameter was given for a team whose Template:Para contained a {{flagathlete}} template, a short column header was created containing the appropriate flag. However, when Template:Para is set to "noflag", then no flag is displayed in the automatically created header. If instead Template:Para is set to "nocountry", then no country code is displayed in the automatically created header as well as no flag. Column headers explicitly defined by Template:Para are not affected by Template:Para. If the parameter Template:Para is set to yes, then draws in the crosstable will be displayed as Template:Frac instead of using the unicode character ½. While the games in a match typically show the white background first, and the black background second, this behavior can be changed using the Template:Para parameter. When no Template:Para data is present, the background alternates between white and black for each successive game. If the Template:Para parameter is set to no, then no cells in the crosstable will be colored black, even if there is Template:Para data present. The Template:Para parameter determines the color of the cells of the crosstable's main diagonal. Currently, Template:Para may take on the values "gray", "grey", "lightgray", "lightgrey", or "silver", as well as "#xxx" or "#xxxxxx" where the x indicates a valid hexadecimal digit. If no value or an invalid value is given, then the entries on the main diagonal will display an Em dash in a cell with the table background color.

Customizing columns

Several columns can be customized in these tables.

Altering default columns

You may choose not to display some of the default columns.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The column for the number of games played can be hidden with the Template:Para parameter. Whether or not that column is hidden, score can be displayed as score / games played by using the Template:Para parameter. This parameter should be set to yes only when Template:Para is set to yes, in order to avoid duplicated information. To hide the H2H and Wins columns, just set Template:Para and Template:Para, respectively, to no. Similar behavior may be obtained by using the Template:Para parameter to only show the games played and score columns to the right of the player name. For more information on Template:Para, or on the Template:Para parameter used in this table, see #Appearance. The leftmost column, which specifies the position of each player, may be hidden using the Template:Para parameter. The Template:Para parameter may be used to give the player column a custom header, instead of the default value of Player seen in other examples on this page.

Wins, Draws, and Losses

For backwards compatibility with the WDL style, it is possible to choose whether to display the Wins, Draws, and Losses columns.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

We saw the Template:Para parameter in the previous example, but there are also Template:Para and Template:Para parameters, which similarly determine whether the Draws and Losses columns, respectively, will be shown. The default value of Template:Para is yes, while the default values of Template:Para and Template:Para are no. As seen in previous tables, the H2H column usually appears before the Wins column. If you wish the H2H column to show up immediately after whichever of the Wins, Draws, and Losses columns are present, you may set the Template:Para parameter to no. If the parameter Template:Para is set to yes, then any wins, draws, or losses will only be displayed if head to head data has been defined for a given player.

Sonneborn-Berger score

In addition to other automatic calculations done by this module, there is also the possibility to calculate the Sonneborn-Berger score.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The Template:Para parameter shows a column containing the Sonneborn–Berger score of each player calculated from their match results. The Sonneborn–Berger score is calculated by taking the number of points gained against a given opponent multiplied by the total number of points that opponent scored, and then summing this product over all of the players. This column always comes after both the H2H column as well as whichever of the Wins, Draws, and Losses columns are present, and the values are always given as decimals regardless of Template:Para. If the parameter Template:Para is set to yes, then a calculated Sonneborn–Berger score will only be displayed if head to head data has been defined for a given player. Additionally, you may set the Template:Para parameter to yes for any given player with team code XXX in order to prevent that particular player's Sonneborn–Berger score from being displayed.

Other additional columns

The data for this table comes from the 3rd Sinquefield Cup, which was a single round-robin event held in 2015.

What you type <syntaxhighlight lang=moin><templatestyles src="Module:Sports table/styles.css"></templatestyles>
3rd Sinquefield Cup, 22 August – 3 September 2015, St. Louis, Missouri, United States
Rank Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Rating
Aug. 2015Template:Refn
Score Wins H2H SB Template:Abbr Tour Points Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr
1 Template:Flagathlete 2765 6 3 25.25 2923 13 ½ 1 ½ ½ ½ ½ 1 ½ 1
2 Template:Flagathlete 2853 5 3 <templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 21.25 2831 10 ½ ½ 1 ½ 0 0 1 ½ 1
3 Template:Flagathlete 2814 5 3 <templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 20.25 2835 8 0 ½ ½ ½ 1 0 ½ 1 1
4 Template:Flagathlete 2731 5 2 21.25 2845 7 ½ 0 ½ ½ ½ 1 ½ ½ 1
5 Template:Flagathlete 2793 5 1 22.25 2838 6 ½ ½ ½ ½ 1 ½ ½ ½ ½
6 Template:Flagathlete 2771 4<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 3 19.75 2797 5 ½ 1 0 ½ 0 ½ 1 1 0
7 Template:Flagathlete 2816 4<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 2 21 2792 4 ½ 1 1 0 ½ ½ 0 ½ ½
8 Template:Flagathlete 2808 3<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 1 15.25 2713 3 0 0 ½ ½ ½ 0 1 ½ ½
9 Template:Flagathlete 2816 3<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 0 16 2712 2 ½ ½ 0 ½ ½ 0 ½ ½ ½
10 Template:Flagathlete 2779 3 1 12.75 2671 1 0 0 0 0 ½ 1 ½ ½ ½
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Sinquefield Cup 2015". Retrieved 9 April 2020.
Rules for classification: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Tie Break Regulations Grand Chess Tour". Retrieved 9 April 2020.
</syntaxhighlight>
What it looks like <templatestyles src="Module:Sports table/styles.css"></templatestyles>
3rd Sinquefield Cup, 22 August – 3 September 2015, St. Louis, Missouri, United States
Rank Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Rating
Aug. 2015Template:Refn
Score Wins H2H SB Template:Abbr Tour Points Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr Template:Abbr
1 Template:Flagathlete 2765 6 3 25.25 2923 13 ½ 1 ½ ½ ½ ½ 1 ½ 1
2 Template:Flagathlete 2853 5 3 <templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 21.25 2831 10 ½ ½ 1 ½ 0 0 1 ½ 1
3 Template:Flagathlete 2814 5 3 <templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 20.25 2835 8 0 ½ ½ ½ 1 0 ½ 1 1
4 Template:Flagathlete 2731 5 2 21.25 2845 7 ½ 0 ½ ½ ½ 1 ½ ½ 1
5 Template:Flagathlete 2793 5 1 22.25 2838 6 ½ ½ ½ ½ 1 ½ ½ ½ ½
6 Template:Flagathlete 2771 4<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 3 19.75 2797 5 ½ 1 0 ½ 0 ½ 1 1 0
7 Template:Flagathlete 2816 4<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 2 21 2792 4 ½ 1 1 0 ½ ½ 0 ½ ½
8 Template:Flagathlete 2808 3<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 1 15.25 2713 3 0 0 ½ ½ ½ 0 1 ½ ½
9 Template:Flagathlete 2816 3<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 0 16 2712 2 ½ ½ 0 ½ ½ 0 ½ ½ ½
10 Template:Flagathlete 2779 3 1 12.75 2671 1 0 0 0 0 ½ 1 ½ ½ ½
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Sinquefield Cup 2015". Retrieved 9 April 2020.
Rules for classification: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Tie Break Regulations Grand Chess Tour". Retrieved 9 April 2020.

If the Template:Para parameter is set to yes, then a column is shown immediately after the player names with values defined by Template:Para for each team code XXX. Similarly, if the Template:Para parameter is set to some number N, then N columns are shown just before the crosstable, if one is present, with values defined by Template:Para for each column N and each team code XXX. The header of any extra column may be set using Template:Para for each N. The header of the rating column also includes some information that may be chosen by a parameter. The contents of the Template:Para parameter will be displayed in small text below the word "Rating" in the header. Note that it is possible to include the {{refn}} template inside any of these custom headers. Because all other notes in this module use the "lower-alpha" group, it is recommended that any use of {{refn}} in a parameter in this module also use the "lower-alpha" group. If any notes are generated by the module, then a {{reflist|group=lower-alpha}} template will also be generated at the end of the module. However, if no notes are generated by the module, then you will have to call this yourself as shown at the end of the example. There is no detriment to calling this twice, so it is a good idea to include this template yourself whenever you call {{refn}} in a parameter. For more information on notes in this module, see #Notes. For information on using Template:Para instead of Template:Para see #Matchrow. For information on Template:Para, Template:Para, and Template:Para used in this table, see #Footer options.

Special case for only two players

When there are only two players, the module enters a special case. The data for the following table comes from the 2014 World Chess Championship.

What you type <syntaxhighlight lang=moin><templatestyles src="Module:Sports table/styles.css"></templatestyles>
World Chess Championship 2014
Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Score Game 1
8 Nov.
Game 2
9 Nov.
Game 3
11 Nov.
Game 4
12 Nov.
Game 5
14 Nov.
Game 6
15 Nov.
Game 7
17 Nov.
Game 8
18 Nov.
Game 9
20 Nov.
Game 10
21 Nov.
Game 11
23 Nov.
Game 12
25 Nov.
Template:Flagathlete 6<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 ½ 1 0 ½ ½ 1 ½ ½ ½ ½ 1
Template:Flagathlete 4<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 ½ 0 1 ½ ½ 0 ½ ½ ½ ½ 0
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Anand vs Carlsen, 2014". Retrieved 9 April 2020.
</syntaxhighlight>
What it looks like <templatestyles src="Module:Sports table/styles.css"></templatestyles>
World Chess Championship 2014
Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Score Game 1
8 Nov.
Game 2
9 Nov.
Game 3
11 Nov.
Game 4
12 Nov.
Game 5
14 Nov.
Game 6
15 Nov.
Game 7
17 Nov.
Game 8
18 Nov.
Game 9
20 Nov.
Game 10
21 Nov.
Game 11
23 Nov.
Game 12
25 Nov.
Template:Flagathlete 6<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 ½ 1 0 ½ ½ 1 ½ ½ ½ ½ 1
Template:Flagathlete 4<templatestyles src="Screen reader-only/styles.css"></templatestyles> 12 ½ 0 1 ½ ½ 0 ½ ½ ½ ½ 0
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Anand vs Carlsen, 2014". Retrieved 9 April 2020.

As can be seen from this example, the crosstable now displays a column header for each game in the match, instead of the normally displayed column header for each player. As such, there is no longer a main diagonal of NULL matches. Also, if Template:Para were defined, its value would never be used. Instead, headers in the match table are determined by the Template:Para parameter for each number N corresponding to a game. The default value for this parameter is the number specified by N. It is highly recommended to use Template:Para in two player tables, so that each column can represent a distinct game, in the order that they are played. It is also recommended that the H2H, Wins, and played columns be hidden in a two player table, because this information is easily discerned from the points. For information on the Template:Para and Template:Para parameters used in this table, see #Footer options.

Matchrow

There are occasions in which it may be preferable to enter all match data corresponding to one row using one parameter.

What you type <syntaxhighlight lang=moin>Lua error: expandTemplate: template "citation needed" does not exist.</syntaxhighlight>
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

Using the Template:Para parameter, only one parameter is needed for the match data per row, rather than a number of parameters equal to the number of players per row. Note that Template:Para data is comma separated, with each value between commas equal to the previously discussed Template:Para data, with the addition of data for the main diagonal. This value for the main diagonal is a dummy value which is never used and only exists to line matches up so that parameter inputs are easier to read. The dummy value is needed even for the two player special case, when no main diagonal is displayed in the crosstable. For this reason, it is advised that Template:Para not be used in competitions with only 2 players. Additionally, if you use Template:Para, then all match data needs to be changed each time you change the rank of any player. With Template:Para, no data needs to be changed when re-ordering players. For this reason, it is advised that Template:Para only be used in already completed tournaments, where there is no possibility of changing the order of players. The parameter Template:Para works similarly to Template:Para in that the data is comma separated, except that each value between commas equal to the previously discussed Template:Para data.

Tiebreak matches

In many tournaments, if there is a tiebreak between the top players, additional tiebreak games are played. This module is able to handle these tiebreak games. The data for the following table comes from the 2018 World Chess Championship.

What you type <syntaxhighlight lang=moin><templatestyles src="Module:Sports table/styles.css"></templatestyles>
World Chess Championship 2018
Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Score Rapid 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
Template:Flagathlete 6 3 ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ 1 1 1
Template:Flagathlete 6 0 ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ 0 0 0
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"World Chess Championship 2018: Carlsen vs Caruana". Retrieved 9 April 2020.
Rules for classification: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"RULES & REGULATIONS FOR THE FIDE WORLD CHAMPIONSHIP MATCH" (PDF). Retrieved 9 April 2020.
</syntaxhighlight>
What it looks like <templatestyles src="Module:Sports table/styles.css"></templatestyles>
World Chess Championship 2018
Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Score Rapid 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
Template:Flagathlete 6 3 ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ 1 1 1
Template:Flagathlete 6 0 ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ ½ 0 0 0
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"World Chess Championship 2018: Carlsen vs Caruana". Retrieved 9 April 2020.
Rules for classification: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"RULES & REGULATIONS FOR THE FIDE WORLD CHAMPIONSHIP MATCH" (PDF). Retrieved 9 April 2020.

The data for the following table comes from the Tata Steel Chess India Blitz tournament in 2018.

What you type <syntaxhighlight lang=moin><templatestyles src="Module:Sports table/styles.css"></templatestyles>
Rank Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Score H2H SB Playoff VA HN LA WS SM PH VSG SK SSG PR 1 2
1 Template:Flagathlete 12.5 1.5 ½ ½ 0 ½ 1 ½ ½ 1 1 ½ 1 1 ½ 0 1 1 1 1 1 ½
2 Template:Flagathlete 12.5 0.5 ½ ½ ½ ½ 1 ½ 1 1 1 0 ½ 1 ½ 1 1 1 ½ ½ 0 ½
3 Template:Flagathlete 12 ½ 1 ½ ½ ½ ½ 1 ½ 1 0 ½ 1 1 ½ ½ ½ 1 1
4 Template:Flagathlete 10 ½ 0 ½ 0 ½ ½ 1 1 1 0 ½ ½ ½ 1 1 0 ½ 1
5 Template:Flagathlete 8 3 0 ½ 0 0 ½ 0 0 0 ½ ½ 1 1 ½ ½ 0 1 1 1
6 Template:Flagathlete 8 1.5 70.75 ½ 0 1 0 1 0 1 0 ½ ½ 0 ½ 0 ½ 1 0 1 ½
7 Template:Flagathlete 8 1.5 62.75 0 0 0 ½ 0 ½ ½ ½ 0 0 ½ 1 ½ 1 ½ 1 ½ 1
8 Template:Flagathlete 7.5 1 ½ 0 ½ ½ 0 0 ½ ½ ½ ½ 1 0 ½ ½ 0 0 1
9 Template:Flagathlete 6 0 0 0 0 ½ ½ 1 0 0 1 1 0 0 ½ 1 ½ 0 0
10 Template:Flagathlete 5.5 0 0 ½ ½ 0 0 0 ½ 0 0 ½ 0 0 ½ 0 1 1 1
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Tata Steel India Chess 2018_Blitz". Retrieved 9 April 2020.
Rules for classification: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Tata Steel India Chess 2018_Blitz". Retrieved 9 April 2020.
</syntaxhighlight>
What it looks like <templatestyles src="Module:Sports table/styles.css"></templatestyles>
Rank Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Score H2H SB Playoff VA HN LA WS SM PH VSG SK SSG PR 1 2
1 Template:Flagathlete 12.5 1.5 ½ ½ 0 ½ 1 ½ ½ 1 1 ½ 1 1 ½ 0 1 1 1 1 1 ½
2 Template:Flagathlete 12.5 0.5 ½ ½ ½ ½ 1 ½ 1 1 1 0 ½ 1 ½ 1 1 1 ½ ½ 0 ½
3 Template:Flagathlete 12 ½ 1 ½ ½ ½ ½ 1 ½ 1 0 ½ 1 1 ½ ½ ½ 1 1
4 Template:Flagathlete 10 ½ 0 ½ 0 ½ ½ 1 1 1 0 ½ ½ ½ 1 1 0 ½ 1
5 Template:Flagathlete 8 3 0 ½ 0 0 ½ 0 0 0 ½ ½ 1 1 ½ ½ 0 1 1 1
6 Template:Flagathlete 8 1.5 70.75 ½ 0 1 0 1 0 1 0 ½ ½ 0 ½ 0 ½ 1 0 1 ½
7 Template:Flagathlete 8 1.5 62.75 0 0 0 ½ 0 ½ ½ ½ 0 0 ½ 1 ½ 1 ½ 1 ½ 1
8 Template:Flagathlete 7.5 1 ½ 0 ½ ½ 0 0 ½ ½ ½ ½ 1 0 ½ ½ 0 0 1
9 Template:Flagathlete 6 0 0 0 0 ½ ½ 1 0 0 1 1 0 0 ½ 1 ½ 0 0
10 Template:Flagathlete 5.5 0 0 ½ ½ 0 0 0 ½ 0 0 ½ 0 0 ½ 0 1 1 1
Source: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Tata Steel India Chess 2018_Blitz". Retrieved 9 April 2020.
Rules for classification: <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>"Tata Steel India Chess 2018_Blitz". Retrieved 9 April 2020.

If Template:Para is a number greater than 1, then a second crosstable will be displayed which may be used for tiebreak match data. The Template:Para parameter determines how many players are involved in the tiebreak matches. Note that tiebreak matches only apply to the players at the top of the table. For tiebreak match data, the parameters Template:Para, Template:Para, Template:Para, and Template:Para are used in place of Template:Para, Template:Para, Template:Para, and Template:Para, respectively. The second crosstable is then displayed following the same rules as the first crosstable. Note that no information on wins or points is automatically calculated from tiebreak match data. For information on the Template:Para, Template:Para, and Template:Para parameters used in these tables, see #Footer options.

Generic Customization

There are many customization options that are available regardless of which style is used in Module:Sports table. These are presented below.

Footer options

What you type
{{#invoke:Sports table|main|style=Chess
|update=1 January 1900
|source=[https://en.wikipedia.org/wiki/Main_Page Wikipedia]

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

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

|class_rules=1) points; 2) goal difference; 3) number of goals scored.
}}
What it looks like <templatestyles src="Module:Sports table/styles.css"></templatestyles>
Pos Player<templatestyles src="Module:Navbar/styles.css"></templatestyles> Pld Score H2H Wins
1 Team A 0 0 0
2 Team B 0 0 0
3 Team C 0 0 0
4 Team D 0 0 0
5 Team E 0 0 0
Updated to match(es) played on 1 January 1900. Source: Wikipedia
Rules for classification: 1) points; 2) goal difference; 3) number of goals scored.

The footer information can be customized (although notes and status will be inserted automatically if they are called; see XXX and YYY). The update date is set by Template:Para, see below for details. If no source is given a citation-needed tag is shown, Template:Para can provide an actual link. The classification results can be shown with Template:Para, either directly or as a wikilink to a tie-breaker rules section. Using Template:Para suppresses the classification rules (this should only be used in template calls when multiple groups are summarized on a page and the rules are listed elsewhere on that page).

Dating

The default description is match(es), this can be changed by calling Template:Para for any other term.

Active season
What you type
{{#invoke:Sports table|main|style=Chess
|update=1 January 1900
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

When the season is active, the footer should include the date of the last match played that is included in the table. This can be achieved by setting Template:Para.

Completed season
What you type
{{#invoke:Sports table|main|style=Chess
|update=complete
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

When all matches have been played, the season is completed and the update line can be removed by setting Template:Para.

Future season
What you type
{{#invoke:Sports table|main|style=Chess
|update=future |start_date=1 January 2121
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

Before any games are played, the date of the first game should be indicated by using Template:Para and setting the start date by Template:Para.

Stacking

Using Template:Para makes the table smaller, which may lead to undesired width and linebreaks in the footer that can be fixed with parameter Template:Para. By setting Template:Para (or y, t, true or 1 or upper case variant of those) every new information, such as "source" and statuses, is displayed on a new row.

Without stack_footer
What you type
{{#invoke:Sports table|main|style=Chess
|only_pld_pts=yes 

|team1=AAA |name_AAA=The A Team
|result1=RRR

|status_AAA=DEOPRT

|res_col_header=PQR
|col_RRR= |text_RRR=Plain text
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.
With stack_footer
What you type
{{#invoke:Sports table|main|style=Chess
|only_pld_pts=yes 
|stack_footer=yes 

|team1=AAA |name_AAA=The A Team
|result1=RRR

|status_AAA=DEOPRT

|res_col_header=PQR
|col_RRR= |text_RRR=Plain text
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

Appearance

What you type
{{#invoke:Sports table|main|style=Chess

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

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

|only_pld_pts=yes
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.
What you type
{{#invoke:Sports table|main|style=Chess

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

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

|split2=yes
|split3=
|split5=1
|teamwidth=250
|postitle={{abbr|Exam.|Example}}
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.
What you type
{{#invoke:Sports table|main|style=Chess

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

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

|show_groups=yes
|group_AAA=A
|group_BBB=A
|group_CCC=B
|group_DDD=B
|group_EEE=C
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

Only the position, team, matches and points columns can be displayed by defining Template:Para (or y, t, true or 1 or upper case variant of those); Template:Para suppresses the classification rules only (this should only be used in template calls when multiple groups are summarized on a page and the rules are listed elsewhere on that page).

A line can be added between section of the table (if desired) by adding Template:Para with N the position below which the bar should be shown. (Note that this bar will not be shown for the bottom position in the table).

A custom width of the team column can be set by Template:Para, for example when multiple groups exist within one tournament and you want to force the same width on all groups.

The position column header can be customized by Template:Para and the position labels by Template:Para for each team.

When multiple a table compares teams from multiple groups, the group can also be listed by setting Template:Para (or y, t, true or 1 or upper case variant of those) and using Template:Para to indicate what teams comes from what group. The group column header can be customized by Template:Para, for example Template:Para.

Team highlighting and partial table

What you type
{{#invoke:Sports table|main|style=Chess
|showteam=DDD

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

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

|show_limit=3
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

When using a table on a team (season) page, you might want to highlight the team (and possibly only show part of the table), especially after a template call to a long league table. Team TTT is highlighted by Template:Para. A limited part of the table is shown by Template:Para, with the number indicating the number of position to show (if this is an even number, and it is in the middle of the table, then this number will be rounded up to the next odd number to show symmetry above and below).

A table can also start at position N, by using Template:Para in the module call.

Results and status

Indicating results

What you type
{{#invoke:Sports table|main|style=Chess

|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=Qualification to [[World Cup]]
|col_PO=blue1  |text_PO=Qualification to play-offs
|col_RPO=red2  |text_RPO=Qualification to relegation play-offs
|col_rel=red1  |text_rel=Relegation to lower division
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The result of the table rankings can be indicated by a coloured bar and text indicating the result. The header of this column is defined by Template:Para with predefined values of Q, QR, P, PQR, PR and R (indicating various combinations of promotion, qualification and relegation), any other entry than these exact codes will print as that entry in the column header. With N the position Template:Para declares the codes (or words if you want that instead) for the results column. Now when RRR is the results column, the colours are defined by Template:Para. The colours green1, green2, green3, green4, blue1, blue2, blue3, blue4, yellow1, yellow2, yellow3, yellow4, red1, red2, red3, red4, black1, black2, black3 and black4 are predefined and should be used preferentially per consensus on WT:FOOTY (you can use either html colours, or RGB colour codes instead if you must [this is not recommended though, because it might violate WP:COLOR]). The text in the results column is now give by Template:Para, which can (and should) link to the relevant competition articles.

Consensus is also to use the colours in the following way: Green should be used for the top-level positive event (promotion, qualification, advancing to next round), blue for the second-level positive events (promotion play-offs when direct promotion exists, play-offs when direct qualification exist, secondary continental tournament), red for bottom-level negative events (relegation) and yellow for other level events. In addition, lower level colours should be used when teams qualify for different rounds (with lower levels corresponding to entry in lower rounds [green1 first, then green2, etc].) Black should be used when teams do not play a full season and their results are expunged or void. This consensus exists to have a uniform table appearance across Wikipedia. In addition, some wikiprojects have more detailed guidelines:

Colour options
Green green1 green2 green3 green4
Blue blue1 blue2 blue3 blue4
Yellow yellow1 yellow2 yellow3 yellow4
Red red1 red2 red3 red4
Black black1 black2 black3 black4
Orange orange1 orange2 White white1

Indicating status

What you type
{{#invoke:Sports table|main|style=Chess
|status_pos=after

|team1=AAA 
|result1=RRR

|status_AAA=ABCDEFGHIJKLMNOPQRSTUVWXYZ

|name_AAA=Team A

|res_col_header=PQR
|col_RRR= |text_RRR=Plain text

|status_text_X=Custom 1
|status_text_Y=Custom 2
|status_text_Z=Custom 3
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.
What you type
{{#invoke:Sports table|main|style=Chess
|status_pos=before

|team1=AAA 

|status_AAA=ABCDEFGHIJKLMNOPQRSTUVWXYZ

|name_AAA=Team A

|status_text_X=Custom 1
|status_text_Y=Custom 2
|status_text_Z=Custom 3
}}
What it looks like Lua error: expandTemplate: template "citation needed" does not exist.

The promotion/qualification/relegation status of a team can be indicated by Template:Para with the letters indicated above (although only the ones in use for this style are shown below the table). The letters will appear next to the team in the order given. Whichever letters are called out in the table will automatically be explained alphabetically in the footer.

These letters can be used for all scenarios as exemplified by the following group phase example with 4 teams that play 3 matches where the first advances directly, the second team will go to play-offs and the remaining two teams are eliminated:

  • Teams start out without status letter
  • Teams that get eliminated get status (E)
  • Teams that can still finish worse than second (and might be eliminated) will remain without status
  • Teams that will finish at least second will get status (T)
  • Teams that will finish for sure second will get status (Q)
  • Teams that will finish for sure first will get status (A)

If these scenarios are not sufficient, some style have wild letters L (marked with a question mark in the overview). They should be accompanied by Template:Para to indicate a non-standard status.

Most styles allow for these letter to be placed after the team name or before, set Template:Para or Template:Para respectively, the default value can differ and its use differs between sports or regions.

Notes

What you type
{{#invoke:Sports table|main|style=Chess

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

|note_AAA=Team note
|note_BBB=AAA |hth_BBB=Team 2 wins head-to-head against team 3
              |hth_CCC=BBB
|note_DDD=EEE

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

|res_col_header=QR |note_header_res=Header note
|col_WC=green1 |text_WC=Qualification to [[World Cup]] |note_res_WC=Result note
|col_PO=blue1  |text_PO=Qualification to play-offs
|col_RPO=red2  |text_RPO=Qualification to relegation play-offs   |note_res_RPO=WC
|col_rel=red1  |text_rel=Relegation to lower division
}}
What it looks like Lua error: expandTemplate: template "efn" does not exist.

When notes are present, they are automatically added to the footer. The following notes are available for teams with Template:Para for a note for a team, when this note is a team code with a defined notes, they will share the note. Results can have notes with Template:Para and the result header can have a note with Template:Para. Head-to-head result tiebreakers are listed in the points column and can be inserted with Template:Para, which can be shared between teams as with all-purpose notes.

Matches

What you type
{{#invoke:Sports table|main|style=Chess
|show_matches=true
|team1=AAA |team2=BBB |team3=CCC |team4=DDD |team5=EEE

|name_AAA=Team A  |short_AAA=AAA
|name_BBB=Team B  |short_BBB=BBB
|name_CCC=Team C  |short_CCC=CCC
|name_DDD=Team D  |short_DDD=DDD
|name_EEE=Team E  |short_EEE=EEE

|match_AAA_BBB=1–0
|match_AAA_CCC=0–1
|match_AAA_DDD=<small>16 Nov '14</small>
|match_AAA_EEE=<small>3 Sep '15</small>

|match_BBB_AAA=
|match_BBB_CCC=<small>3 Sep '15</small>
|match_BBB_DDD=B–D
|match_BBB_EEE=<small>3 Sep '15</small>

|match_CCC_AAA=<small>16 Nov '14</small>
|match_CCC_BBB=C–B
|match_CCC_DDD=<small>16 Nov '14</small>
|match_CCC_EEE=C–E

|match_DDD_AAA=D–A
|match_DDD_BBB=<small>3 Sep '15</small>
|match_DDD_CCC=D–C
|match_DDD_EEE=<small>3 Sep '15</small>

|match_EEE_AAA=
|match_EEE_BBB=9–5
|match_EEE_CCC=<small>16 Nov '14</small>
|match_EEE_DDD=E–D |match_EEE_DDD_note=Pitch was taken by [[Martian|Martians]], the match will be played in [[Iani Chaos]] instead.
}}
What it looks like Lua error: expandTemplate: template "efn" does not exist.

The match list can be added by displayed by defining Template:Para (or y, t, true or 1 or upper case variant of those). The column headers for the match results are defined by Template:Para for team TTT. The results for the game TTT vs. SSS can now be input by Template:Para. Future games can be listed with their date (possibly between small tags) or they can be left blank. (Note that this calls Module:Sports results to build the match table.) A note can be added to a result using Template:Para, this note can be shared with team TTT note by setting Template:Para when Template:Para is set. The width of the match columns can be customized by setting Template:Para to the desired width.


Template:When pagename is Note that match notes do not show up properly at this time when the number of games per match is not 1.



-- Style for chess tables
local pp = {}

function pp.preprocess(Args,N_teams,prefix,drawfractions)
	local legs = 1
	for ii=1,N_teams do
		local ti = Args['team' .. ii]
		Args[prefix..'win_'..ti] = 0
		Args[prefix..'draw_'..ti] = 0
		Args[prefix..'loss_'..ti] = 0
		local matchrow_str = Args[prefix..'matchrow_' .. ti] or ''
		for jj=1,N_teams do
			local tj = Args['team' .. jj] 
			if ii ~= jj then
				if matchrow_str ~= '' then
					Args[prefix..'match_' .. ti .. '_' .. tj] = mw.ustring.match(matchrow_str, '^([^,]*),?')
				end
				local match_str = Args[prefix..'match_' .. ti .. '_' .. tj] or ''
				local game_count = 1
				while match_str ~= '' do
					local gii = mw.ustring.match(match_str, '^([^%+]*)%+?')
					gii = mw.ustring.gsub(gii or '','^%s*','')						-- Trim starting whitespace
					gii = mw.ustring.gsub(gii or '','%s*$','')						-- Trim ending whitespace
					if gii == '1' then
						Args[prefix..'win_'..ti] = Args[prefix..'win_'..ti] + 1
					elseif gii == '½' then
						Args[prefix..'draw_'..ti] = Args[prefix..'draw_'..ti] + 1
						if drawfractions then
							gii = mw.getCurrentFrame():extensionTag{
								name = 'templatestyles', args = { src = 'Screen reader-only/styles.css' }
							} .. '<span class="sr-only">&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
						end
					elseif gii == '0' then
						Args[prefix..'loss_'..ti] = Args[prefix..'loss_'..ti] + 1
					end
					Args[prefix..'match' .. game_count .. '_' .. ti .. '_' .. tj] = gii
					match_str = mw.ustring.gsub(match_str, '^([^%+]*)', '') or ''	-- Remove gii from the match_str
					if match_str ~= '' then											-- If there is still a plus sign
						game_count = game_count + 1									-- Then there is another game in the match
						match_str = mw.ustring.gsub(match_str, '^%+?', '') or ''	-- So remove the plus sign
					end																-- And continue
				end
				if game_count > legs then											-- If there are more games than expected
					legs = game_count												-- Change the number of games
				end
			end
			matchrow_str = mw.ustring.gsub(matchrow_str, '^([^,]*),?', '') or ''
		end
	end
	Args[prefix..'legs'] = legs														-- And finally change the Arg at the end
end

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 player_width = Args['playerwidth'] or '190'
	local sort_text = ''
	local sort_table_val = Args['sortable_table'] 	or 'no'
	if yesno(sort_table_val) then sort_text = ' sortable' end
	-- Open table
	table.insert(t,'{|class="wikitable'..sort_text..'" style="text-align:center;"\n')
	-- Table title
	if Args['title'] or Args['table_header'] then
		table.insert(t,'|+ ' .. (Args['title'] or Args['table_header']) .. '\n')
	end
	-- Preprocess match data
	local top_pos = tonumber(Args['highest_pos']) or 1
	local N_teams = top_pos - 1 -- Default to 0 at start, but higher number needed to skip certain entries
	while Args['team'..N_teams+1] ~= nil do N_teams = N_teams+1 end
	pp.preprocess(Args,N_teams,'',yesno(Args['crosstable_fractions'] or 'no'))
	local tb_numplayers = tonumber(Args['tb_numplayers']) or 0
	if tb_numplayers > N_teams then
		tb_numplayers = N_teams
		Args['tb_numplayers'] = N_teams
	end
	if tb_numplayers >= 2 then
		pp.preprocess(Args,tb_numplayers,'tb',yesno(Args['crosstable_fractions'] or 'no'))
	end
	-- Which columns to show
	local show_rating = yesno(Args['show_rating'] or 'no')
	local show_played = not yesno(Args['hide_played'] or 'no')
	local hth_first = yesno(Args['hth_before_w'] or 'yes')
	local show_hth = yesno(Args['show_hth'] or 'yes')
	local show_win = yesno(Args['show_win'] or 'yes')
	local show_draw = yesno(Args['show_draw'] or 'no')
	local show_loss = yesno(Args['show_loss'] or 'no')
	local show_sb = yesno(Args['show_sb'] or 'no')
	local extra_cols = tonumber(Args['extra_cols']) or 0
	-- Custom header options
	local group_head_text = Args['group_header'] or '<abbr title="Group">Grp</abbr>'
	local player_head_text = Args['player_header'] or 'Player'

	-- Initialize
	local tt = {}
	tt.count = 0 		-- Up by one after every call
	tt.tab_text = t		-- Actual text
	-- Actual headers
	if pos_label ~= nil then
		tt = p_sub.colhead(tt,28,pos_label)										-- Position col
	end
	-- Add group header
	if full_table and group_col then
		tt = p_sub.colhead(tt,28,group_head_text)								-- Group col
	end
	tt = p_sub.colhead(tt,player_width,player_head_text..VTE_text)				-- Player col
	if full_table and show_rating then
		local rate_date = Args['rate_date'] or ''
		tt = p_sub.colhead(tt,28, '[[FIDE world rankings|Rating]]<br/><small><span style="white-space:nowrap">'..rate_date..'</span></small>')
	end
	if show_played then
		tt = p_sub.colhead(tt,28, '<abbr title="Games Played">Pld</abbr>')		-- Games played col
	end
	tt = p_sub.colhead(tt,28, 'Score')											-- Score col
	if full_table then
		if show_hth and hth_first then
			tt = p_sub.colhead(tt,28, '<abbr title="Head-to-head">H2H</abbr>')	-- Head-to-head col
		end
		if show_win then
			tt = p_sub.colhead(tt,28, 'Wins')									-- Wins col
		end
		if show_draw then
			tt = p_sub.colhead(tt,28, 'Draws')									-- Draws col
		end
		if show_loss then
			tt = p_sub.colhead(tt,28, 'Losses')									-- Losses col
		end
		if show_hth and not hth_first then
			tt = p_sub.colhead(tt,28, '<abbr title="Head-to-head">H2H</abbr>')	-- Head-to-head col if not first tiebreak
		end
		if show_sb then
			tt = p_sub.colhead(tt,28, '<abbr title="Sonneborn–Berger score">[[Sonneborn-Berger score|SB]]</abbr>')
		end
		for ecol=1,extra_cols do
			local extra_head_text = Args['extra_header'..ecol] or ('Extra' .. ecol)
			tt = p_sub.colhead(tt,28,extra_head_text)
		end
		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 1
	local draw_points = tonumber(Args['drawpoints'])			or 0.5
	local loss_points = tonumber(Args['losspoints'])			or 0
	
	-- 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 hth_local = Args['hth_'..team_code_ii]				or ''
	local show_rating = yesno(Args['show_rating'] or 'no')
	local show_played = not yesno(Args['hide_played'] or 'no')
	local score_over_played = yesno(Args['score_over_played'] or 'no')
	local hth_first = yesno(Args['hth_before_w'] or 'yes')
	local show_hth = yesno(Args['show_hth'] or 'yes')
	local show_win = yesno(Args['show_win'] or 'yes')
	local show_draw = yesno(Args['show_draw'] or 'no')
	local show_loss = yesno(Args['show_loss'] or 'no')
	local wdl_iff_hth = yesno(Args['wdl_iff_hth'] or 'no')
	local show_sb = yesno(Args['show_sb'] or 'no')
	local nosb = yesno(Args['nosb_'..team_code_ii] or 'no')
	local sb_iff_hth = yesno(Args['sb_iff_hth'] or 'no')
	local extra_cols = tonumber(Args['extra_cols']) or 0
	local disp_fractions = yesno(Args['disp_fractions'] or 'yes')
	-- Then calculate some values
	local matches = wins + draws + losses
	local points = win_points*wins + draw_points*draws + loss_points*losses
	local sb_score = 0
	
	local templatestyles = mw.getCurrentFrame():extensionTag{
		name = 'templatestyles', args = { src = 'Screen reader-only/styles.css' }
	}
	hth_local = mw.ustring.gsub(hth_local, '%s*½', '.5')
	if hth_local == '' then
		hth_local = '&mdash;'
	elseif disp_fractions then
		hth_local = tonumber(hth_local) or 0
		if math.floor(hth_local) ~= hth_local then
			if math.floor(hth_local) > 0 then
				hth_local = math.floor(hth_local) .. templatestyles .. '<span class="sr-only">&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
			else
				hth_local = templatestyles .. '<span class="sr-only">&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
			end
		end
	end

	if score_over_played then
		points = '<span style="white-space:nowrap">' .. points .. ' / ' .. matches .. '</span>'
	elseif disp_fractions then
		if math.floor(points) ~= points then
			if math.floor(points) > 0 then
				points = math.floor(points) .. templatestyles .. '<span class="sr-only">&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
			else
				points = templatestyles .. '<span class="sr-only">&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
			end
		end
	end

	-- Sonneborn-Berger score
	if show_sb then
		if (sb_iff_hth and hth_local == '&mdash;') or nosb then
			sb_score = '&mdash;'
		end
		if sb_score == 0 then
			local legs = tonumber(Args['legs']) or 1
			for jj=1,N_teams do
				local tj = Args['team' .. jj]
				local tjpoints = win_points*Args['win_'..tj] + draw_points*Args['draw_'..tj] + loss_points*Args['loss_'..tj]
				if ii ~= jj then
					local match_str = Args['match_' .. team_code_ii .. '_' .. tj] or ''
					for l=1,legs do
						local gii = mw.ustring.match(match_str, '^%s*([^%+%s]*)%s*%+?')
						if gii == '1' then
							sb_score = sb_score + win_points*tjpoints
						elseif gii == '½' then
							sb_score = sb_score + draw_points*tjpoints
						elseif gii == '0' then
							sb_score = sb_score + loss_points*tjpoints
						end
						match_str = mw.ustring.gsub(match_str, '^%s*([^%+%s]*)%s*%+?', '') or ''
					end
				end
			end
		end
	end
	
	-- Some local vars	
	local hth_string
	local tt_return = p_sub.hth(frame,Args,full_table,hth_id_list,nil,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
	if full_table and show_rating then
		local rateii = Args['rating_'..team_code_ii] or ''
		table.insert(t,'| style="'..ii_fw..bg_col..'" |'..rateii..'\n')					-- Rating
	end
	if show_played then
		table.insert(t,'| style="'..ii_fw..bg_col..'" |'..matches..'\n')				-- Played
	end
	table.insert(t,'| style="font-weight: bold;'..bg_col..'" | '..points..'\n')			-- Points
	if full_table then
		if show_hth and hth_first then
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(hth_local or '')..'\n')	-- Head-to-head
		end
		if show_win then
			if wdl_iff_hth and hth_local == '&mdash;' then
				wins = '&mdash;'
			end
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..wins..'\n')				-- Won
		end
		if show_draw then
			if wdl_iff_hth and hth_local == '&mdash;' then
				draws = '&mdash;'
			end
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..draws..'\n')				-- Drew
		end
		if show_loss then
			if wdl_iff_hth and hth_local == '&mdash;' then
				losses = '&mdash;'
			end
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n')				-- Lost
		end
		if show_hth and not hth_first then
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(hth_local or '')..'\n')	-- Head-to-head if not first tiebreak
		end
		if show_sb then
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..sb_score..'\n')			-- Sonneborn-Berger
		end
		for ecol=1,extra_cols do
			local extraii = Args['extra'..ecol..'_'..team_code_ii] or ''
			table.insert(t,'| style="'..ii_fw..bg_col..'" |'..extraii..'\n')			-- Extra
		end
	end

	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='Advance to a further round', C='Champion', D='Disqualified', 
		E='Eliminated', G='Guest', H='Host', O='Play-off winner', P='Promoted', Q='Qualified to the phase indicated',
		R='Relegated', T='Qualified, but not yet to the particular phase indicated',
		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
	for l in mw.text.gsplit(status_letters, '') do
		if Args['status_text_' .. l] then
			status_code[l] = Args['status_text_' .. l]
		end
	 end
	
	return {code=status_code, called=status_called, letters=status_letters, position=status_position}
end

return pp