diff --git a/src/Models/Round.php b/src/Models/Round.php index 8cc7b54..b0994c5 100644 --- a/src/Models/Round.php +++ b/src/Models/Round.php @@ -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; + } + } diff --git a/src/Round.php b/src/Round.php index f897394..14e8845 100644 --- a/src/Round.php +++ b/src/Round.php @@ -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); + } } diff --git a/src/Tournament.php b/src/Tournament.php index 99deb1a..e8d794b 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -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)) {