public static async Task CatchWithSnipe(ISession session, CancellationToken cancellationToken, EncounterInfo encounterId) { cancellationToken.ThrowIfCancellationRequested(); await SnipePokemonTask.Snipe(session, new List <PokemonId>() { encounterId.PokemonId }, encounterId.Latitude, encounterId.Longitude, cancellationToken); }
public static async Task CheckMSniperLocation(ISession session, CancellationToken cancellationToken) { try { if (session.LogicSettings.CatchPokemon)//config is checking { string pth = Path.Combine(session.LogicSettings.ProfilePath, "SnipeMS.json"); if (!File.Exists(pth)) { return; } StreamReader sr = new StreamReader(pth, Encoding.UTF8); string jsn = sr.ReadToEnd(); sr.Close(); List <MSniperInfo> MSniperLocation = JsonConvert.DeserializeObject <List <MSniperInfo> >(jsn); File.Delete(pth); foreach (var location in MSniperLocation) { session.EventDispatcher.Send(new SnipeScanEvent { Bounds = new Location(location.Latitude, location.Longitude), PokemonId = location.Id, Source = "MSniper" }); await SnipePokemonTask.Snipe(session, session.LogicSettings.PokemonToSnipe.Pokemon, location.Latitude, location.Longitude, cancellationToken); } } } catch (Exception ex) { session.EventDispatcher.Send(new ErrorEvent { Message = ex.Message }); } }
public static async Task <bool> CatchWithSnipe(ISession session, MSniperInfo2 encounterId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return(await SnipePokemonTask.Snipe( session, new List <PokemonId>() { (PokemonId)encounterId.PokemonId }, encounterId.Latitude, encounterId.Longitude, cancellationToken )); }
public static async Task <bool> CatchWithSnipe(ISession session, MSniperInfo2 encounterId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>().ThrowIfSwitchAccountRequested(); return(await SnipePokemonTask.Snipe( session, new List <PokemonId>() { (PokemonId)encounterId.PokemonId }, encounterId.Latitude, encounterId.Longitude, cancellationToken )); }
public static async Task CheckMSniperLocation(ISession session, CancellationToken cancellationToken) { string pth = Path.Combine(session.LogicSettings.ProfilePath, "SnipeMS.json"); try { if (session.LogicSettings.CatchPokemon == true && session.LogicSettings.SnipeAtPokestops == false && session.LogicSettings.UseSnipeLocationServer == false && session.LogicSettings.EnableHumanWalkingSnipe == false )//extra security { if (!await SnipePokemonTask.CheckPokeballsToSnipe(session.LogicSettings.MinPokeballsWhileSnipe + 1, session, cancellationToken)) { return; } if (!File.Exists(pth)) { return; } StreamReader sr = new StreamReader(pth, Encoding.UTF8); string jsn = sr.ReadToEnd(); sr.Close(); List <MSniperInfo> MSniperLocation = JsonConvert.DeserializeObject <List <MSniperInfo> >(jsn); File.Delete(pth); foreach (var location in MSniperLocation) { session.EventDispatcher.Send(new SnipeScanEvent { Bounds = new Location(location.Latitude, location.Longitude), PokemonId = location.Id, Source = "MSniper" }); await SnipePokemonTask.Snipe(session, session.LogicSettings.PokemonToSnipe.Pokemon, location.Latitude, location.Longitude, cancellationToken); } } } catch (Exception ex) { File.Delete(pth);//fixing deserialize errors ErrorEvent ee = new ErrorEvent { Message = ex.Message }; if (ex.InnerException != null) { ee.Message = ex.InnerException.Message; } session.EventDispatcher.Send(ee); } }