コード例 #1
0
ファイル: SendUnitsControl.php プロジェクト: Spameri/TravianZ
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->wdata = $this->WDataModel->get($this->presenter->getParameter('destination'));
     $this->template->village = $this->village = $this->villageService->getVillage($this->presenter->getParameter('id'));
     $this->units = $this->unitService->getUnits($this->village);
     $this->template->units = $this->units;
     $this->template->names = $this->unitService->getNames();
     $unitData = [];
     switch ($this->village->getOwner()->tribe) {
         case App\FrontModule\Model\User\UserService::TRIBE_ROMANS:
             foreach (App\GameModule\Model\Units\UnitService::ROMANS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
         case App\FrontModule\Model\User\UserService::TRIBE_TEUTONS:
             foreach (App\GameModule\Model\Units\UnitService::TEUTONS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
         case App\FrontModule\Model\User\UserService::TRIBE_GAULS:
             foreach (App\GameModule\Model\Units\UnitService::GAULS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
     }
     $this->template->unitData = $unitData;
     $this->template->setFile(__DIR__ . '/SendUnitsControl.latte');
 }
コード例 #2
0
ファイル: VillageService.php プロジェクト: Spameri/TravianZ
 /**
  * @param int $place
  */
 public function getRegistrationPlace($place)
 {
     if ($place === 0) {
         $place = rand(1, 4);
     }
     $this->WDataModel->getRandom($place);
 }
コード例 #3
0
ファイル: SendPresenter.php プロジェクト: Spameri/TravianZ
 public function actionDefault($id, $destination)
 {
     $this->village;
     /** @var \stdClass $wdata */
     $wdata = $this->WDataModel->get($id);
     if ($wdata->occupied) {
         $destinationVillage = $this->villageService->getVillage($destination);
     } else {
         $destinationVillage = FALSE;
     }
 }
コード例 #4
0
ファイル: OasisService.php プロジェクト: Spameri/TravianZ
 public function populateOasis()
 {
     $oases = $this->WDataModel->getAllOases();
     foreach ($oases as $oasis) {
         if ($oasis->oasistype < 4) {
             $high = 1;
         } elseif ($oasis->oasistype < 10) {
             $high = 2;
         } else {
             $high = 0;
         }
         $this->ODataModel->add(['wref' => $oasis->id, 'type' => $oasis->oasistype, 'wood' => 800, 'iron' => 800, 'clay' => 800, 'crop' => 800, 'maxstore' => 800, 'maxcrop' => 800, 'loyalty' => 100, 'owner' => App\FrontModule\Model\User\UserModel::NATURE_ID, 'name' => 'Unoccupied Oasis', 'high' => $high]);
         $this->saveOasisUnits($oasis->id, $oasis->oasistype);
     }
 }
コード例 #5
0
ファイル: RegisterService.php プロジェクト: Spameri/TravianZ
 /**
  * Handle all related to create new user.
  *
  * @param \stdClass $data
  */
 public function createUser($data)
 {
     $user = $this->registerUser($data);
     /** @var \stdClass $field */
     $field = $this->WDataModel->getRandom($data->position);
     $this->WDataModel->setFieldTaken($field->id);
     $villageName = $this->villageService->getNewVillageName($user);
     $vid = $this->VDataModel->addVillageForUser($user, $field, $villageName);
     $this->FDataModel->addResourceFields($field->fieldtype, $vid);
     $this->unitsModel->add(['vref' => $vid]);
     $this->TDataModel->add(['vref' => $vid]);
     $this->ABDataModel->add(['vref' => $vid]);
 }
コード例 #6
0
ファイル: MapPresenter.php プロジェクト: Spameri/TravianZ
 /**
  * @param int $id
  * @param int $wid
  */
 public function actionDetail($id, $wid)
 {
     $this->template->id = $id;
     $village = $this->villageService->getVillage($id);
     /** @var \stdClass $wdata */
     $this->template->wdata = $wdata = $this->WDataModel->get($wid);
     $this->template->reports = $this->reportService->getLastReportsForUser($wid, $this->user->getId());
     $this->template->rallyPoint = $this->buildingService->isBuilt($village, App\GameModule\Model\Building\BuildingModel::RALLY_POINT);
     if ($wdata->occupied === 1) {
         $this->template->village = $this->villageService->getVillage($wid);
     } else {
         $this->template->village = FALSE;
     }
     if ($wdata->oasistype != 0 && $wdata->occupied == 0) {
         $this->template->units = $this->unitsModel->get($wid);
         $this->template->unitNames = $this->unitService->getNames();
     } else {
         $this->template->units = [];
     }
 }