/**
  * {@inheritdoc}
  */
 public function serializedSize(\Protobuf\ComputeSizeContext $context)
 {
     $calculator = $context->getSizeCalculator();
     $size = 0;
     if ($this->map_cells !== null) {
         foreach ($this->map_cells as $val) {
             $innerSize = $val->serializedSize($context);
             $size += 1;
             $size += $innerSize;
             $size += $calculator->computeVarintSize($innerSize);
         }
     }
     if ($this->status !== null) {
         $size += 1;
         $size += $calculator->computeVarintSize($this->status->value());
     }
     if ($this->extensions !== null) {
         $size += $this->extensions->serializedSize($context);
     }
     return $size;
 }
Пример #2
0
 /**
  * @param bool $defaults
  * @throws Exception
  */
 public function execute($defaults = true)
 {
     $this->pokestops = [];
     $this->gyms = [];
     $this->wildPokemons = [];
     parent::execute($defaults);
     $resp = $this->getResponse();
     if ($resp->getStatus() != MapObjectsStatus::SUCCESS() || !$resp->hasMapCellsList()) {
         throw new Exception("Unable to retrieve map objects");
     }
     $mapCells = $resp->getMapCellsList();
     foreach ($mapCells as $mapCell) {
         /** @var MapCell $mapCell */
         if ($mapCell->hasFortsList()) {
             $forts = $mapCell->getFortsList();
             foreach ($forts as $fort) {
                 /** @var FortData $fort */
                 $fortType = $fort->getType();
                 $fortId = $fort->getId();
                 if (is_null($fortType) || $fortType == FortType::GYM()) {
                     if (!isset($this->gyms[$fortId])) {
                         $this->gyms[$fortId] = new Gym($this->session, $fort);
                     }
                 } elseif ($fortType == FortType::CHECKPOINT()) {
                     if (!isset($this->pokestops[$fortId])) {
                         $this->pokestops[$fortId] = new Pokestop($this->session, $fort);
                     }
                 }
             }
         }
         if ($mapCell->hasWildPokemonsList()) {
             $wildPokemons = $mapCell->getWildPokemonsList();
             foreach ($wildPokemons as $wildPokemon) {
                 $this->wildPokemons[] = new WildPokemon($wildPokemon);
             }
         }
     }
 }