Пример #1
0
 /**
  * @param int $id
  * @return App\GameModule\DTO\Village
  */
 public function getVillage($id)
 {
     /** @var \stdClass $VData */
     $VData = $this->VDataModel->getByWId($id);
     $village = new App\GameModule\DTO\Village();
     $village->setId($id);
     if ($VData) {
         /** @var \stdClass $owner */
         $owner = $this->userModel->get($VData->owner);
         $village->setOwner($owner);
         $village->setActualWood($VData->wood);
         $village->setActualClay($VData->clay);
         $village->setActualIron($VData->iron);
         $village->setActualCrop($VData->crop);
         $village->setStorage($VData->maxstore);
         $village->setGranary($VData->maxcrop);
         $upkeep = $VData->pop + $this->upkeepService->getUpkeep($id);
         $village->setUpkeep($upkeep);
         $village->setName($VData->name);
         $village->setLoyalty($VData->loyalty);
         $village->setCapital($VData->capital);
         $village->setType($VData->type);
         $village->setNatar($VData->natar);
         $village->setCulturePoints($VData->cp);
         $village->setPopulation($VData->pop);
         $FData = $this->FDataModel->getByVref($village->getId())->toArray();
         $village->setFData($FData);
         $village->setProductionWood($this->productionService->getProductionWood($village));
         $village->setProductionClay($this->productionService->getProductionClay($village));
         $village->setProductionIron($this->productionService->getProductionIron($village));
         $village->setProductionCrop($this->productionService->getProductionCrop($village));
         $village->setMaxUpkeep($this->productionService->getBaseProductionCrop($village));
     }
     return $village;
 }
Пример #2
0
 public function hasPlus($uid)
 {
     /** @var \stdClass $user */
     $user = $this->userModel->get($uid);
     if ($user->plus > time()) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Пример #3
0
 public function processRegistration(Nette\Application\UI\Form $form)
 {
     $values = $form->getValues();
     $existingUser = $this->userModel->getByEmail($values->email);
     if ($existingUser) {
         $this->flashMessage('Email allready exists');
         $this->redirect(':Front:Register:default');
     }
     $this->registerService->createUser($values);
     $this->redirect(':Front:Login:default');
 }
Пример #4
0
 public function authenticate($username, $password)
 {
     /** @var \stdClass $user */
     $user = $this->userModel->getByUsername($username);
     if (!$user) {
         throw new Nette\Security\AuthenticationException('Username does not exist.');
     } elseif (!Nette\Security\Passwords::verify($password, $user->password)) {
         throw new Nette\Security\AuthenticationException('The password is incorrect.');
     }
     unset($user->password);
     return new Nette\Security\Identity($user->id, $user->access, $user);
 }
Пример #5
0
 /**
  * Recalculated in 10 minute cron.
  */
 public function process()
 {
     $users = $this->userModel->getAllCulturePoints();
     foreach ($users as $user) {
         $villages = $this->VDataModel->getAllByUser($user->id);
         $production = 0;
         foreach ($villages as $village) {
             $production += $village->cp;
         }
         $culturePoints = $user->cp + $production / 6;
         $this->userModel->update($user->id, ['cp' => $culturePoints]);
     }
 }
Пример #6
0
 /**
  * Save registration form.
  *
  * @param \stdClass $data
  * @return \stdClass
  */
 public function registerUser($data)
 {
     $protection = time() + $this->protection;
     $userId = $this->userModel->add(['email' => $data->email, 'username' => $data->nickname, 'password' => Nette\Security\Passwords::hash($data->password), 'access' => UserModel::PERMISSION_USER, 'tribe' => $data->tribe, 'protect' => $protection]);
     return $this->userModel->get($userId);
 }