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

Added "Save last coordination function" #10

Merged
merged 1 commit into from Jul 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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