public static bool CheckIfPokemonBeenCaught(double lat, double lng, PokemonId id, ulong encounterId, ISession session) { if (session.Cache.Get(CatchPokemonTask.GetUsernameGeoLocationCacheKey(session.Settings.Username, id, lat, lng)) != null) { return(true); } if (encounterId > 0 && session.Cache[CatchPokemonTask.GetEncounterCacheKey(encounterId)] != null) { return(true); } return(false); }
public Account FindAvailableAccountForPokemonSwitch(string encounterId) { ISession session = TinyIoCContainer.Current.Resolve <ISession>(); //set current Account switchableAccount = GetSwitchableAccount(null, false); // Don't pause if no switchable account is available. if (switchableAccount != null) { if (session.Cache.GetCacheItem(CatchPokemonTask.GetUsernameEncounterCacheKey(switchableAccount.Username, encounterId)) == null) { // Don't edit the running account until we actually switch. Just return the pending account. return(switchableAccount); } } return(null); }
public async Task <IState> Execute(ISession session, CancellationToken cancellationToken) { //Console.WriteLine($"waiting data....., {data.Count}"); CatchablePokemon pkm = null; var currentLatitude = session.Client.CurrentLatitude; var currentLongitude = session.Client.CurrentLongitude; do { pkm = data.FirstOrDefault(p => !p.Checked && p.ExpiredTime > DateTime.Now && LocationUtils.CalculateDistanceInMeters(currentLatitude, currentLongitude, p.Latitude, p.Longitude) < 100); if (pkm == null) { break; } EncounterResponse encounter; try { //await // LocationUtils.UpdatePlayerLocationWithAltitude(session, // new GeoCoordinate(pkm.Latitude, pkm.Longitude, session.Client.CurrentAltitude), 0); // Set speed to 0 for random speed. await session.Navigation.Move(new MapLocation(pkm.Latitude, pkm.Longitude, session.Client.CurrentAltitude), null, session, cancellationToken); encounter = await session.Client.Encounter.EncounterPokemon(pkm.EncounteredId, pkm.SpawnId); } finally { //await // LocationUtils.UpdatePlayerLocationWithAltitude(session, // new GeoCoordinate(currentLatitude, currentLongitude, session.Client.CurrentAltitude), 0); // Set speed to 0 for random speed. } switch (encounter.Status) { case EncounterResponse.Types.Status.EncounterSuccess: await CatchPokemonTask.Execute(session, cancellationToken, encounter, pkm.ToMapPokemon(), currentFortData : null, sessionAllowTransfer : true); break; case EncounterResponse.Types.Status.PokemonInventoryFull: if (session.LogicSettings.EvolveAllPokemonAboveIv || session.LogicSettings.EvolveAllPokemonWithEnoughCandy || session.LogicSettings.UseLuckyEggsWhileEvolving || session.LogicSettings.KeepPokemonsThatCanEvolve) { await EvolvePokemonTask.Execute(session, cancellationToken); } if (session.LogicSettings.TransferDuplicatePokemon) { await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } else { session.EventDispatcher.Send(new WarnEvent { Message = session.Translation.GetTranslation(TranslationString.InvFullTransferManually) }); } break; default: session.EventDispatcher.Send(new WarnEvent { Message = session.Translation.GetTranslation( TranslationString.EncounterProblem, encounter.Status) }); break; } pkm.Checked = true; await Task.Delay(1000); }while (pkm != null); await Task.Delay(3000); return(this); }