This repository has been archived by the owner on Sep 21, 2018. It is now read-only.
forked from d-pollard/Pokemon-GO-node-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exampleFort.js
88 lines (73 loc) · 2.89 KB
/
exampleFort.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var Pokeio = require('pokemon-go-node-api');
var util = require('util');
util.inspect(console, true);
var username = process.env.PGO_USERNAME || 'username';
var password = process.env.PGO_PASSWORD || 'password';
var provider = process.env.PGO_PROVIDER || 'google';
var location = {
type: 'name',
name: process.env.PGO_LOCATION || 'Time Square'
};
Pokeio.init(username, password, location, provider, function(err) {
console.log('[i] Current location: ' + Pokeio.playerInfo.locationName);
console.log('[i] lat/long/alt: : ' + Pokeio.playerInfo.latitude + ' ' + Pokeio.playerInfo.longitude + ' ' + Pokeio.playerInfo.altitude);
Pokeio.GetProfile(function(err, profile) {
if (err) throw err;
console.log('[i] Username: ' + profile.username);
console.log('[i] Poke Storage: ' + profile.poke_storage);
console.log('[i] Item Storage: ' + profile.item_storage);
var poke = 0;
if (profile.currency[0].amount) {
poke = profile.currency[0].amount;
}
console.log('[i] Pokecoin: ' + poke);
console.log('[i] Stardust: ' + profile.currency[1].amount);
var fortArr = [];
setInterval(function() {
// This lets you know the heartbeat is pumping
console.log('[o] pump...');
Pokeio.Heartbeat(function(a,hb) {
if(a !== null) {
console.log('There appeared to be an error...');
} else {
for (var i = hb.cells.length - 1; i >= 0; i--) {
if(hb.cells[i].Fort) {
var currentFortArr = hb.cells[i].Fort;
for (var i = currentFortArr.length - 1; i >= 0; i--) {
var currentFort = currentFortArr[i];
// console.log(currentFort);
if(currentFort.FortType === 1) {
// "Fort" is a pokestop
if(fortArr.indexOf(currentFort.FortId) === -1) {
fortArr.push(currentFort.FortId);
Pokeio.GetFort(currentFort.FortId, currentFort.Latitude, currentFort.Longitude, function(a,b) {
// NO_RESULT_SET = 0; SUCCESS = 1; OUT_OF_RANGE = 2; IN_COOLDOWN_PERIOD = 3; INVENTORY_FULL = 4;
var resultSet = ['Unexpected Error','Successful collect','Out of range','Already collected','Inventory Full'];
if(b.result === 2) {
Pokeio.warpSpeed(currentFort.Latitude, currentFort.Longitude);
Pokeio.Heartbeat(function(z,y) {
Pokeio.GetFort(currentFort.FortId, currentFort.Latitude, currentFort.Longitude, function(a,b) {
console.log('Stop status: ' + resultSet[b.result]);
});
});
} else {
console.log('Stop status: ' + resultSet[b.result]);
}
console.log(util.inspect(b, showHidden=false, depth=10, colorize=true));
});
}
} else {
// "Fort" is a gym
if(fortArr.indexOf(currentFort.FortId) === -1) {
fortArr.push(currentFort.FortId);
console.log('.:Fort is a gym, pass:.');
}
}
}
}
}
}
});
}, 2000);
});
});