/** * @param Session $session * @param FortData $data */ public function __construct(Session $session, FortData $data) { if ($data->getType() != FortType::CHECKPOINT()) { throw new InvalidArgumentException("Fort not a pokestop"); } parent::__construct($session, $data); // TODO: modifier // TODO: lure // TODO: sponsor (maybe) }
/** * @param Session $session * @param FortData $data */ public function __construct(Session $session, FortData $data) { if (!is_null($data->getType()) && $data->getType() != FortType::GYM()) { throw new InvalidArgumentException("Fort not a gym"); } parent::__construct($session, $data); // TODO: team color // TODO: highest cp pokemon // TODO: xp // TODO: in battle }
/** * @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); } } } }
/** * {@inheritdoc} */ public function serializedSize(\Protobuf\ComputeSizeContext $context) { $calculator = $context->getSizeCalculator(); $size = 0; if ($this->fort_id !== null) { $size += 1; $size += $calculator->computeStringSize($this->fort_id); } if ($this->team_color !== null) { $size += 1; $size += $calculator->computeVarintSize($this->team_color->value()); } if ($this->pokemon_data !== null) { $innerSize = $this->pokemon_data->serializedSize($context); $size += 1; $size += $innerSize; $size += $calculator->computeVarintSize($innerSize); } if ($this->name !== null) { $size += 1; $size += $calculator->computeStringSize($this->name); } if ($this->image_urls !== null) { foreach ($this->image_urls as $val) { $size += 1; $size += $calculator->computeStringSize($val); } } if ($this->fp !== null) { $size += 1; $size += $calculator->computeVarintSize($this->fp); } if ($this->stamina !== null) { $size += 1; $size += $calculator->computeVarintSize($this->stamina); } if ($this->max_stamina !== null) { $size += 1; $size += $calculator->computeVarintSize($this->max_stamina); } if ($this->type !== null) { $size += 1; $size += $calculator->computeVarintSize($this->type->value()); } if ($this->latitude !== null) { $size += 1; $size += 8; } if ($this->longitude !== null) { $size += 1; $size += 8; } if ($this->description !== null) { $size += 1; $size += $calculator->computeStringSize($this->description); } if ($this->modifiers !== null) { foreach ($this->modifiers as $val) { $innerSize = $val->serializedSize($context); $size += 1; $size += $innerSize; $size += $calculator->computeVarintSize($innerSize); } } if ($this->extensions !== null) { $size += $this->extensions->serializedSize($context); } return $size; }
/** * {@inheritdoc} */ public function serializedSize(\Protobuf\ComputeSizeContext $context) { $calculator = $context->getSizeCalculator(); $size = 0; if ($this->id !== null) { $size += 1; $size += $calculator->computeStringSize($this->id); } if ($this->last_modified_timestamp_ms !== null) { $size += 1; $size += $calculator->computeVarintSize($this->last_modified_timestamp_ms); } if ($this->latitude !== null) { $size += 1; $size += 8; } if ($this->longitude !== null) { $size += 1; $size += 8; } if ($this->owned_by_team !== null) { $size += 1; $size += $calculator->computeVarintSize($this->owned_by_team->value()); } if ($this->guard_pokemon_id !== null) { $size += 1; $size += $calculator->computeVarintSize($this->guard_pokemon_id->value()); } if ($this->guard_pokemon_cp !== null) { $size += 1; $size += $calculator->computeVarintSize($this->guard_pokemon_cp); } if ($this->enabled !== null) { $size += 1; $size += 1; } if ($this->type !== null) { $size += 1; $size += $calculator->computeVarintSize($this->type->value()); } if ($this->gym_points !== null) { $size += 1; $size += $calculator->computeVarintSize($this->gym_points); } if ($this->is_in_battle !== null) { $size += 1; $size += 1; } if ($this->active_fort_modifier !== null) { foreach ($this->active_fort_modifier as $val) { $size += 1; $size += $calculator->computeVarintSize($val->value()); } } if ($this->lure_info !== null) { $innerSize = $this->lure_info->serializedSize($context); $size += 1; $size += $innerSize; $size += $calculator->computeVarintSize($innerSize); } if ($this->cooldown_complete_timestamp_ms !== null) { $size += 1; $size += $calculator->computeVarintSize($this->cooldown_complete_timestamp_ms); } if ($this->sponsor !== null) { $size += 1; $size += $calculator->computeVarintSize($this->sponsor->value()); } if ($this->rendering_type !== null) { $size += 2; $size += $calculator->computeVarintSize($this->rendering_type->value()); } if ($this->deploy_lockout_end_ms !== null) { $size += 2; $size += $calculator->computeVarintSize($this->deploy_lockout_end_ms); } if ($this->extensions !== null) { $size += $this->extensions->serializedSize($context); } return $size; }