Transferbug is fixed
Transferbug is fixed
Thx @ Daylend
diff --git a/PokemonGo.RocketAPI.Logic/Inventory.cs b/PokemonGo.RocketAPI.Logic/Inventory.cs
index 57512ac..7574a33 100644
--- a/PokemonGo.RocketAPI.Logic/Inventory.cs
+++ b/PokemonGo.RocketAPI.Logic/Inventory.cs
@@ -29,11 +29,9 @@ namespace PokemonGo.RocketAPI.Logic
{
var myPokemon = await GetPokemons();
- var pokemonList = myPokemon.Where(p => p.DeployedFortId == 0 && p.Favorite == 0 && p.Cp < _client.Settings.KeepMinCP && PokemonInfo.CalculatePokemonPerfection(p) < _client.Settings.KeepMinIVPercentage).ToList(); //Don't evolve pokemon in gyms
+ var pokemonList = myPokemon.Where(p => p.DeployedFortId == 0 && p.Favorite == 0 && p.Cp < _client.Settings.KeepMinCP).ToList();
if (filter != null)
- {
pokemonList = pokemonList.Where(p => !filter.Contains(p.PokemonId)).ToList();
- }
if (keepPokemonsThatCanEvolve)
{
@@ -224,12 +222,12 @@ namespace PokemonGo.RocketAPI.Logic
return pokemonToEvolve;
}
- public static async Task<GetInventoryResponse> getCachedInventory(Client _client)
+ public static async Task<GetInventoryResponse> getCachedInventory(Client _client, bool request = false)
{
var now = DateTime.UtcNow;
SemaphoreSlim ss = new SemaphoreSlim(10);
- if (_lastRefresh != null && _lastRefresh.AddSeconds(30).Ticks > now.Ticks)
+ if (_lastRefresh != null && _lastRefresh.AddSeconds(30).Ticks > now.Ticks && request == false)
{
return _cachedInventory;
}
@@ -247,7 +245,6 @@ namespace PokemonGo.RocketAPI.Logic
ss.Release();
}
}
-
}
}
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 30657b2..01ea3cd 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -31,7 +31,6 @@ namespace PokemonGo.RocketAPI.Logic
private GetPlayerResponse _playerProfile;
private int recycleCounter = 0;
- private bool TransferIsRunning = false;
public Logic(ISettings clientSettings)
{
@@ -127,7 +126,7 @@ namespace PokemonGo.RocketAPI.Logic
var PokemonsToEvolve = _clientSettings.PokemonsToEvolve;
if (_clientSettings.EvolveAllPokemonWithEnoughCandy) await EvolveAllPokemonWithEnoughCandy(_clientSettings.PokemonsToEvolve);
- if (_clientSettings.TransferDuplicatePokemon && !TransferIsRunning) await TransferDuplicatePokemon();
+ if (_clientSettings.TransferDuplicatePokemon) await TransferDuplicatePokemon();
await PokemonToCSV();
await RecycleItems();
await ExecuteFarmingPokestopsAndPokemons();
@@ -146,12 +145,6 @@ namespace PokemonGo.RocketAPI.Logic
}
}
- public async Task RepeatAction(int repeat, Func<Task> action)
- {
- for (int i = 0; i < repeat; i++)
- await action();
- }
-
private async Task ExecuteFarmingPokestopsAndPokemons()
{
var mapObjects = await _client.GetMapObjects();
@@ -178,8 +171,6 @@ namespace PokemonGo.RocketAPI.Logic
foreach (var pokeStop in pokeStops)
{
await ExecuteCatchAllNearbyPokemons();
- if (_clientSettings.EvolveAllPokemonWithEnoughCandy) await EvolveAllPokemonWithEnoughCandy(_clientSettings.PokemonsToEvolve);
- if (_clientSettings.TransferDuplicatePokemon) await TransferDuplicatePokemon();
var distance = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, pokeStop.Latitude, pokeStop.Longitude);
var fortInfo = await _client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
@@ -271,6 +262,8 @@ namespace PokemonGo.RocketAPI.Logic
if (pokemons != null && pokemons.Any())
Logger.Write($"Found {pokemons.Count()} catchable Pokemon", LogLevel.None, ConsoleColor.Green);
+ else
+ return;
foreach (var pokemon in pokemons)
{
@@ -286,6 +279,9 @@ namespace PokemonGo.RocketAPI.Logic
if (pokemons.ElementAtOrDefault(pokemons.Count() - 1) != pokemon)
await RandomHelper.RandomDelay(50, 200);
}
+
+ if (_clientSettings.EvolveAllPokemonWithEnoughCandy) await EvolveAllPokemonWithEnoughCandy(_clientSettings.PokemonsToEvolve);
+ if (_clientSettings.TransferDuplicatePokemon) await TransferDuplicatePokemon();
}
private async Task EvolveAllPokemonWithEnoughCandy(IEnumerable<PokemonId> filter = null)
@@ -310,10 +306,10 @@ namespace PokemonGo.RocketAPI.Logic
private async Task TransferDuplicatePokemon(bool keepPokemonsThatCanEvolve = false)
{
+ await Inventory.getCachedInventory(_client, true);
var duplicatePokemons = await _inventory.GetDuplicatePokemonToTransfer(keepPokemonsThatCanEvolve, _clientSettings.PrioritizeIVOverCP, _clientSettings.PokemonsNotToTransfer);
- // Currently not returns the correct value
- //if (duplicatePokemons != null && duplicatePokemons.Any())
- // Logger.Normal(ConsoleColor.DarkYellow, $"(TRANSFER) {duplicatePokemons.Count()} Pokemon:");
+ if (duplicatePokemons != null && duplicatePokemons.Any())
+ Logger.Write($"{duplicatePokemons.Count()} Pokemon:", LogLevel.Transfer);
foreach (var duplicatePokemon in duplicatePokemons)
{
@@ -323,7 +319,7 @@ namespace PokemonGo.RocketAPI.Logic
_stats.UpdateConsoleTitle(_inventory);
var bestPokemonOfType = await _inventory.GetHighestPokemonOfTypeByCP(duplicatePokemon);
- Logger.Write($"{duplicatePokemon.PokemonId} (CP {duplicatePokemon.Cp} | {PokemonInfo.CalculatePokemonPerfection(duplicatePokemon).ToString("0.00")} % perfect) | (Best: {bestPokemonOfType.Cp} CP | {PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType).ToString("0.00")} % perfect)", LogLevel.Transfer);
+ Logger.Write($"{duplicatePokemon.PokemonId} (CP {duplicatePokemon.Cp} | {PokemonInfo.CalculatePokemonPerfection(duplicatePokemon).ToString("0.00")} % perfect) | (Best: {bestPokemonOfType.Cp} CP | {PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType).ToString("0.00")} % perfect)", LogLevel.Transfer);
await Task.Delay(500);
}
}
diff --git a/PokemonGo.RocketAPI/Client.cs b/PokemonGo.RocketAPI/Client.cs
index 8ac6a63..8060b4d 100644
--- a/PokemonGo.RocketAPI/Client.cs
+++ b/PokemonGo.RocketAPI/Client.cs
@@ -404,6 +404,12 @@ namespace PokemonGo.RocketAPI
_apiUrl = serverResponse.ApiUrl;
}
+ public async Task RepeatAction(int repeat, Func<Task> action)
+ {
+ for (int i = 0; i < repeat; i++)
+ await action();
+ }
+
public async Task<TransferPokemonOut> TransferPokemon(ulong pokemonId)
{
var customRequest = new TransferPokemon
diff --git a/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj b/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
index a95087d..570dacc 100644
--- a/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
+++ b/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
@@ -17,7 +17,7 @@
<UpdateAssemblyInfoVersion>False</UpdateAssemblyInfoVersion>
<AssemblyVersionSettings>YearStamp.MonthStamp.DayStamp.Increment</AssemblyVersionSettings>
<PrimaryVersionType>AssemblyVersionAttribute</PrimaryVersionType>
- <AssemblyVersion>2016.7.24.256</AssemblyVersion>
+ <AssemblyVersion>2016.7.24.275</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
diff --git a/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs b/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
index f322d75..97588d1 100644
--- a/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
+++ b/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2016.7.24.256")]
+[assembly: AssemblyVersion("2016.7.24.276")]
[assembly: AssemblyFileVersion("1.0.0.0")]
You may download the files in Public Git.