mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Added average rating calculation
This commit is contained in:
parent
a0e36ec0be
commit
b437a74334
@ -297,4 +297,25 @@ class Tournament extends Tiebreaks
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the average rating for tournament
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getAverageElo(): int
|
||||||
|
{
|
||||||
|
$totalrating = 0;
|
||||||
|
$players = 0;
|
||||||
|
foreach ($this->getPlayers() as $player) {
|
||||||
|
$toadd = $player->getElos()['home'];
|
||||||
|
if ($toadd == 0) {
|
||||||
|
$toadd = $this->getNonRatedElo();
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalrating += $toadd;
|
||||||
|
$players++;
|
||||||
|
}
|
||||||
|
return intdiv($totalrating, $players);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user