mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Implemented Player::getPerformance()
This commit is contained in:
parent
56e831b372
commit
aef6b688e9
@ -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