mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-22 04:11:22 +01:00
Added priorityElo to getPerformance and tiebreaks
This commit is contained in:
parent
3da584aebc
commit
0d83e86edb
@ -131,13 +131,13 @@ class Player extends PlayerModel
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPerformance(): int
|
||||
public function getPerformance(string $type) : int
|
||||
{
|
||||
$total = 0;
|
||||
$opponents = 0;
|
||||
foreach ($this->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::Notplayed)) {
|
||||
$opponentElo = $pairing->getOpponent()->getElo('Nation');
|
||||
$opponentElo = $pairing->getOpponent()->getElo($type);
|
||||
$opponentElo = $opponentElo != 0 ? $opponentElo : $this->getUnratedElo();
|
||||
if (array_search(self::Won, $pairing->getResult())) {
|
||||
$total += $opponentElo + 400;
|
||||
|
@ -128,15 +128,13 @@ abstract class Tiebreaks extends Tournament
|
||||
* @param int $cut
|
||||
* @return float
|
||||
*/
|
||||
protected function calculateAverageRating(Player $player, int $cut = 0): ?float
|
||||
protected function calculateAverageRating(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$totalrating = 0;
|
||||
$totalopponents = 0;
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getElo('Nation');
|
||||
$toadd = $pairing->getOpponent()->getElo($type);
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
@ -153,13 +151,13 @@ abstract class Tiebreaks extends Tournament
|
||||
* @param int $cut
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateAveragePerformance(Player $player, int $cut = 0): ?float
|
||||
protected function calculateAveragePerformance(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getPerformance('Nation');
|
||||
$toadd = $pairing->getOpponent()->getPerformance($type);
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
|
@ -291,10 +291,10 @@ class Tournament extends Tiebreaks
|
||||
return $this->calculateMutualResult($player, $this->getPlayers(), $tbkey);
|
||||
break;
|
||||
case Tiebreak::Aro:
|
||||
return $this->calculateAverageRating($player);
|
||||
return $this->calculateAverageRating($player, $this->getPriorityElo());
|
||||
break;
|
||||
case Tiebreak::AroCut:
|
||||
return $this->calculateAverageRating($player, 1);
|
||||
return $this->calculateAverageRating($player, $this->getPriorityElo(), 1);
|
||||
break;
|
||||
case Tiebreak::Koya:
|
||||
return $this->calculateKoya($player);
|
||||
@ -318,7 +318,7 @@ class Tournament extends Tiebreaks
|
||||
return $this->calculateCumulative($player);
|
||||
break;
|
||||
case Tiebreak::Performance:
|
||||
return $this->calculateAveragePerformance($player);
|
||||
return $this->calculateAveragePerformance($player, $this->getPriorityElo());
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user