Skip to content

Commit

Permalink
Merge pull request NecronomiconCoding#1419 from 5andr0/sniper
Browse files Browse the repository at this point in the history
Sniper improvements and removed spamming debug messages
  • Loading branch information
NecronomiconCoding authored Jul 30, 2016
2 parents 5d8ff6a + 7bc010b commit 847fd8f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
5 changes: 4 additions & 1 deletion PoGo.NecroBot.CLI/ConsoleEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ public void HandleEvent(UseBerryEvent evt, ISession session)

public void HandleEvent(SnipeScanEvent evt, ISession session)
{
Logger.Write(session.Translation.GetTranslation(TranslationString.SnipeScan, $"{evt.Bounds.Latitude},{evt.Bounds.Longitude}"));
if(evt.PokemonId == POGOProtos.Enums.PokemonId.Missingno)
Logger.Write(session.Translation.GetTranslation(TranslationString.SnipeScan, $"{evt.Bounds.Latitude},{evt.Bounds.Longitude}"));
else
Logger.Write(session.Translation.GetTranslation(TranslationString.SnipeScanEx, evt.PokemonId, (evt.iv > 0) ? evt.iv.ToString() : "unknown", $"{evt.Bounds.Latitude},{evt.Bounds.Longitude}"));
}

public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session)
Expand Down
2 changes: 2 additions & 0 deletions PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public enum TranslationString
MissingCredentialsGoogle,
MissingCredentialsPtc,
SnipeScan,
SnipeScanEx,
NoPokemonToSnipe,
DisplayHighestMOVE1Header,
DisplayHighestMOVE2Header
Expand Down Expand Up @@ -225,6 +226,7 @@ public class Translation : ITranslation
new KeyValuePair<TranslationString, string>(Common.TranslationString.MissingCredentialsGoogle, "You need to fill out GoogleUsername and GooglePassword in auth.json!"),
new KeyValuePair<TranslationString, string>(Common.TranslationString.MissingCredentialsPtc, "You need to fill out PtcUsername and PtcPassword in auth.json!"),
new KeyValuePair<TranslationString, string>(Common.TranslationString.SnipeScan, "[Sniper] Scanning for Snipeable Pokemon at {0}..."),
new KeyValuePair<TranslationString, string>(Common.TranslationString.SnipeScanEx, "[Sniper] Sniping a {0} with {1} IV at {2}..."),
new KeyValuePair<TranslationString, string>(Common.TranslationString.NoPokemonToSnipe, "[Sniper] No Pokemon found to snipe!"),
new KeyValuePair<TranslationString, string>(Common.TranslationString.DisplayHighestMOVE1Header, "MOVE1"),
new KeyValuePair<TranslationString, string>(Common.TranslationString.DisplayHighestMOVE2Header, "MOVE2"),
Expand Down
2 changes: 2 additions & 0 deletions PoGo.NecroBot.Logic/Event/SnipeScanEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ namespace PoGo.NecroBot.Logic.Event
public class SnipeScanEvent : IEvent
{
public Location Bounds { get; set; }
public POGOProtos.Enums.PokemonId PokemonId { get; set; }
public double iv { get; set; }
}
}
12 changes: 0 additions & 12 deletions PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,30 +217,18 @@ public async Task<IEnumerable<ItemData>> GetItemsToRecycle(ISettings settings)
var pokeballsToRecycle = GetPokeballsToRecycle(settings, myItems);
itemsToRecylce.AddRange(pokeballsToRecycle);
}
else
{
Logging.Logger.Write("Using ItemRecycleFilter for pokeballs", Logging.LogLevel.Info, ConsoleColor.Yellow);
}

if (!_logicSettings.ItemRecycleFilter.Any(s => Potions.Contains(s.Key)))
{
var potionsToRecycle = GetPotionsToRecycle(settings, myItems);
itemsToRecylce.AddRange(potionsToRecycle);
}
else
{
Logging.Logger.Write("Using ItemRecycleFilter for potions", Logging.LogLevel.Info, ConsoleColor.Yellow);
}

if (!_logicSettings.ItemRecycleFilter.Any(s => Revives.Contains(s.Key)))
{
var revivesToRecycle = GetRevivesToRecycle(settings, myItems);
itemsToRecylce.AddRange(revivesToRecycle);
}
else
{
Logging.Logger.Write("Using ItemRecycleFilter for revives", Logging.LogLevel.Info, ConsoleColor.Yellow);
}

var otherItemsToRecylce = myItems
.Where(x => _logicSettings.ItemRecycleFilter.Any(f => f.Key == x.ItemId && x.Count > f.Value))
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

await RecycleItemsTask.Execute(session, cancellationToken);

if (session.LogicSettings.SnipeAtPokestops)
if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
{
await SnipePokemonTask.Execute(session, cancellationToken);
}
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/FarmPokestopsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, p
}
}

if (session.LogicSettings.SnipeAtPokestops)
if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
{
await SnipePokemonTask.Execute(session, cancellationToken);
}
Expand Down
6 changes: 3 additions & 3 deletions PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
var locationsToSnipe = snipeLocations == null ? new List<SniperInfo>() : snipeLocations.Where(q =>
(!session.LogicSettings.UseTransferIVForSnipe || (
(q.iv == 0 && !session.LogicSettings.SnipeIgnoreUnknownIV) ||
(q.iv > session.Inventory.GetPokemonTransferFilter(q.id).KeepMinIvPercentage)
(q.iv >= session.Inventory.GetPokemonTransferFilter(q.id).KeepMinIvPercentage)
)) &&
!locsVisited.Contains(new PokemonLocation(q.latitude, q.longitude))
&& !(q.timeStamp != default(DateTime) &&
Expand All @@ -234,7 +234,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
lastSnipe = DateTime.Now;
foreach (var location in locationsToSnipe)
{
session.EventDispatcher.Send(new SnipeScanEvent() { Bounds = new Location(location.latitude, location.longitude) });
session.EventDispatcher.Send(new SnipeScanEvent() { Bounds = new Location(location.latitude, location.longitude), PokemonId = location.id, iv = location.iv });

await snipe(session, pokemonIds, location.latitude, location.longitude, cancellationToken);
locsVisited.Add(new PokemonLocation(location.latitude, location.longitude));
Expand All @@ -245,7 +245,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

foreach (var location in session.LogicSettings.PokemonToSnipe.Locations)
{
session.EventDispatcher.Send(new SnipeScanEvent() { Bounds = location });
session.EventDispatcher.Send(new SnipeScanEvent() { Bounds = location, PokemonId = PokemonId.Missingno });

var scanResult = SnipeScanForPokemon(location);

Expand Down

0 comments on commit 847fd8f

Please sign in to comment.