mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Merge branch 'bugfix/fix-mutual-result' into develop
This commit is contained in:
commit
ff1848b0cb
@ -322,6 +322,43 @@ class Player
|
|||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if player has played against all players of the array
|
||||||
|
*
|
||||||
|
* @param Player[] $players
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasPlayedAllPlayersOfArray(array $players): bool
|
||||||
|
{
|
||||||
|
$ownkey = array_search($this, $players);
|
||||||
|
if ($ownkey !== false) {
|
||||||
|
unset($players[$ownkey]);
|
||||||
|
}
|
||||||
|
$total = 0;
|
||||||
|
foreach ($players as $player) {
|
||||||
|
if (array_search($player, $this->Opponents) !== false) {
|
||||||
|
$total++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total == count($players);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all opponents of $this
|
||||||
|
*
|
||||||
|
* @return Player[]
|
||||||
|
*/
|
||||||
|
private function opponents() {
|
||||||
|
$return = array();
|
||||||
|
foreach ($this->Pairings as $pairing) {
|
||||||
|
if (!empty($pairing->Opponent)) {
|
||||||
|
$return[] = $pairing->Opponent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
||||||
*
|
*
|
||||||
@ -334,6 +371,8 @@ class Player
|
|||||||
return $this->playedGames();
|
return $this->playedGames();
|
||||||
} elseif ($key == 'NoOfWins') {
|
} elseif ($key == 'NoOfWins') {
|
||||||
return $this->noOfWins();
|
return $this->noOfWins();
|
||||||
|
} elseif ($key == 'Opponents') {
|
||||||
|
return $this->opponents();
|
||||||
} elseif (isset($this->BinaryData[$key])) {
|
} elseif (isset($this->BinaryData[$key])) {
|
||||||
return $this->BinaryData[$key];
|
return $this->BinaryData[$key];
|
||||||
}
|
}
|
||||||
|
@ -700,6 +700,15 @@ class Tournament
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($interestingplayers) {
|
||||||
|
$allintplayers = $interestingplayers;
|
||||||
|
$allintplayers[] = $player;
|
||||||
|
foreach($allintplayers as $player) {
|
||||||
|
if (!$player->hasPlayedAllPlayersOfArray($allintplayers)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$points = 0;
|
$points = 0;
|
||||||
$totalmatches = 0;
|
$totalmatches = 0;
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
|
Loading…
Reference in New Issue
Block a user