1.3.1 • Published 2 months ago

cup-tool v1.3.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

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 and euro2024 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")
1.3.1

2 months ago

1.3.0

2 months ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.12

2 years ago

1.1.13

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.11

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago