Skip to content

Commit

Permalink
More Fixes, Our own API, and S2 reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
disdain13 committed Sep 8, 2016
1 parent 374f02d commit 70276ed
Show file tree
Hide file tree
Showing 24 changed files with 137 additions and 121 deletions.
2 changes: 1 addition & 1 deletion PokeRoadie/Data/LocationData.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#region " Imports "

using System;
using PokemonGo.RocketAPI.Helpers;
using PokeRoadie.Api.Helpers;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion PokeRoadie/Logging/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class LogEntry
{
public DateTime Date { get; set; }
public string Message { get; set; }
public PokemonGo.RocketAPI.Logging.LogLevel Level { get; set; }
public PokeRoadie.Api.Logging.LogLevel Level { get; set; }
public ConsoleColor Color { get; set; }
}
}
2 changes: 1 addition & 1 deletion PokeRoadie/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Initialize()
if (provider != null)
provider.Initialize();
}
public static void Write(string message, PokemonGo.RocketAPI.Logging.LogLevel level = PokemonGo.RocketAPI.Logging.LogLevel.None, ConsoleColor color = ConsoleColor.White)
public static void Write(string message, PokeRoadie.Api.Logging.LogLevel level = PokeRoadie.Api.Logging.LogLevel.None, ConsoleColor color = ConsoleColor.White)
{
//create new log entry
Logger.Current.Write(
Expand Down
2 changes: 1 addition & 1 deletion PokeRoadie/Logging/Providers/ConsoleLogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PokemonGo.RocketAPI.Logging;
using PokeRoadie.Api.Logging;

namespace PokeRoadie.Logging.Providers
{
Expand Down
6 changes: 3 additions & 3 deletions PokeRoadie/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System;
using System.Threading.Tasks;

using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Logging;
using PokemonGo.RocketAPI.Helpers;
using PokeRoadie.Api;
using PokeRoadie.Api.Logging;
using PokeRoadie.Api.Helpers;

using POGOProtos.Networking.Responses;
using POGOProtos.Map.Fort;
Expand Down
9 changes: 6 additions & 3 deletions PokeRoadie/PokeRoadie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\components\POGOProtos.dll</HintPath>
</Reference>
<Reference Include="Pokemon.Go.Rocket.API, Version=2016.9.5.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\components\Pokemon.Go.Rocket.API.dll</HintPath>
<Reference Include="PokeRoadie.Api">
<HintPath>..\components\PokeRoadie.Api.dll</HintPath>
</Reference>
<Reference Include="PokeRoadie.Xml, Version=2016.8.2.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\components\PokeRoadie.Xml.dll</HintPath>
</Reference>
<Reference Include="S2Geometry, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\S2Geometry.1.0.3\lib\portable-net45+wp8+win8\S2Geometry.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
Expand Down
4 changes: 2 additions & 2 deletions PokeRoadie/PokeRoadieClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.Linq;
using System.IO;
using System.Reflection;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI;
using PokeRoadie.Api.Extensions;
using PokeRoadie.Api;
using POGOProtos.Networking.Envelopes;
using System.Threading.Tasks;
using PokeRoadie.Utils;
Expand Down
12 changes: 6 additions & 6 deletions PokeRoadie/PokeRoadieExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
using System.Linq;
using System.Threading.Tasks;

using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.Helpers;
using PokemonGo.RocketAPI.Logging;
using PokemonGo.RocketAPI.Exceptions;
using PokeRoadie.Api;
using PokeRoadie.Api.Enums;
using PokeRoadie.Api.Extensions;
using PokeRoadie.Api.Helpers;
using PokeRoadie.Api.Logging;
using PokeRoadie.Api.Exceptions;

using POGOProtos.Inventory.Item;
using POGOProtos.Networking.Responses;
Expand Down
8 changes: 4 additions & 4 deletions PokeRoadie/PokeRoadieInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using System.Threading.Tasks;
using System.Threading;

using PokemonGo.RocketAPI.Logging;
using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Exceptions;
using PokeRoadie.Api.Logging;
using PokeRoadie.Api;
using PokeRoadie.Api.Exceptions;

using POGOProtos.Inventory;
using POGOProtos.Inventory.Item;
Expand All @@ -18,7 +18,7 @@
using POGOProtos.Data.Player;
using POGOProtos.Enums;
using POGOProtos.Settings.Master;
using PokemonGo.RocketAPI.Extensions;
using PokeRoadie.Api.Extensions;
using POGOProtos.Map.Fort;
using PokeRoadie.Extensions;

Expand Down
57 changes: 31 additions & 26 deletions PokeRoadie/PokeRoadieLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using System.Threading.Tasks;
using System.Net;

using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.Helpers;
using PokemonGo.RocketAPI.Logging;
using PokemonGo.RocketAPI.Exceptions;
using PokemonGo.RocketAPI.Rpc;
using PokeRoadie.Api;
using PokeRoadie.Api.Enums;
using PokeRoadie.Api.Extensions;
using PokeRoadie.Api.Helpers;
using PokeRoadie.Api.Logging;
using PokeRoadie.Api.Exceptions;
using PokeRoadie.Api.Rpc;

using POGOProtos.Inventory;
using POGOProtos.Inventory.Item;
Expand Down Expand Up @@ -97,7 +97,7 @@ private bool RaiseSyncEvent(Delegate method, params object[] args)
private int xloCount = 0;
private volatile bool isRunning;
//private volatile bool inFlight = false;
private volatile bool inTravel = false;


#endregion
#region " Timers "
Expand Down Expand Up @@ -138,6 +138,7 @@ private bool RaiseSyncEvent(Delegate method, params object[] args)
#endregion
#region " Properties "
public Context Context { get; set; }
public bool IsTravelingLongDistance { get; set; }
public bool CanCatch { get { return Context.Settings.CatchPokemon && Context.Session.Current.CatchEnabled && !softBan && Context.Navigation.LastKnownSpeed <= Context.Settings.MaxCatchSpeed && noWorkTimer <= DateTime.Now; } }
public bool CanVisit { get { return Context.Settings.VisitPokestops && Context.Session.Current.VisitEnabled && !softBan; } }
public bool CanVisitGyms { get { return Context.Settings.VisitGyms && Context.Statistics.Currentlevel > 4 && !softBan; } }
Expand Down Expand Up @@ -993,13 +994,13 @@ private async Task ExecuteFarming()
if (Context.Settings.MaxDistance != 0 &&
distanceFromStart > Context.Settings.MaxDistance)
{
inTravel = true;
IsTravelingLongDistance = true;
Logger.Write($"We have traveled outside the max distance of {Context.Settings.MaxDistance}, returning to center at {wayPointGeo}", LogLevel.Navigation, ConsoleColor.White);
await Context.Navigation.HumanLikeWalking(wayPointGeo, distanceFromStart > Context.Settings.MaxDistance / 2 ? Context.Settings.LongDistanceSpeed : Context.Settings.MinSpeed, GetShortTask(), distanceFromStart > Context.Settings.MaxDistance / 2 ? false : true);
await Context.Navigation.HumanLikeWalking(wayPointGeo, distanceFromStart > Context.Settings.MaxDistance / 2 ? Context.Settings.LongDistanceSpeed : Context.Settings.MinSpeed, distanceFromStart > Context.Settings.MaxDistance / 2 ? GetLongTask() : GetShortTask(), distanceFromStart > Context.Settings.MaxDistance / 2 ? false : true);
gymTries.Clear();
locationAttemptCount = 0;
Logger.Write($"Arrived at center point {Math.Round(wayPointGeo.Latitude, 5)}", LogLevel.Navigation);
inTravel = false;
IsTravelingLongDistance = false;
}

//if destinations are enabled
Expand Down Expand Up @@ -1030,14 +1031,14 @@ private async Task ExecuteFarming()
if (!RaiseSyncEvent(OnChangeDestination, destination, newIndex))
OnChangeDestination(destination, newIndex);
}
inTravel = true;
IsTravelingLongDistance = true;
Logger.Write($"Moving to new destination - {destination.Name} - {destination.Latitude}:{destination.Longitude}", LogLevel.Navigation, ConsoleColor.White);
Logger.Write("Preparing for long distance travel...", LogLevel.None, ConsoleColor.White);
await Context.Navigation.HumanLikeWalking(destination.GetGeo(), Context.Settings.LongDistanceSpeed, GetLongTask(), false);
Logger.Write($"Arrived at destination - {destination.Name}!", LogLevel.Navigation, ConsoleColor.White);
gymTries.Clear();
locationAttemptCount = 0;
inTravel = false;
IsTravelingLongDistance = false;

//reset destination timer
Context.Settings.DestinationEndDate = DateTime.Now.AddMinutes(Context.Settings.MinutesPerDestination);
Expand Down Expand Up @@ -1123,13 +1124,13 @@ private async Task ExecuteFarming()
}
else
{
inTravel = true;
IsTravelingLongDistance = true;
Logger.Write($"Since there are no locations, let's go back to the waypoint center {wayPointGeo} {distanceFromStart}m", LogLevel.Navigation, ConsoleColor.White);
await Context.Navigation.HumanLikeWalking(wayPointGeo, distanceFromStart > Context.Settings.MaxDistance / 2 ? Context.Settings.LongDistanceSpeed : Context.Settings.MinSpeed, distanceFromStart > Context.Settings.MaxDistance / 2 ? GetLongTask() : GetShortTask(), distanceFromStart > Context.Settings.MaxDistance / 2 ? false : true);
gymTries.Clear();
locationAttemptCount = 0;
Logger.Write($"Arrived at center point {Math.Round(wayPointGeo.Latitude, 5)}", LogLevel.Navigation);
inTravel = false;
IsTravelingLongDistance = false;
}
}
}
Expand Down Expand Up @@ -1267,7 +1268,7 @@ private async Task ProcessNearby(GetMapObjectsResponse mapObjects)
//if (Context.Settings.TransferPokemon) await TransferPokemon();
}

