コード例 #1
0
 /**
  * @param \Likedimion\Tools\Helper\PlayerDataHelper $playerData
  * @throws \Likedimion\Exception\RegistrationException
  * @return Player
  */
 public function createPlayer(PlayerDataHelper $playerData)
 {
     try {
         $findPlayer = $this->playerService->getRepository()->findPlayerByName($playerData->name);
         throw new RegistrationException("player_name_exists");
     } catch (EntityNotFoundException $e) {
         $player = new Player();
         $player->setName($playerData->name);
         $player->setSex($playerData->sex);
         $player->setClass($playerData->class);
         $player->setRace($playerData->race);
         $stats = $player->getStats();
         $cfg = Game::getInstance()->getConfig();
         $stats->setStrenge($cfg["new_player"][$player->getClass()]["str"]);
         $stats->setDexterity($cfg["new_player"][$player->getClass()]["dex"]);
         $stats->setIntelligence($cfg["new_player"][$player->getClass()]["int"]);
         $stats->setSpirituality($cfg["new_player"][$player->getClass()]["spr"]);
         $stats->setEndurance($cfg["new_player"][$player->getClass()]["end"]);
         $player->setStats($stats);
         $this->playerCalculatingService->calculate($player);
         $this->playerService->getRepository()->save($player);
         $account = $this->authService->getAccount(Game::getInstance()->getAuthToken()->getValue());
         $player->setAccount($account);
         $this->accountService->getRepository()->save($account);
         $this->playerService->getRepository()->save($player);
         return $player;
     }
 }
コード例 #2
0
 public function calculatePlayer(PlayerEvent $player)
 {
     $this->calculatingService->calculate($player->getPlayer());
 }