mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-26 00:07:42 +01:00
New feature: get pairings from round objects
This commit is contained in:
parent
c52e731361
commit
f56455f4e5
@ -9,6 +9,8 @@
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Game;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
class Round
|
||||
{
|
||||
@ -21,6 +23,9 @@ class Round
|
||||
/** @var int */
|
||||
private $roundNo;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $pairings = [];
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*
|
||||
@ -69,4 +74,21 @@ class Round
|
||||
{
|
||||
$this->roundNo = $roundNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $pairings
|
||||
*/
|
||||
public function setPairings(array $pairings): void
|
||||
{
|
||||
$this->pairings = $pairings;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
||||
use JeroenED\Libpairtwo\Game;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
class Round extends RoundModel
|
||||
{
|
||||
@ -23,4 +25,16 @@ class Round extends RoundModel
|
||||
$newarray[] = $game;
|
||||
$this->setGames($newarray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a pairing to the round
|
||||
*
|
||||
* @param Pairing $pairing
|
||||
*/
|
||||
public function addPairing(Pairing $pairing)
|
||||
{
|
||||
$newarray = $this->getPairings();
|
||||
$newarray[] = $pairing;
|
||||
$this->setPairings($newarray);
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ class Tournament extends TournamentModel
|
||||
$pairing->getPlayer()->addPairing($pairing);
|
||||
$round = $pairing->getRound();
|
||||
$color = $pairing->getColor();
|
||||
|
||||
$this->getRoundByNo($round)->addPairing($pairing);
|
||||
$opponent = null;
|
||||
foreach ($cache as $key=>$cached) {
|
||||
if (!is_null($cached)) {
|
||||
|
Loading…
Reference in New Issue
Block a user