trueskill/src/PartialPlay.php

26 lines
662 B
PHP
Raw Normal View History

2022-07-05 13:55:47 +00:00
<?php
namespace DNW\Skills;
class PartialPlay
{
public static function getPartialPlayPercentage($player)
{
// If the player doesn't support the interface, assume 1.0 == 100%
$supportsPartialPlay = $player instanceof ISupportPartialPlay;
2022-07-05 13:55:47 +00:00
if (! $supportsPartialPlay) {
return 1.0;
}
$partialPlayPercentage = $player->getPartialPlayPercentage();
// HACK to get around bug near 0
$smallestPercentage = 0.0001;
if ($partialPlayPercentage < $smallestPercentage) {
$partialPlayPercentage = $smallestPercentage;
}
return $partialPlayPercentage;
}
2022-07-05 13:55:47 +00:00
}