2019-02-06 17:23:37 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: jeroen
|
|
|
|
* Date: 1/02/19
|
|
|
|
* Time: 17:16
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace JeroenED\Libpairtwo;
|
|
|
|
|
2019-05-13 20:03:21 +02:00
|
|
|
use JeroenED\Libpairtwo\Enums\Result;
|
2019-02-06 17:23:37 +01:00
|
|
|
use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
2019-05-01 15:49:12 +02:00
|
|
|
use JeroenED\Libpairtwo\Game;
|
|
|
|
use JeroenED\Libpairtwo\Pairing;
|
2019-02-06 17:23:37 +01:00
|
|
|
|
|
|
|
class Round extends RoundModel
|
|
|
|
{
|
2019-03-20 17:33:09 +01:00
|
|
|
/**
|
|
|
|
* Adds a game to the round
|
|
|
|
*
|
|
|
|
* @param Game $game
|
|
|
|
*/
|
2019-02-11 22:41:44 +01:00
|
|
|
public function addGame(Game $game)
|
|
|
|
{
|
|
|
|
$newarray = $this->getGames();
|
|
|
|
$newarray[] = $game;
|
|
|
|
$this->setGames($newarray);
|
|
|
|
}
|
2019-05-01 15:49:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a pairing to the round
|
|
|
|
*
|
|
|
|
* @param Pairing $pairing
|
|
|
|
*/
|
|
|
|
public function addPairing(Pairing $pairing)
|
|
|
|
{
|
|
|
|
$newarray = $this->getPairings();
|
|
|
|
$newarray[] = $pairing;
|
|
|
|
$this->setPairings($newarray);
|
|
|
|
}
|
2019-05-13 20:03:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of pairings where the player is bye
|
|
|
|
*
|
|
|
|
* @return Pairing[]
|
|
|
|
*/
|
|
|
|
public function getBye(): array
|
|
|
|
{
|
|
|
|
$allPairings = $this->getPairings();
|
|
|
|
$byePairings = [];
|
|
|
|
foreach ($allPairings as $pairing) {
|
|
|
|
if ($pairing->getResult() == Result::bye) {
|
|
|
|
$byePairings[] = $pairing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $byePairings;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of pairings where the player is absent
|
|
|
|
*
|
|
|
|
* @return Pairing[]
|
|
|
|
*/
|
|
|
|
public function getAbsent(): array
|
|
|
|
{
|
|
|
|
$allPairings = $this->getPairings();
|
|
|
|
$absentPairings = [];
|
|
|
|
foreach ($allPairings as $pairing) {
|
|
|
|
if ($pairing->getResult() == Result::absent) {
|
|
|
|
$absentPairings[] = $pairing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $absentPairings;
|
|
|
|
}
|
2019-02-11 17:37:30 +01:00
|
|
|
}
|