DocsAPITeam Free for All

Team Free for All

A TeamFreeForAll is between minTeams and maxTeams. calculate(teamIds) determines the winning order.

Example

import { Player, Team, TeamFreeForAll } from 'teslo'
 
const match = new TeamFreeForAll([
  new Team('1', [new Player('1', 1000), new Player('2', 900)]),
  new Team('2', [new Player('3', 800), new Player('4', 700)]),
  new Team('3', [new Player('5', 600), new Player('6', 500)])
])
 
const results = match.calculate(['1', '2', '3'])
 
/*
[
  {
    id: '1',
    players: [
      {
        id: '1',
        elo: 1004
      },
      {
        id: '2',
        elo: 906
      }
    ]
  },
  {
    id: '2',
    players: [
      {
        id: '3',
        elo: 798
      },
      {
        id: '4',
        elo: 701
      }
    ]
  },
  {
    id: '3',
    players: [
      {
        id: '5',
        elo: 593
      },
      {
        id: '6',
        elo: 496
      }
    ]
  }
]
*/

API

interface Options {
  kFactor?: number
  minTeams?: number
  maxTeams?: number
}
 
class TeamFreeForAll {
  constructor(teams?: Team[], options?: Options)
  static create(teams?: Team[], options?: Options): TeamFreeForAll
  get contestants(): Map<string, Team>
  get size(): number
  get completed(): boolean
  addTeam(team: Team): this
  addTeams(...teams: Team[]): this
  calculate(teamIds: string[]): TeamResult[]
  getResults(): TeamResult[]
}