Skip to content

Commit

Permalink
Use a reset instead of using another instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Hindi committed Jul 24, 2016
1 parent a2f3be9 commit 995313a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/pokegoapi/api/inventory/CandyJar.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class CandyJar {
private HashMap<PokemonFamilyId, Integer> candies;

public CandyJar(PokemonGo pgo) {
reset(pgo);
}

public void reset(PokemonGo pgo) {
this.pgo = pgo;
candies = new HashMap<>();
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/pokegoapi/api/inventory/Hatchery.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ public class Hatchery {
@Getter
PokemonGo instance;

public Hatchery(PokemonGo instance) {
this.instance = instance;
public Hatchery(PokemonGo pgo) {
reset(pgo);
}

public void reset(PokemonGo pgo) {
this.instance = pgo;
}

public void addEgg(EggPokemon egg) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/pokegoapi/api/inventory/Inventories.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ public void updateInventories() throws LoginFailedException, RemoteServerExcepti
public void updateInventories(boolean forceUpdate) throws LoginFailedException, RemoteServerException {
if (forceUpdate) {
lastInventoryUpdate = 0;
itemBag = new ItemBag(api);
pokebank = new PokeBank(api);
candyjar = new CandyJar(api);
pokedex = new Pokedex(api);
itemBag.reset(api);
pokebank.reset(api);
candyjar.reset(api);
pokedex.reset(api);
incubators = new ArrayList<>();
hatchery = new Hatchery(api);
hatchery.reset(api);
}
GetInventoryMessage invReqMsg = GetInventoryMessage.newBuilder()
.setLastTimestampMs(lastInventoryUpdate)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/pokegoapi/api/inventory/ItemBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public class ItemBag {
private HashMap<ItemId, Item> items;

public ItemBag(PokemonGo pgo) {
reset(pgo);
}

public void reset(PokemonGo pgo) {
this.pgo = pgo;
items = new HashMap<>();
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/pokegoapi/api/inventory/PokeBank.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ public class PokeBank {
@Getter
PokemonGo instance;

public PokeBank(PokemonGo instance) {
this.instance = instance;
public PokeBank(PokemonGo pgo) {
reset(pgo);
}

public void reset(PokemonGo pgo) {
this.instance = pgo;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/pokegoapi/api/inventory/Pokedex.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@

public class Pokedex {

private final PokemonGo api;
private PokemonGo api;
private Map<PokemonId, PokedexEntry> pokedexMap = new HashMap();

public Pokedex(PokemonGo api) {
this.api = api;
public Pokedex(PokemonGo pgo) {
reset(pgo);
}

public void reset(PokemonGo pgo) {
this.api = pgo;
}

/**
Expand Down

0 comments on commit 995313a

Please sign in to comment.