mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-24 23:37:41 +01:00
Created function Round::getGamesbyBoard
This commit is contained in:
parent
5314bc47f2
commit
575b786079
@ -117,6 +117,33 @@ class Round
|
||||
return $absentPairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns an array with the games of this round sorted by board
|
||||
*
|
||||
* @return Game[]
|
||||
*/
|
||||
public function getGamesByBoard(): array
|
||||
{
|
||||
$allGames = $this->getGames();
|
||||
usort($allGames, array($this, 'sortByBoard'));
|
||||
return $allGames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by board
|
||||
*
|
||||
* @param Game $a
|
||||
* @param Game $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortByBoard(Game $a, Game $b): int
|
||||
{
|
||||
if (($a->getBoard() == $b->getBoard()) || ($a->getBoard() === false) || ($b->getBoard() === false)) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->getBoard() > $b->getBoard()) ? +1 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the round
|
||||
*
|
||||
@ -191,7 +218,7 @@ class Round
|
||||
{
|
||||
return $this->Pairings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets an array of all pairings for the round
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user