Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sniper with automated pokelocation feed #1349

Merged
merged 11 commits into from
Jul 29, 2016
2 changes: 2 additions & 0 deletions PoGo.NecroBot.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ private static void Main(string[] args)
(lat, lng) => session.EventDispatcher.Send(new UpdatePositionEvent {Latitude = lat, Longitude = lng});

machine.AsyncStart(new VersionCheckState(), session);
if(session.LogicSettings.UseSnipeLocationServer)
SnipePokemonTask.AsyncStart(session);

//Non-blocking key reader
//This will allow to process console key presses in another code parts
Expand Down
9 changes: 7 additions & 2 deletions PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public SnipeSettings()
{
}

public SnipeSettings(List<Location> locations, List<string> pokemon)
public SnipeSettings(List<Location> locations, List<PokemonId> pokemon)
{
Locations = locations;
Pokemon = pokemon;
}

public List<Location> Locations { get; set; }
public List<string> Pokemon { get; set; }
public List<PokemonId> Pokemon { get; set; }
}

public class TransferFilter
Expand Down Expand Up @@ -90,6 +90,11 @@ public interface ILogicSettings
string ProfileConfigPath { get; }
string GeneralConfigPath { get; }
bool SnipeAtPokestops { get; }
string SnipeLocationServer { get; }
int SnipeLocationServerPort { get; }
bool UseSnipeLocationServer { get; }
bool UseTransferIVForSnipe { get; }
int MinDelayBetweenSnipes { get; }

ICollection<KeyValuePair<ItemId, int>> ItemRecycleFilter { get; }

Expand Down
26 changes: 21 additions & 5 deletions PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public class GlobalSettings
public int WebSocketPort = 14251;
public bool StartupWelcomeDelay = true;
public bool SnipeAtPokestops = true;
public string SnipeLocationServer = "localhost";
public int SnipeLocationServerPort = 16969;
public bool UseSnipeLocationServer = false;
public bool UseTransferIVForSnipe = false;
public int MinDelayBetweenSnipes = 20000;

public List<KeyValuePair<ItemId, int>> ItemRecycleFilter = new List<KeyValuePair<ItemId, int>>
{
Expand Down Expand Up @@ -258,12 +263,13 @@ public class GlobalSettings
new Location(51.5025343,-0.2055027) //Charmender Spot

},
Pokemon = new List<string>()
Pokemon = new List<PokemonId>()
{
PokemonId.Dratini.ToString(),
PokemonId.Magikarp.ToString(),
PokemonId.Eevee.ToString(),
PokemonId.Charmander.ToString()
PokemonId.Dratini,
PokemonId.Magikarp,
PokemonId.Eevee,
PokemonId.Snorlax,
PokemonId.Dragonair,
}
};

Expand Down Expand Up @@ -308,6 +314,11 @@ public static GlobalSettings Load(string path)
settings.RenameTemplate = Default.RenameTemplate;
}

if(settings.SnipeLocationServer == null)
{
settings.SnipeLocationServer = Default.SnipeLocationServer;
}

settings.ProfilePath = profilePath;
settings.ProfileConfigPath = profileConfigPath;
settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config");
Expand Down Expand Up @@ -512,5 +523,10 @@ public LogicSettings(GlobalSettings settings)
public bool StartupWelcomeDelay => _settings.StartupWelcomeDelay;
public bool SnipeAtPokestops => _settings.SnipeAtPokestops;
public SnipeSettings PokemonToSnipe => _settings.PokemonToSnipe;
public string SnipeLocationServer => _settings.SnipeLocationServer;
public int SnipeLocationServerPort => _settings.SnipeLocationServerPort;
public bool UseSnipeLocationServer=> _settings.UseSnipeLocationServer;
public bool UseTransferIVForSnipe => _settings.UseTransferIVForSnipe;
public int MinDelayBetweenSnipes => _settings.MinDelayBetweenSnipes;
}
}
13 changes: 7 additions & 6 deletions PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ public static async Task Execute(ISession session)
{
var trackPoints = track.Segments.ElementAt(0).TrackPoints;
var maxTrkPt = trackPoints.Count - 1;

while (curTrkPt <= maxTrkPt)
{
var nextPoint = trackPoints.ElementAt(curTrkPt);
var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
session.Client.CurrentLongitude, Convert.ToDouble(nextPoint.Lat, CultureInfo.InvariantCulture),
Convert.ToDouble(nextPoint.Lon, CultureInfo.InvariantCulture));

if (distance > 5000)
{
session.EventDispatcher.Send(new ErrorEvent
Expand Down Expand Up @@ -94,11 +95,6 @@ public static async Task Execute(ISession session)

await RecycleItemsTask.Execute(session);

if (session.LogicSettings.SnipeAtPokestops)
{
await SnipePokemonTask.Execute(session);
}

if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
session.LogicSettings.EvolveAllPokemonAboveIv)
{
Expand All @@ -116,6 +112,11 @@ public static async Task Execute(ISession session)
}
}

if (session.LogicSettings.SnipeAtPokestops)
{
await SnipePokemonTask.Execute(session);
}

await session.Navigation.HumanPathWalking(trackPoints.ElementAt(curTrkPt),
session.LogicSettings.WalkingSpeedInKilometerPerHour, async () =>
{
Expand Down
9 changes: 5 additions & 4 deletions PoGo.NecroBot.Logic/Tasks/FarmPokestopsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, p
await session.Inventory.RefreshCachedInventory();
}
await RecycleItemsTask.Execute(session);
if (session.LogicSettings.SnipeAtPokestops)
{
await SnipePokemonTask.Execute(session);
}
if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy || session.LogicSettings.EvolveAllPokemonAboveIv)
{
await EvolvePokemonTask.Execute(session);
Expand All @@ -167,6 +163,11 @@ await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, p
await RenamePokemonTask.Execute(session);
}
}

if (session.LogicSettings.SnipeAtPokestops)
{
await SnipePokemonTask.Execute(session);
}
}
}

Expand Down
Loading