mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-20 08:47:49 +00:00
Start of factor graph port. Things don't work yet, but a lot of syntax updates towards PHP
This commit is contained in:
@ -1,46 +1,40 @@
|
||||
<?php
|
||||
namespace Moserware\Skills;
|
||||
|
||||
require_once(dirname(__FILE__) . "/HashMap.php");
|
||||
|
||||
class RatingContainer
|
||||
{
|
||||
private $_playerHashToRating = array();
|
||||
private $_playerHashToPlayer = array();
|
||||
private $_playerToRating;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_playerToRating = new \HashMap();
|
||||
}
|
||||
|
||||
public function getRating($player)
|
||||
{
|
||||
return $this->_playerHashToRating[self::getHash($player)];
|
||||
return $this->_playerToRating->getValue($player);
|
||||
}
|
||||
|
||||
public function setRating($player, $rating)
|
||||
{
|
||||
$hash = self::getHash($player);
|
||||
$this->_playerHashToPlayer[$hash] = $player;
|
||||
$this->_playerHashToRating[$hash] = $rating;
|
||||
return $this;
|
||||
return $this->_playerToRating->setValue($player, $rating);
|
||||
}
|
||||
|
||||
public function getAllPlayers()
|
||||
{
|
||||
return \array_values($this->_playerHashToPlayer);
|
||||
return $this->_playerToRating->getAllKeys();
|
||||
}
|
||||
|
||||
public function getAllRatings()
|
||||
{
|
||||
return \array_values($this->_playerHashToRating);
|
||||
return $this->_playerToRating->getAllValues();
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return \count($this->_playerHashToPlayer);
|
||||
}
|
||||
private static function getHash($player)
|
||||
{
|
||||
if(\is_object($player))
|
||||
{
|
||||
return \spl_object_hash($player);
|
||||
}
|
||||
|
||||
return $player;
|
||||
}
|
||||
return \count($this->_playerToRating->count());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user