Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var PokemonGO = require('pokemon-go-node-api');
- // using var so you can login with multiple users
- var a = new PokemonGO.Pokeio();
- //Set environment variables or replace placeholder text
- var location = {
- type: 'coords',
- coords: {
- latitude: 28.4688446,
- longitude: -16.2776493,
- altitude: 0
- }
- };
- var seekedPokemons = ["Dratini"];
- var username = process.env.PGO_USERNAME || 'USERNAME';
- var password = process.env.PGO_PASSWORD || 'PASSWD';
- var provider = process.env.PGO_PROVIDER || 'GOOGLE / PTC';
- a.init(username, password, location, provider, function(err) {
- if (err) throw err;
- console.log('[i] Current location: ' + a.playerInfo.locationName);
- console.log('[i] lat/long/alt: : ' + a.playerInfo.latitude + ' ' + a.playerInfo.longitude + ' ' + a.playerInfo.altitude);
- a.GetProfile(function(err, profile) {
- if (err) throw err;
- function findPokemon (lat, long) {
- if (long > -16.2357082 && lat > 28.4508218) {
- long = location.coords.longitude;
- lat -= 0.005;
- }
- else {
- long += 0.003;
- }
- //console.log("lat: " + lat + " lon: " + long);
- //console.log(lat + " " + long);
- a.Heartbeat(function(err,hb) {
- if(err) {
- console.log(err);
- }
- // FIX LOCATION FOR UPDATE
- a.SetLocation({type: "coords", coords: {latitude: lat, longitude: long, altitude: 0}}, function(error, coordinates) {
- if (error) {
- console.log (error);
- }
- // console.log(coordinates);
- for (var i = hb.cells.length - 1; i >= 0; i--) {
- for (var j = hb.cells[i].NearbyPokemon.length -1; j >= 0; j--) {
- if(hb.cells[i].NearbyPokemon[j]) {
- var pokemon = a.pokemonlist[parseInt(hb.cells[i].NearbyPokemon[j].PokedexNumber)-1];
- for (var k = 0; k <= seekedPokemons.length - 1; k++) {
- if (seekedPokemons[k] == pokemon.name) {
- var streetName = "";
- if (a.playerInfo.locationName != streetName) {
- console.log('[+] Hay un ' + pokemon.name + ' cerca de: ' + a.playerInfo.locationName);
- }
- streetName = a.playerInfo.locationName;
- }
- }
- }
- }
- }
- if (lat < 28.4508218 && long > -16.2357082) {
- console.log("Programa finalizado");
- }
- else {
- findPokemon(lat, long);
- }
- });
- });
- }
- findPokemon(location.coords.latitude, location.coords.longitude);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement