mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Implemented setting board if not set yet
This commit is contained in:
parent
1708a54d0a
commit
2eb570ce7c
@ -226,6 +226,10 @@ class Tournament
|
|||||||
/** @var Pairing[] */
|
/** @var Pairing[] */
|
||||||
$cache = array();
|
$cache = array();
|
||||||
|
|
||||||
|
/** @var int[] */
|
||||||
|
$lastboards;
|
||||||
|
|
||||||
|
/** @var Pairing $pairing */
|
||||||
foreach ($pairings as $pairing) {
|
foreach ($pairings as $pairing) {
|
||||||
// Add pairing to player
|
// Add pairing to player
|
||||||
$pairing->getPlayer()->addPairing($pairing);
|
$pairing->getPlayer()->addPairing($pairing);
|
||||||
@ -234,6 +238,11 @@ class Tournament
|
|||||||
|
|
||||||
$this->getRoundByNo($round)->addPairing($pairing);
|
$this->getRoundByNo($round)->addPairing($pairing);
|
||||||
$opponent = null;
|
$opponent = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int $key
|
||||||
|
* @var Pairing $cached
|
||||||
|
*/
|
||||||
foreach ($cache as $key=>$cached) {
|
foreach ($cache as $key=>$cached) {
|
||||||
if (!is_null($cached)) {
|
if (!is_null($cached)) {
|
||||||
if (($cached->getOpponent() == $pairing->getPlayer()) && ($cached->getRound() == $pairing->getRound())) {
|
if (($cached->getOpponent() == $pairing->getPlayer()) && ($cached->getRound() == $pairing->getRound())) {
|
||||||
@ -257,6 +266,18 @@ class Tournament
|
|||||||
} else {
|
} else {
|
||||||
// Check if game already exists
|
// Check if game already exists
|
||||||
if (!$this->gameExists($game, $round)) {
|
if (!$this->gameExists($game, $round)) {
|
||||||
|
$game->setBoard($game->getWhite()->getBoard());
|
||||||
|
// Add board if inexistent
|
||||||
|
if($game->getBoard() == -1) {
|
||||||
|
if (isset($lastboards[$round])) {
|
||||||
|
$lastboards[$round] += 1;
|
||||||
|
} else {
|
||||||
|
$lastboards[$round] = 0;
|
||||||
|
}
|
||||||
|
$game->setBoard($lastboards[$round]);
|
||||||
|
$game->getWhite()->setBoard($lastboards[$round]);
|
||||||
|
$game->getBlack()->setBoard($lastboards[$round]);
|
||||||
|
}
|
||||||
$this->AddGame($game, $round);
|
$this->AddGame($game, $round);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user