Skip to content

Commit

Permalink
fix in set currentPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
kokspflanze committed Oct 24, 2015
1 parent 144a8ab commit b672562
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/PServerCMS/Service/PlayerHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@

class PlayerHistory extends InvokableBase
{

/**
* @return int
*/
public function getCurrentPlayer()
{
$currentPlayer = $this->getCachingHelperService()->getItem( Caching::PLAYER_HISTORY, function () {
$currentPlayer = $this->getCachingHelperService()->getItem(Caching::PLAYER_HISTORY, function () {
/** @var \PServerCMS\Entity\Repository\PlayerHistory $repository */
$repository = $this->getEntityManager()->getRepository( $this->getEntityOptions()->getPlayerHistory() );
$repository = $this->getEntityManager()->getRepository($this->getEntityOptions()->getPlayerHistory());
return $repository->getCurrentPlayer();
} );
});

return $currentPlayer;
}

/**
* read from GameBackend the current player [or] as param and save them in database
*
* @param int $player
* @param int $extraPlayer
*/
public function setCurrentPlayer( $player = 0 )
public function setCurrentPlayer($extraPlayer = 0)
{
if (!$player) {
$player = $this->getGameBackendService()->getCurrentPlayerNumber();
$player = $this->getGameBackendService()->getCurrentPlayerNumber();
if ($player > 0) {
$player += $extraPlayer;
}

$class = $this->getEntityOptions()->getPlayerHistory();
/** @var \PServerCMS\Entity\PlayerHistory $playerHistory */
$playerHistory = new $class();
$playerHistory->setPlayer( $player );
$playerHistory->setPlayer($player);

$entityManager = $this->getEntityManager();
$entityManager->persist( $playerHistory );
$entityManager->persist($playerHistory);
$entityManager->flush();
}

Expand Down Expand Up @@ -95,8 +95,8 @@ protected function imageCenterString(&$img, $font, $text, $color)
];

$width = ceil(strlen($text) * $num[$font][0]);
$x = imagesx($img) - $width - 8;
$y = Imagesy($img) - ($num[$font][1] + 2);
imagestring($img, $font, $x/2, $y/2, $text, $color);
$x = imagesx($img) - $width - 8;
$y = Imagesy($img) - ($num[$font][1] + 2);
imagestring($img, $font, $x / 2, $y / 2, $text, $color);
}
}

0 comments on commit b672562

Please sign in to comment.