mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-01 18:51:32 +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;
|
namespace JeroenED\Libpairtwo\Models;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use JeroenED\Libpairtwo\Game;
|
||||||
|
use JeroenED\Libpairtwo\Pairing;
|
||||||
|
|
||||||
class Round
|
class Round
|
||||||
{
|
{
|
||||||
@ -21,6 +23,9 @@ class Round
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $roundNo;
|
private $roundNo;
|
||||||
|
|
||||||
|
/** @var Pairing[] */
|
||||||
|
private $pairings = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DateTime
|
* @return DateTime
|
||||||
*
|
*
|
||||||
@ -69,4 +74,21 @@ class Round
|
|||||||
{
|
{
|
||||||
$this->roundNo = $roundNo;
|
$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;
|
namespace JeroenED\Libpairtwo;
|
||||||
|
|
||||||
use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
||||||
|
use JeroenED\Libpairtwo\Game;
|
||||||
|
use JeroenED\Libpairtwo\Pairing;
|
||||||
|
|
||||||
class Round extends RoundModel
|
class Round extends RoundModel
|
||||||
{
|
{
|
||||||
@ -23,4 +25,16 @@ class Round extends RoundModel
|
|||||||
$newarray[] = $game;
|
$newarray[] = $game;
|
||||||
$this->setGames($newarray);
|
$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);
|
$pairing->getPlayer()->addPairing($pairing);
|
||||||
$round = $pairing->getRound();
|
$round = $pairing->getRound();
|
||||||
$color = $pairing->getColor();
|
$color = $pairing->getColor();
|
||||||
|
|
||||||
|
$this->getRoundByNo($round)->addPairing($pairing);
|
||||||
$opponent = null;
|
$opponent = null;
|
||||||
foreach ($cache as $key=>$cached) {
|
foreach ($cache as $key=>$cached) {
|
||||||
if (!is_null($cached)) {
|
if (!is_null($cached)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user