@@ -71,7 +71,7 @@ public static void main(String[] args) {
71
71
api .login (new PtcCredentialProvider (http , ExampleConstants .LOGIN , ExampleConstants .PASSWORD ), hasher );
72
72
api .setLocation (ExampleConstants .LATITUDE , ExampleConstants .LONGITUDE , ExampleConstants .ALTITUDE );
73
73
74
- List <Pokemon > pokemons = api .getInventories (). getPokebank (). getPokemons () ;
74
+ List <Pokemon > pokemons = api .inventories . pokebank . pokemons ;
75
75
76
76
//List to put all pokemon that can be used in a gym battle
77
77
List <Pokemon > possiblePokemon = new ArrayList <>();
@@ -109,13 +109,13 @@ public int compare(Pokemon primary, Pokemon secondary) {
109
109
}
110
110
111
111
//Sort from closest to farthest
112
- MapObjects mapObjects = api .getMap ().getMapObjects () ;
113
- List <Gym > gyms = new ArrayList <>(mapObjects .getGyms () );
112
+ MapObjects mapObjects = api .getMap ().mapObjects ;
113
+ List <Gym > gyms = new ArrayList <>(mapObjects .gyms );
114
114
Collections .sort (gyms , new Comparator <Gym >() {
115
115
@ Override
116
116
public int compare (Gym primary , Gym secondary ) {
117
- double lat = api .getLatitude () ;
118
- double lng = api .getLongitude () ;
117
+ double lat = api .latitude ;
118
+ double lng = api .longitude ;
119
119
double distance1 = MapUtil .distFrom (primary .getLatitude (), primary .getLongitude (), lat , lng );
120
120
double distance2 = MapUtil .distFrom (secondary .getLatitude (), secondary .getLongitude (), lat , lng );
121
121
return Double .compare (distance1 , distance2 );
@@ -124,14 +124,14 @@ public int compare(Gym primary, Gym secondary) {
124
124
125
125
for (Gym gym : gyms ) {
126
126
//Check if gym is attackable, and check if it is not owned by your team
127
- if (gym .isAttackable () && gym .getOwnedByTeam () != api .getPlayerProfile () .getPlayerData ().getTeam ()) {
127
+ if (gym .isAttackable () && gym .getOwnedByTeam () != api .playerProfile .getPlayerData ().getTeam ()) {
128
128
//Walk to gym; Documented pathing in TravelToPokestopExample
129
129
Point destination = new Point (gym .getLatitude (), gym .getLongitude ());
130
130
Path path = new Path (api .getPoint (), destination , 50.0 );
131
131
System .out .println ("Traveling to " + destination + " at 50KMPH!" );
132
132
path .start (api );
133
133
try {
134
- while (!path .isComplete () ) {
134
+ while (!path .complete ) {
135
135
Point point = path .calculateIntermediate (api );
136
136
api .setLatitude (point .getLatitude ());
137
137
api .setLongitude (point .getLongitude ());
@@ -149,7 +149,7 @@ public int compare(Gym primary, Gym secondary) {
149
149
150
150
//Start battle
151
151
battle .start (new FightHandler (attackers ));
152
- while (battle .isActive () ) {
152
+ while (battle .active ) {
153
153
handleAttack (api , battle );
154
154
}
155
155
@@ -162,10 +162,10 @@ public int compare(Gym primary, Gym secondary) {
162
162
}
163
163
164
164
//If prestige reaches 0, deploy your pokemon
165
- if (battle .getGym () .getPoints () <= 0 ) {
165
+ if (battle .gym .getPoints () <= 0 ) {
166
166
Pokemon best = possiblePokemon .get (0 );
167
167
System .out .println ("Deploying " + best .getPokemonId () + " to gym." );
168
- battle .getGym () .deployPokemon (best );
168
+ battle .gym .deployPokemon (best );
169
169
}
170
170
}
171
171
}
@@ -177,10 +177,10 @@ public int compare(Gym primary, Gym secondary) {
177
177
178
178
private static void handleAttack (PokemonGo api , Battle battle ) throws InterruptedException {
179
179
int duration ;
180
- PokemonMove specialMove = battle .getActiveAttacker (). getPokemon () .getMove2 ();
181
- MoveSettings moveSettings = api .getItemTemplates () .getMoveSettings (specialMove );
180
+ PokemonMove specialMove = battle .activeAttacker . pokemon .getMove2 ();
181
+ MoveSettings moveSettings = api .itemTemplates .getMoveSettings (specialMove );
182
182
//Check if we have sufficient energy to perform a special attack
183
- int energy = battle .getActiveAttacker (). getEnergy () ;
183
+ int energy = battle .activeAttacker . energy ;
184
184
int desiredEnergy = -moveSettings .getEnergyDelta ();
185
185
if (energy <= desiredEnergy ) {
186
186
duration = battle .attack ();
@@ -225,7 +225,7 @@ public Pokemon[] createTeam(PokemonGo api, Battle battle) {
225
225
public void onStart (PokemonGo api , Battle battle , Result result ) {
226
226
System .out .println ("Battle started with result: " + result );
227
227
try {
228
- System .out .println ("Defender count: " + battle .getGym () .getDefendingPokemon ().size ());
228
+ System .out .println ("Defender count: " + battle .gym .getDefendingPokemon ().size ());
229
229
} catch (Exception e ) {
230
230
e .printStackTrace ();
231
231
}
@@ -250,11 +250,11 @@ public void onTimedOut(PokemonGo api, Battle battle) {
250
250
@ Override
251
251
public void onActionStart (PokemonGo api , Battle battle , Battle .ServerAction action ) {
252
252
//Dodge all special attacks
253
- if (action .getType () == BattleActionType .ACTION_SPECIAL_ATTACK ) {
253
+ if (action .type == BattleActionType .ACTION_SPECIAL_ATTACK ) {
254
254
System .out .println ("Dodging special attack!" );
255
255
battle .dodge ();
256
256
}
257
- System .out .println (toIndexName (action ) + " performed " + action .getType () );
257
+ System .out .println (toIndexName (action ) + " performed " + action .type );
258
258
}
259
259
260
260
@ Override
@@ -283,17 +283,17 @@ public void onPlayerLeave(PokemonGo api, Battle battle, BattleParticipant left,
283
283
public void onAttacked (PokemonGo api , Battle battle , Battle .BattlePokemon attacked ,
284
284
Battle .BattlePokemon attacker , int duration ,
285
285
long damageWindowStart , long damageWindowEnd , Battle .ServerAction action ) {
286
- PokemonId attackedPokemon = attacked .getPokemon () .getPokemonId ();
287
- PokemonId attackerPokemon = attacker .getPokemon () .getPokemonId ();
286
+ PokemonId attackedPokemon = attacked .pokemon .getPokemonId ();
287
+ PokemonId attackerPokemon = attacker .pokemon .getPokemonId ();
288
288
System .out .println (attackedPokemon + " attacked by " + attackerPokemon + " (" + toIndexName (action ) + ")" );
289
289
}
290
290
291
291
@ Override
292
292
public void onAttackedSpecial (PokemonGo api , Battle battle , Battle .BattlePokemon attacked ,
293
293
Battle .BattlePokemon attacker , int duration ,
294
294
long damageWindowStart , long damageWindowEnd , Battle .ServerAction action ) {
295
- PokemonId attackedPokemon = attacked .getPokemon () .getPokemonId ();
296
- PokemonId attackerPokemon = attacker .getPokemon () .getPokemonId ();
295
+ PokemonId attackedPokemon = attacked .pokemon .getPokemonId ();
296
+ PokemonId attackerPokemon = attacker .pokemon .getPokemonId ();
297
297
System .out .println (attackedPokemon
298
298
+ " attacked with special attack by " + attackerPokemon + " (" + toIndexName (action ) + ")" );
299
299
}
@@ -321,12 +321,12 @@ public void onDefenderHealthUpdate(PokemonGo api, Battle battle, int lastHealth,
321
321
322
322
@ Override
323
323
public void onAttackerSwap (PokemonGo api , Battle battle , Battle .BattlePokemon newAttacker ) {
324
- System .out .println ("Attacker change: " + newAttacker .getPokemon () .getPokemonId ());
324
+ System .out .println ("Attacker change: " + newAttacker .pokemon .getPokemonId ());
325
325
}
326
326
327
327
@ Override
328
328
public void onDefenderSwap (PokemonGo api , Battle battle , Battle .BattlePokemon newDefender ) {
329
- System .out .println ("Defender change: " + newDefender .getPokemon () .getPokemonId ());
329
+ System .out .println ("Defender change: " + newDefender .pokemon .getPokemonId ());
330
330
}
331
331
332
332
@ Override
@@ -349,7 +349,7 @@ public void onDodge(PokemonGo api, Battle battle, Battle.BattlePokemon pokemon,
349
349
*/
350
350
private String toIndexName (Battle .ServerAction action ) {
351
351
String name = "Attacker" ;
352
- if (action .getAttackerIndex () == -1 ) {
352
+ if (action .attackerIndex == -1 ) {
353
353
name = "Defender" ;
354
354
}
355
355
return name ;
0 commit comments