Advertisement
Guest User

Untitled

a guest
Aug 7th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.21 KB | None | 0 0
  1. #region using directives
  2.  
  3. using System;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using PoGo.NecroBot.Logic;
  8. using PoGo.NecroBot.Logic.Common;
  9. using PoGo.NecroBot.Logic.Event;
  10. using PoGo.NecroBot.Logic.Logging;
  11. using PoGo.NecroBot.Logic.State;
  12. using PoGo.NecroBot.Logic.Utils;
  13. using PokemonGo.RocketAPI;
  14. using PokemonGo.RocketAPI.Enums;
  15. using PokemonGo.RocketAPI.Extensions;
  16. using POGOProtos.Map.Fort;
  17.  
  18. #endregion
  19.  
  20. namespace PokeWatcher
  21. {
  22.     internal class Program
  23.     {
  24.         private const AuthType Type = AuthType.Ptc;
  25.         private const string Username = "Doilind";
  26.         private const string Password = "a93flcHj";
  27.         private const double Lat = 40.780752;
  28.         private const double Lon = -73.972580;
  29.         private const double Alt = 0;
  30.  
  31.  
  32.         private static void Main(string[] args)
  33.         {
  34.             var c = new Program();
  35.             Console.WriteLine("going to Start()");
  36.             c.Start().Wait();
  37.         }
  38.  
  39.         public async Task Start()
  40.         {
  41.             var setting = new GlobalSettings
  42.             {
  43.                 ProfilePath = Directory.GetCurrentDirectory(),
  44.                 GeneralConfigPath = Directory.GetCurrentDirectory(),
  45.                 ProfileConfigPath = Directory.GetCurrentDirectory()
  46.             };
  47.             Console.WriteLine("Defining Session & ctx");
  48.             var clientSettings = new ClientSettings(setting);
  49.             var logicSettings = new LogicSettings(setting);
  50.             var session = new Session(clientSettings, logicSettings);
  51.             session.Client.ApiFailure = new ApiFailureStrategy(session);
  52.             Console.WriteLine("doing settings");
  53.             var profilePath = Path.Combine(Directory.GetCurrentDirectory());
  54.             var profileConfigPath = Path.Combine(profilePath, "config");
  55.             setting.ProfilePath = profilePath;
  56.             setting.ProfileConfigPath = profileConfigPath;
  57.             setting.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config");
  58.             session.Settings.AuthType = Type;
  59.             session.Settings.PtcUsername = Username;
  60.             session.Settings.PtcPassword = Password;
  61.             session.Settings.DefaultLatitude = Lat;
  62.             session.Settings.DefaultLongitude = Lon;
  63.             session.Settings.DefaultAltitude = Alt;
  64.             setting.Save(profileConfigPath);
  65.             Console.WriteLine(session.Settings.AuthType);
  66.             try
  67.             {
  68.                 var ctx = new Client(session.Settings, session.Client.ApiFailure);
  69.                 await ctx.Login.DoLogin();
  70.                 var profile = await ctx.Player.GetPlayer();
  71.                 var inventory = await ctx.Inventory.GetInventory();
  72.                 var pokemon = inventory.InventoryDelta.InventoryItems.Select(p => p.InventoryItemData.PokemonData).OrderByDescending(p => p.Cp);
  73.                 var mapObjects = await session.Client.Map.GetMapObjects();
  74.                 var pokeStops = mapObjects.Item1.MapCells.SelectMany(i => i.Forts)
  75.                     .Where(
  76.                         i =>
  77.                             i.Type == FortType.Checkpoint &&
  78.                             i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() &&
  79.                             ( // Make sure PokeStop is within max travel distance, unless it's set to 0.
  80.                                 LocationUtils.CalculateDistanceInMeters(
  81.                                     session.Settings.DefaultLatitude, session.Settings.DefaultLongitude,
  82.                                     i.Latitude, i.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters ||
  83.                             session.LogicSettings.MaxTravelDistanceInMeters == 0)
  84.                     );
  85.                 Console.WriteLine("logged in as : " + profile.PlayerData.Username);
  86.             }
  87.             catch (Exception ex)
  88.             {
  89.                 Console.WriteLine("error " + ex.ToString());
  90.             }
  91.             Console.ReadKey();
  92.         }
  93.  
  94.         public async Task UpdatePos(Client ctx, double lat, double lng)
  95.         {
  96.             var pos = await ctx.Player.UpdatePlayerLocation(lat, lng, Alt);
  97.             Console.WriteLine("Updated Position!");
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement