Tournament Generator

Generator implements WithGeneratorSetters, WithSkipSetters Uses WithSkipSetters

Generator class is responsible for generating all different games in rounds.

Tags
author

Tomáš Vojík vojik@wboy.cz

since
0.3

Interfaces, Classes and Traits

WithGeneratorSetters
Interface for objects that can generate games
WithSkipSetters
Interface that allows for setting skipping of not-playable games

Table of Contents

$allowSkip  : bool
$group  : Group
$inGame  : int
$maxSize  : int
$type  : string
__construct()  : mixed
Generator constructor.
allowSkip()  : $this
Allows round skipping
circle_genGames2()  : array<string|int, Game>
Generate games for round robin and 2 teams in one game
circle_rotateBracket()  : array<string|int, mixed>
Rotate array of teams
circle_saveBracket()  : array<string|int, Game>
Get one generated round-robin round
disallowSkip()  : $this
Disallow round skipping
genGames()  : array<string|int, Game>
Generate games for a round
getInGame()  : int
Get how many teams are playing in one game
getMaxSize()  : int
Get tha maximum group size
getSkip()  : bool
Getter for round skipping
getType()  : string
Get round type
orderGames()  : array<string|int, mixed>
Sort games to minimize teams playing multiple games after one other
setInGame()  : $this
Set how many teams are playing in one game
setMaxSize()  : $this
Set the maximum group size
setSkip()  : $this
Set round skipping
setType()  : $this
Set round type
cond_splitGames()  : Generator
Automatically split teams in a group
fillGamesFromChunks()  : void
Add games from chunks to groups
r_r3Games()  : array<string|int, mixed>
Generate a round-robin for three teams in one game
r_r4Games()  : array<string|int, mixed>
Generate a round-robin for four teams in one game
r_rGames()  : array<string|int, Game>
Generate round-robin games
saveTwoTwoGames()  : array<string|int, mixed>
Create games from array of teams for a Two-Two game
two_twoGames()  : Generator
Generates games for teams, where a team plays only against one other team

Properties

$type

private string $type = TournamentGeneratorConstants::ROUND_ROBIN

Methods

__construct()

Generator constructor.

public __construct(Group $group) : mixed
Parameters
$group : Group

Group object to generate the games from

Return values
mixed

allowSkip()

Allows round skipping

public allowSkip() : $this
Return values
$this

circle_genGames2()

Generate games for round robin and 2 teams in one game

public static circle_genGames2(Group $group[, array<string|int, mixed> $teams = [] ]) : array<string|int, Game>
Parameters
$group : Group
$teams : array<string|int, mixed> = []
Tags
throws
Exception
Return values
array<string|int, Game>

circle_rotateBracket()

Rotate array of teams

public static circle_rotateBracket(array<string|int, mixed> $teams) : array<string|int, mixed>
Parameters
$teams : array<string|int, mixed>
Return values
array<string|int, mixed>

circle_saveBracket()

Get one generated round-robin round

public static circle_saveBracket(array<string|int, mixed> $teams, Group $group) : array<string|int, Game>
Parameters
$teams : array<string|int, mixed>
$group : Group
Tags
throws
Exception
Return values
array<string|int, Game>

disallowSkip()

Disallow round skipping

public disallowSkip() : $this
Return values
$this

genGames()

Generate games for a round

public genGames() : array<string|int, Game>
Tags
throws
Exception
Return values
array<string|int, Game>

List of generated games

getInGame()

Get how many teams are playing in one game

public getInGame() : int
Return values
int

getMaxSize()

Get tha maximum group size

public getMaxSize() : int
Return values
int

getSkip()

Getter for round skipping

public getSkip() : bool
Return values
bool

getType()

Get round type

public getType() : string
Return values
string

orderGames()

Sort games to minimize teams playing multiple games after one other

public orderGames() : array<string|int, mixed>
Tags
pre

The autoincrement must be reset on the group's container

post

All games will have reset ids in the new order

throws
Exception
Return values
array<string|int, mixed>

setInGame()

Set how many teams are playing in one game

public setInGame(int $inGame) : $this
Parameters
$inGame : int
Tags
throws
Exception
Return values
$this

setMaxSize()

Set the maximum group size

public setMaxSize(int $size) : $this
Parameters
$size : int
Tags
throws
Exception
Return values
$this

setSkip()

Set round skipping

public setSkip(bool $skip) : $this
Parameters
$skip : bool
Return values
$this

setType()

Set round type

public setType([string $type = Constants::ROUND_ROBIN ]) : $this
Parameters
$type : string = Constants::ROUND_ROBIN
Tags
throws
Exception
Return values
$this

cond_splitGames()

Automatically split teams in a group

protected cond_splitGames([array<string|int, mixed> $teams = [] ]) : Generator
Parameters
$teams : array<string|int, mixed> = []
Tags
throws
Exception
Return values
Generator

fillGamesFromChunks()

Add games from chunks to groups

protected fillGamesFromChunks(array<string|int, array<string|int, Game>> $games) : void

Fills game in alternating order (chunk 1 - 1, chunk 2 - 1 , chunk 3 - 1, chunk 1 - 2, chunk 2 - 2...)

Parameters
$games : array<string|int, array<string|int, Game>>
Tags
throws
Exception
Return values
void

r_r3Games()

Generate a round-robin for three teams in one game

protected r_r3Games(array<string|int, mixed> $teams, array<string|int, mixed> &$games[, Team|null $lockedTeam1 = null ]) : array<string|int, mixed>
Parameters
$teams : array<string|int, mixed>
$games : array<string|int, mixed>
$lockedTeam1 : Team|null = null
Tags
throws
Exception
Return values
array<string|int, mixed>

r_r4Games()

Generate a round-robin for four teams in one game

protected r_r4Games(array<string|int, mixed> $teams, array<string|int, mixed> &$games) : array<string|int, mixed>
Parameters
$teams : array<string|int, mixed>
$games : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

r_rGames()

Generate round-robin games

protected r_rGames([array<string|int, mixed> $teams = [] ]) : array<string|int, Game>
Parameters
$teams : array<string|int, mixed> = []
Tags
throws
Exception
Return values
array<string|int, Game>

saveTwoTwoGames()

Create games from array of teams for a Two-Two game

protected saveTwoTwoGames(array<string|int, Team$teams) : array<string|int, mixed>
Parameters
$teams : array<string|int, Team>
Tags
pre

The input array must be divisible by the Generator::$inGame value

throws
Exception
Return values
array<string|int, mixed>

two_twoGames()

Generates games for teams, where a team plays only against one other team

protected two_twoGames([array<string|int, mixed> $teams = [] ]) : Generator
Parameters
$teams : array<string|int, mixed> = []
Tags
throws
Exception
Return values
Generator

Search results