Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region using directives
- using System;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using PoGo.NecroBot.Logic;
- using PoGo.NecroBot.Logic.Common;
- using PoGo.NecroBot.Logic.Event;
- using PoGo.NecroBot.Logic.Logging;
- using PoGo.NecroBot.Logic.State;
- using PoGo.NecroBot.Logic.Utils;
- using PokemonGo.RocketAPI;
- using PokemonGo.RocketAPI.Enums;
- using PokemonGo.RocketAPI.Extensions;
- using POGOProtos.Map.Fort;
- #endregion
- namespace PokeWatcher
- {
- internal class Program
- {
- private const AuthType Type = AuthType.Ptc;
- private const string Username = "Doilind";
- private const string Password = "a93flcHj";
- private const double Lat = 40.780752;
- private const double Lon = -73.972580;
- private const double Alt = 0;
- private static void Main(string[] args)
- {
- var c = new Program();
- Console.WriteLine("going to Start()");
- c.Start().Wait();
- }
- public async Task Start()
- {
- var setting = new GlobalSettings
- {
- ProfilePath = Directory.GetCurrentDirectory(),
- GeneralConfigPath = Directory.GetCurrentDirectory(),
- ProfileConfigPath = Directory.GetCurrentDirectory()
- };
- Console.WriteLine("Defining Session & ctx");
- var clientSettings = new ClientSettings(setting);
- var logicSettings = new LogicSettings(setting);
- var session = new Session(clientSettings, logicSettings);
- session.Client.ApiFailure = new ApiFailureStrategy(session);
- Console.WriteLine("doing settings");
- var profilePath = Path.Combine(Directory.GetCurrentDirectory());
- var profileConfigPath = Path.Combine(profilePath, "config");
- setting.ProfilePath = profilePath;
- setting.ProfileConfigPath = profileConfigPath;
- setting.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config");
- session.Settings.AuthType = Type;
- session.Settings.PtcUsername = Username;
- session.Settings.PtcPassword = Password;
- session.Settings.DefaultLatitude = Lat;
- session.Settings.DefaultLongitude = Lon;
- session.Settings.DefaultAltitude = Alt;
- setting.Save(profileConfigPath);
- Console.WriteLine(session.Settings.AuthType);
- try
- {
- var ctx = new Client(session.Settings, session.Client.ApiFailure);
- await ctx.Login.DoLogin();
- var profile = await ctx.Player.GetPlayer();
- var inventory = await ctx.Inventory.GetInventory();
- var pokemon = inventory.InventoryDelta.InventoryItems.Select(p => p.InventoryItemData.PokemonData).OrderByDescending(p => p.Cp);
- var mapObjects = await session.Client.Map.GetMapObjects();
- var pokeStops = mapObjects.Item1.MapCells.SelectMany(i => i.Forts)
- .Where(
- i =>
- i.Type == FortType.Checkpoint &&
- i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime() &&
- ( // Make sure PokeStop is within max travel distance, unless it's set to 0.
- LocationUtils.CalculateDistanceInMeters(
- session.Settings.DefaultLatitude, session.Settings.DefaultLongitude,
- i.Latitude, i.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters ||
- session.LogicSettings.MaxTravelDistanceInMeters == 0)
- );
- Console.WriteLine("logged in as : " + profile.PlayerData.Username);
- }
- catch (Exception ex)
- {
- Console.WriteLine("error " + ex.ToString());
- }
- Console.ReadKey();
- }
- public async Task UpdatePos(Client ctx, double lat, double lng)
- {
- var pos = await ctx.Player.UpdatePlayerLocation(lat, lng, Alt);
- Console.WriteLine("Updated Position!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement