cup-tool
v1.3.4
Published
Outcomes, tiebreakers and other useful tools when working with FIFA and UEFA cups and torunaments
Downloads
4
Readme
Cup Tool
Cup Tool makes it easy to calculate groups, outcomes and tiebreakers of tournaments like the UEFA Euros och FIFA World Cup.
Getting Started
Start by initializing a cup.
const cup = cupTools();
Feed it some matches:
cup.matches = [
{
id: "a1",
homeTeamId: "turkey",
awayTeamId: "italy",
group: "A",
},
...
];
Set outcomes of those matches:
cup.setOutcome("a1", {
homeScoreFT: 0,
awayScoreFT: 3,
});
Now you can look at the resulting groups given those outcomes.
console.log(cup.groups.A);
[
{
teamId: "italy",
pld: 3,
w: 3,
d: 0,
l: 0,
gf: 7,
ga: 1,
gd: 6,
pts: 9,
},
...
]
Knockout stage
You can add the knockout matches with qualification criteria in the following format.
"1-A" // Winner group A
"2-A" // Runner-up group A
"1-39" // Winner KO match 39
"2-39" // Loser KO match 39
Always provide a number
for knockout stage matches. Full match example:
cup.matches = [
{
id: "zb3s1",
homeTeamQualify: "1-A",
awayTeamQualify: "2-E",
number: 39,
},
...
{
id: "zb3s1",
homeTeamQualify: "1-39",
awayTeamQualify: "1-40",
number: 56,
},
...
];
After setting the outcomes, figure out which team qualified for a specific position like so:
cup.qualified("2-E")
In this case, it will return the id
for the runnerup of group E.
UEFA Euros
For UEFA Euros, the best thirds of each group also proceed to KO. You need to specify which Euro ruleset to use in order for it to know what teams to match up in the KO stage. Right now, euro2016
, euro2020
, euro2024
, olympics2024women
and olympics2020women
are available.
const cup = cupTools("euro2024");
Then when the outcomes are set, you can figure out which third qualified like so:
cup.qualified("3-ADEF")