mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Implemented Player::getPerformance()
This commit is contained in:
parent
6d4eeff234
commit
587a7a2e08
@ -127,4 +127,27 @@ class Player extends PlayerModel
|
||||
}
|
||||
return $points;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPerformance()
|
||||
{
|
||||
$total = 0;
|
||||
$opponents = 0;
|
||||
foreach ($this->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::Notplayed)) {
|
||||
if (array_search(self::Won, $pairing->getResult())) {
|
||||
$total += $pairing->getOpponent()->getElo('home') + 400;
|
||||
} elseif (array_search(self::Lost, $pairing->getResult())) {
|
||||
$total += $pairing->getOpponent()->getElo('home') - 400;
|
||||
} elseif (array_search(self::Draw, $pairing->getResult())) {
|
||||
$total += $pairing->getOpponent()->getElo('home');
|
||||
}
|
||||
$opponents++;
|
||||
}
|
||||
return round($total / $opponents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user