/** * @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); } } } }
/** * @param Session $session */ public function __construct(Session $session) { parent::__construct($session); $this->completed = []; }
/** * @param Session $session * @param Fort $fort */ public function __construct(Session $session, Fort $fort) { parent::__construct($session); $this->fort = $fort; }