/** * @param string $value * * @return bool */ protected function query($value) { $class = $this->entityOptions->getUser(); /** @var \PServerCore\Entity\UserInterface $user */ $user = new $class(); $user->setUsername($value); return $this->gameBackendService->isUserNameExists($user); }
/** * @param UserBlockEntity $userBlock * @return bool */ public function blockUserWithEntity(UserBlockEntity $userBlock) { $this->gameBackendService->removeBlockUser($userBlock->getUser()); $entityManager = $this->entityManager; $entityManager->merge($userBlock); $entityManager->flush(); if ($userBlock->getExpire() > new DateTime()) { $this->gameBackendService->blockUser($userBlock->getUser(), $userBlock->getExpire(), $userBlock->getReason()); } }
/** * @return string */ public function __invoke() { $template = ''; if ($this->authService->hasIdentity()) { $user = $this->authService->getIdentity(); $viewModel = new ViewModel(['user' => $user, 'coins' => $this->gameBackendService->getCoins($user), 'loggedIn' => $this->config['logged_in']]); $viewModel->setTemplate('helper/sidebarLoggedInWidget'); $template = $this->getView()->render($viewModel); } return $template; }
/** * @param array $data * @param UserInterface $user * @return bool */ public function changeInGamePwd(array $data, UserInterface $user) { $user = $this->userService->getUser4Id($user->getId()); if (!$this->isPwdChangeAllowed($data, $user, 'InGame')) { return false; } // check if we have to change it at web too if ($this->isSamePasswordOption()) { $user = $this->userService->setNewPasswordAtUser($user, $data['password']); } $this->gameBackendService->setUser($user, $data['password']); return $user; }
/** * @param UserInterface $user * @param $charId * @return string[] */ protected function validation(UserInterface $user, $charId) { $errorList = []; if (!($character = $this->characterService->getCharacter4UserCharacterId($user, $charId))) { $errorList[] = 'Thats not your character!'; } if (!$errorList && $this->gameDataService->isCharacterOnline($character)) { $errorList[] = 'Please logout your character!'; } if (!$errorList && $this->gameDataService->getInventorySlot($character, 8)) { $errorList[] = 'Its not allowed with job-items!'; } return $errorList; }
/** * @param UserInterface $entity * @param string $plaintext * @return bool */ public function hashPassword(UserInterface $entity, $plaintext) { if ($this->isSamePasswordOption()) { return $this->gameDataService->isPasswordSame($entity->getPassword(), $plaintext); } $bcrypt = new Bcrypt(); return $bcrypt->verify($plaintext, $entity->getPassword()); }
/** * read from GameBackend the current player [or] as param and save them in database * * @param int $extraPlayer */ public function setCurrentPlayer($extraPlayer = 0) { try { $player = $this->gameBackendService->getCurrentPlayerNumber(); } catch (\Exception $e) { $player = 0; } if ($player > 0) { $player += $extraPlayer; } $class = $this->collectionOptions->getEntityOptions()->getPlayerHistory(); /** @var \PServerCore\Entity\PlayerHistory $playerHistory */ $playerHistory = new $class(); $playerHistory->setPlayer($player); $this->entityManager->persist($playerHistory); $this->entityManager->flush(); }
/** * @param UserInterface $user * @param $amount * @return bool */ public function addCoins(UserInterface $user, $amount) { return $this->gameBackendService->setCoins($user, $amount); }
/** * @param int $limit * * @return Paginator|\GameBackend\Entity\SRO\Shard\Character[] */ public function getTopThievesEntityData($limit = 10) { $topThieves = $this->gameDataService->getTopJobCharacter(2); return $topThieves->setMaxResults($limit)->getQuery()->getResult(); }