Skip to content

Commit

Permalink
Merge pull request #417 from SwordStroker/master
Browse files Browse the repository at this point in the history
Fixed Transfer Duplicate lines,that caused by cachedInventory.
  • Loading branch information
NecronomiconCoding authored Jul 24, 2016
2 parents d98a952 + 315047a commit 719ecf5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions PokemonGo.RocketAPI.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ public async Task<IEnumerable<PokemonSettings>> GetPokemonSettings()
.Where(p => p != null && p.FamilyId != PokemonFamilyId.FamilyUnset);
}


public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve(IEnumerable<PokemonId> filter = null)
{
var myPokemons = await GetPokemons();
Expand Down Expand Up @@ -233,7 +232,6 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve(IEnumerable<Pokem
return pokemonToEvolve;
}


private async Task<GetInventoryResponse> getCachedInventory()
{
var now = DateTime.UtcNow;
Expand All @@ -259,5 +257,13 @@ private async Task<GetInventoryResponse> getCachedInventory()
}

}

public async void DeletePokemonFromInvById(ulong Id)
{
var inventory = await getCachedInventory();
InventoryItem pokemon = inventory.InventoryDelta.InventoryItems.FirstOrDefault(i => i.InventoryItemData.Pokemon != null && i.InventoryItemData.Pokemon.Id == Id);
if (pokemon != null)
inventory.InventoryDelta.InventoryItems.Remove(pokemon);
}
}
}
1 change: 1 addition & 0 deletions PokemonGo.RocketAPI.Logic/Logic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ private async Task TransferDuplicatePokemon(bool keepPokemonsThatCanEvolve = fal
if (duplicatePokemon.Cp >= _clientSettings.KeepMinCP || PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) > _clientSettings.KeepMinIVPercentage)
continue;
var transfer = await _client.TransferPokemon(duplicatePokemon.Id);
_inventory.DeletePokemonFromInvById(duplicatePokemon.Id);
_stats.IncreasePokemonsTransfered();
_stats.UpdateConsoleTitle(_inventory);
var bestPokemonOfType = _client.Settings.PrioritizeIVOverCP ? await _inventory.GetHighestPokemonOfTypeByIV(duplicatePokemon) : await _inventory.GetHighestPokemonOfTypeByCP(duplicatePokemon);
Expand Down

0 comments on commit 719ecf5

Please sign in to comment.