/** * @param Player $p1 * @param Player $p2 * * @return PlayerGame */ public function getPlayerstats(Player $p1, Player $p2) { $elo = new Elo($p1->getElo(), $p2->getElo(), 1, 0); $expected = $elo->getExpected(); $player1win = $elo->getRatings(); $elo = new Elo($p1->getElo(), $p2->getElo(), 0, 1); $player2win = $elo->getRatings(); $chance1 = new PlayerChance(); $chance1->setPlayer($p1)->setChance($expected['a'] * 100)->setWinNormal($player1win['a'])->setWinGammon($this->calculateGammon($p1->getElo(), $player1win['a'], self::GAMMON))->setWinBackgammon($this->calculateGammon($p1->getElo(), $player1win['a'], self::BACKGAMMON))->setLoseNormal($player2win['a'])->setLoseGammon($this->calculateGammon($p1->getElo(), $player2win['a'], self::GAMMON))->setLoseBackgammon($this->calculateGammon($p1->getElo(), $player2win['a'], self::BACKGAMMON)); $chance2 = new PlayerChance(); $chance2->setPlayer($p2)->setChance($expected['b'] * 100)->setWinNormal($player2win['b'])->setWinGammon($this->calculateGammon($p2->getElo(), $player2win['b'], self::GAMMON))->setWinBackgammon($this->calculateGammon($p2->getElo(), $player2win['b'], self::BACKGAMMON))->setLoseNormal($player1win['b'])->setLoseGammon($this->calculateGammon($p2->getElo(), $player1win['b'], self::GAMMON))->setLoseBackgammon($this->calculateGammon($p2->getElo(), $player1win['b'], self::BACKGAMMON)); $data = new PlayerGame(); $data->setPlayer1($chance1)->setPlayer2($chance2); return $data; }
public function testPHPELO() { $elo = new Elo(100, 100, Elo::WIN, Elo::LOST); $this->assertEquals(['a' => 0.5, 'b' => 0.5], $elo->getExpected()); $this->assertEquals(['a' => 108, 'b' => 92], $elo->getRatings()); }