Skip to content

Commit

Permalink
Merge pull request #10 from ReddoKiddo/master
Browse files Browse the repository at this point in the history
Added "Save last coordination function"
  • Loading branch information
NecronomiconCoding authored Jul 22, 2016
2 parents 6429198 + 38ba9ac commit 3ec2e94
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion PokemonGo.RocketAPI/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.Login;
using static PokemonGo.RocketAPI.GeneratedCode.Response.Types;
using System.IO;

namespace PokemonGo.RocketAPI
{
Expand All @@ -29,7 +30,16 @@ public class Client
public Client(ISettings settings)
{
Settings = settings;
SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
if (File.Exists(Directory.GetCurrentDirectory() + "\\Coords.txt"))
{
string latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Coords.txt");
String[] latlng = latlngFromFile.Split(':');
SetCoordinates(Convert.ToDouble(latlng[0]), Convert.ToDouble(latlng[1]), Settings.DefaultAltitude);
}
else
{
SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
}

//Setup HttpClient and create default headers
HttpClientHandler handler = new HttpClientHandler()
Expand All @@ -47,11 +57,19 @@ public Client(ISettings settings)
"application/x-www-form-urlencoded");
}


public void SaveLatLng(double lat, double lng)
{
string latlng = lat.ToString() + ":" + lng.ToString();
File.WriteAllText(Directory.GetCurrentDirectory() + "\\Coords.txt", latlng);
}

private void SetCoordinates(double lat, double lng, double altitude)
{
CurrentLat = lat;
CurrentLng = lng;
CurrentAltitude = altitude;
SaveLatLng(lat, lng);
}

public async Task DoGoogleLogin()
Expand Down

0 comments on commit 3ec2e94

Please sign in to comment.