private async Task ProcessFortList(List<FortData> pokeStopList, GetMapObjectsResponse mapObjects)
private async Task ProcessFortList(List<FortData> pokeStopList, GetMapObjectsResponse mapObjects, bool holdSpeed = false)
{
if (pokeStopList.Count == 0) return;

Expand Down Expand Up @@ -1343,7 +1344,7 @@ private async Task ProcessFortList(List<FortData> pokeStopList, GetMapObjectsRes
if (NeedsNewLogin) break;

//if we are not currently traveling long distance
if (!inTravel)
if (!IsTravelingLongDistance)
{
//check destinations
if (Context.Settings.DestinationsEnabled && Context.Settings.DestinationEndDate.HasValue && DateTime.Now > Context.Settings.DestinationEndDate.Value)
Expand All @@ -1370,11 +1371,11 @@ private async Task ProcessFortList(List<FortData> pokeStopList, GetMapObjectsRes
finalList.RemoveAt(0);
if (pokeStop.Type != FortType.Gym)
{
await ProcessPokeStop(pokeStop, mapObjects);
await ProcessPokeStop(pokeStop, mapObjects, holdSpeed);
}
else
{
await ProcessGym(pokeStop, mapObjects);
await ProcessGym(pokeStop, mapObjects, holdSpeed);
}
//if (pokestopCount == 0 && gymCount > 0)
// await RandomHelper.RandomDelay(1000, 2000);
Expand All @@ -1383,7 +1384,7 @@ private async Task ProcessFortList(List<FortData> pokeStopList, GetMapObjectsRes
}
}

private async Task ProcessGym(FortData pokeStop, GetMapObjectsResponse mapObjects)
private async Task ProcessGym(FortData pokeStop, GetMapObjectsResponse mapObjects, bool holdSpeed = false)
{
if (!gymTries.Contains(pokeStop.Id))
{
Expand All @@ -1406,7 +1407,11 @@ private async Task ProcessGym(FortData pokeStop, GetMapObjectsResponse mapObject

var name = $"(GYM) {fortInfo.Name} in {distance:0.##} m distance";
Logger.Write(name, LogLevel.None, ConsoleColor.Cyan);
await Context.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), Context.Settings.MinSpeed, GetShortTask());
//await Context.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), Context.Settings.MinSpeed, GetShortTask());
await Context.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), holdSpeed ? Context.Settings.LongDistanceSpeed : distance > Context.Settings.MaxDistance / 2 ? Context.Settings.LongDistanceSpeed : Context.Settings.MinSpeed, distance > Context.Settings.MaxDistance / 2 ? GetLongTask() : GetShortTask(), distance > Context.Settings.MaxDistance / 2 ? false : true);

if (CanCatch)
await ProcessNearby(mapObjects);

var fortDetails = await Context.Client.Fort.GetGymDetails(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

Expand Down Expand Up @@ -1533,7 +1538,7 @@ private async Task ProcessGym(FortData pokeStop, GetMapObjectsResponse mapObject
}
}

private async Task ProcessPokeStop(FortData pokeStop, GetMapObjectsResponse mapObjects)
private async Task ProcessPokeStop(FortData pokeStop, GetMapObjectsResponse mapObjects, bool holdSpeed = false)
{
if (CanCatch)
await ProcessNearby(mapObjects);
Expand All @@ -1554,7 +1559,7 @@ private async Task ProcessPokeStop(FortData pokeStop, GetMapObjectsResponse mapO
}

Logger.Write($"{fortInfo.Name}{(pokeStop.LureInfo == null ? "" : " WITH LURE")} in {distance:0.##} m distance", LogLevel.Pokestop);
await Context.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), distance > Context.Settings.MaxDistance / 2 ? Context.Settings.LongDistanceSpeed : Context.Settings.MinSpeed, distance > Context.Settings.MaxDistance / 2 ? GetLongTask() : GetShortTask(), distance > Context.Settings.MaxDistance / 2 ? false : true);
await Context.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), holdSpeed ? Context.Settings.LongDistanceSpeed : distance > Context.Settings.MaxDistance / 2 ? Context.Settings.LongDistanceSpeed : Context.Settings.MinSpeed, distance > Context.Settings.MaxDistance / 2 ? GetLongTask() : GetShortTask(), distance > Context.Settings.MaxDistance / 2 ? false : true);

if (CanCatch)
await ProcessNearby(mapObjects);
Expand Down Expand Up @@ -2626,9 +2631,9 @@ private async Task CatchNearbyStops(GetMapObjectsResponse mapObjects, bool path)

if (totalActivecount > 0)
{
if (inTravel) Logger.Write($"Slight course change...", LogLevel.Navigation);
await ProcessFortList(pokeStopList, mapObjects);
if (inTravel)
if (IsTravelingLongDistance) Logger.Write($"Slight course change...", LogLevel.Navigation);
await ProcessFortList(pokeStopList, mapObjects, true);
if (IsTravelingLongDistance)
{
var speedInMetersPerSecond = Context.Settings.LongDistanceSpeed / 3.6;
var sourceLocation = new GeoCoordinate(Context.Client.CurrentLatitude, Context.Client.CurrentLongitude);
Expand Down
8 changes: 4 additions & 4 deletions PokeRoadie/PokeRoadieSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
using System.Xml.Serialization;
using System.Threading.Tasks;

using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Logging;
using PokeRoadie.Api;
using PokeRoadie.Api.Enums;
using PokeRoadie.Api.Logging;

using POGOProtos.Inventory.Item;
using POGOProtos.Enums;
Expand All @@ -22,7 +22,7 @@

namespace PokeRoadie
{
public class PokeRoadieSettings : PokemonGo.RocketAPI.ISettings
public class PokeRoadieSettings : PokeRoadie.Api.ISettings
{

#region " Members "
Expand Down
4 changes: 2 additions & 2 deletions PokeRoadie/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using System.Threading.Tasks;
using System.Windows.Forms;

using PokemonGo.RocketAPI.Exceptions;
using PokemonGo.RocketAPI.Logging;
using PokeRoadie.Api.Exceptions;
using PokeRoadie.Api.Logging;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion PokeRoadie/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.IO;
using System.Xml.Serialization;
using System.Threading.Tasks;
using PokemonGo.RocketAPI.Logging;
using PokeRoadie.Api.Logging;

#endregion

Expand Down
6 changes: 3 additions & 3 deletions PokeRoadie/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Collections.Generic;
using System.Linq;

using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Logging;
using PokemonGo.RocketAPI.Helpers;
using PokeRoadie.Api;
using PokeRoadie.Api.Logging;
using PokeRoadie.Api.Helpers;

using POGOProtos.Data;
using POGOProtos.Enums;
Expand Down
Loading

0 comments on commit 70276ed

Please sign in to comment.