Skip to content

Commit

Permalink
Merge pull request NecronomiconCoding#1667 from OuttaControlX/snipefixed
Browse files Browse the repository at this point in the history
Inventory Full During Snipe Power Farming Fix(for real this time)
  • Loading branch information
NecronomiconCoding authored Aug 1, 2016
2 parents 612b2a8 + 5c0a2eb commit 79468ab
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
List<PokemonLocation> locationsToSnipe = new List<PokemonLocation>();
if (scanResult.pokemons != null)
{
var filteredPokemon = scanResult.pokemons.Where(q => pokemonIds.Contains((PokemonId) q.pokemon_name));
var filteredPokemon = scanResult.pokemons.Where(q => pokemonIds.Contains((PokemonId)q.pokemon_name));
var notVisitedPokemon = filteredPokemon.Where(q => !LocsVisited.Contains(q));
var notExpiredPokemon = notVisitedPokemon.Where(q => q.expires < currentTimestamp);

Expand Down Expand Up @@ -228,7 +228,7 @@ private static async Task Snipe(ISession session, IEnumerable<PokemonId> pokemon
var CurrentLatitude = session.Client.CurrentLatitude;
var CurrentLongitude = session.Client.CurrentLongitude;

session.EventDispatcher.Send(new SnipeModeEvent {Active = true});
session.EventDispatcher.Send(new SnipeModeEvent { Active = true });

await
session.Client.Player.UpdatePlayerLocation(latitude,
Expand Down Expand Up @@ -281,12 +281,22 @@ await session.Client.Player.UpdatePlayerLocation(CurrentLatitude, CurrentLongitu
}
else if (encounter.Status == EncounterResponse.Types.Status.PokemonInventoryFull)
{
session.EventDispatcher.Send(new WarnEvent
if (session.LogicSettings.EvolveAllPokemonAboveIv || session.LogicSettings.EvolveAllPokemonWithEnoughCandy)
{
Message =
session.Translation.GetTranslation(
TranslationString.InvFullTransferManually)
});
await EvolvePokemonTask.Execute(session, cancellationToken);
}

if (session.LogicSettings.TransferDuplicatePokemon)
{
await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
}
else
{
session.EventDispatcher.Send(new WarnEvent
{
Message = session.Translation.GetTranslation(TranslationString.InvFullTransferManually)
});
}
}
else
{
Expand All @@ -306,18 +316,18 @@ await session.Client.Player.UpdatePlayerLocation(CurrentLatitude, CurrentLongitu
}
}

session.EventDispatcher.Send(new SnipeModeEvent {Active = false});
session.EventDispatcher.Send(new SnipeModeEvent { Active = false });
await Task.Delay(session.LogicSettings.DelayBetweenPlayerActions, cancellationToken);
}

private static ScanResult SnipeScanForPokemon(ISession session, Location location)
{
var formatter = new NumberFormatInfo {NumberDecimalSeparator = "."};
var formatter = new NumberFormatInfo { NumberDecimalSeparator = "." };

var offset = session.LogicSettings.SnipingScanOffset;
// 0.003 = half a mile; maximum 0.06 is 10 miles
if (offset<0.001) offset=0.003;
if (offset>0.06) offset = 0.06;
if (offset < 0.001) offset = 0.003;
if (offset > 0.06) offset = 0.06;

var boundLowerLeftLat = location.Latitude - offset;
var boundLowerLeftLng = location.Longitude - offset;
Expand Down Expand Up @@ -400,7 +410,7 @@ public static async Task Start(Session session, CancellationToken cancellationTo
catch (Exception ex)
{
// most likely System.IO.IOException
session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()});
session.EventDispatcher.Send(new ErrorEvent { Message = ex.ToString() });
}
await Task.Delay(5000, cancellationToken);
}
Expand Down

0 comments on commit 79468ab

Please sign in to comment.