Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. var PokemonGO = require('pokemon-go-node-api');
  2.  
  3. // using var so you can login with multiple users
  4. var a = new PokemonGO.Pokeio();
  5.  
  6. //Set environment variables or replace placeholder text
  7. var location = {
  8. type: 'coords',
  9. coords: {
  10. latitude: 28.4688446,
  11. longitude: -16.2776493,
  12. altitude: 0
  13. }
  14. };
  15.  
  16. var seekedPokemons = ["Dratini"];
  17.  
  18. var username = process.env.PGO_USERNAME || 'USERNAME';
  19. var password = process.env.PGO_PASSWORD || 'PASSWD';
  20. var provider = process.env.PGO_PROVIDER || 'GOOGLE / PTC';
  21.  
  22. a.init(username, password, location, provider, function(err) {
  23. if (err) throw err;
  24.  
  25. console.log('[i] Current location: ' + a.playerInfo.locationName);
  26. console.log('[i] lat/long/alt: : ' + a.playerInfo.latitude + ' ' + a.playerInfo.longitude + ' ' + a.playerInfo.altitude);
  27.  
  28. a.GetProfile(function(err, profile) {
  29. if (err) throw err;
  30.  
  31.  
  32.  
  33. function findPokemon (lat, long) {
  34. if (long > -16.2357082 && lat > 28.4508218) {
  35. long = location.coords.longitude;
  36. lat -= 0.005;
  37. }
  38. else {
  39. long += 0.003;
  40. }
  41. //console.log("lat: " + lat + " lon: " + long);
  42. //console.log(lat + " " + long);
  43.  
  44. a.Heartbeat(function(err,hb) {
  45.  
  46. if(err) {
  47. console.log(err);
  48. }
  49.  
  50.  
  51. // FIX LOCATION FOR UPDATE
  52. a.SetLocation({type: "coords", coords: {latitude: lat, longitude: long, altitude: 0}}, function(error, coordinates) {
  53. if (error) {
  54. console.log (error);
  55. }
  56.  
  57. // console.log(coordinates);
  58. for (var i = hb.cells.length - 1; i >= 0; i--) {
  59. for (var j = hb.cells[i].NearbyPokemon.length -1; j >= 0; j--) {
  60. if(hb.cells[i].NearbyPokemon[j]) {
  61. var pokemon = a.pokemonlist[parseInt(hb.cells[i].NearbyPokemon[j].PokedexNumber)-1];
  62. for (var k = 0; k <= seekedPokemons.length - 1; k++) {
  63.  
  64. if (seekedPokemons[k] == pokemon.name) {
  65. var streetName = "";
  66. if (a.playerInfo.locationName != streetName) {
  67. console.log('[+] Hay un ' + pokemon.name + ' cerca de: ' + a.playerInfo.locationName);
  68. }
  69. streetName = a.playerInfo.locationName;
  70. }
  71. }
  72. }
  73. }
  74. }
  75. if (lat < 28.4508218 && long > -16.2357082) {
  76. console.log("Programa finalizado");
  77. }
  78. else {
  79. findPokemon(lat, long);
  80. }
  81.  
  82. });
  83. });
  84. }
  85. findPokemon(location.coords.latitude, location.coords.longitude);
  86. });
  87. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement