private static bool SearchThresholdExceeds(ISession session) { if (!session.LogicSettings.UsePokeStopLimit) { return(false); } if (session.Stats.PokeStopTimestamps.Count >= session.LogicSettings.PokeStopLimit) { // delete uesless data int toRemove = session.Stats.PokeStopTimestamps.Count - session.LogicSettings.PokeStopLimit; if (toRemove > 0) { session.Stats.PokeStopTimestamps.RemoveRange(0, toRemove); UpdateTimeStampsPokestop?.Invoke(); } var sec = (DateTime.Now - new DateTime(session.Stats.PokeStopTimestamps.First())).TotalSeconds; var limit = session.LogicSettings.PokeStopLimitMinutes * 60; if (sec < limit) { session.EventDispatcher.Send(new ErrorEvent { Message = session.Translation.GetTranslation(TranslationString.PokeStopExceeds, Math.Round(limit - sec)) }); return(true); } } return(false); }
private static bool SearchThresholdExceeds(ISession session) { if (!session.LogicSettings.UsePokeStopLimit) { return(false); } if (_pokestopLimitReached || _pokestopTimerReached) { return(true); } // Check if user defined max Pokestops reached if (!session.Stats.PokeStopTimestamps.Any()) { return(false); } var timeDiff = (DateTime.Now - new DateTime(session.Stats.PokeStopTimestamps.First())); if (session.Stats.PokeStopTimestamps.Count >= session.LogicSettings.PokeStopLimit) { session.EventDispatcher.Send(new ErrorEvent { Message = session.Translation.GetTranslation(TranslationString.PokestopLimitReached) }); // Check Timestamps & delete older than 24h var TSminus24h = DateTime.Now.AddHours(-24).Ticks; for (int i = 0; i < session.Stats.PokeStopTimestamps.Count; i++) { if (session.Stats.PokeStopTimestamps[i] < TSminus24h) { Logger.Write($"Removing stored Pokestop timestamp {session.Stats.PokeStopTimestamps[i]}", LogLevel.Info); session.Stats.PokeStopTimestamps.Remove(session.Stats.PokeStopTimestamps[i]); } } UpdateTimeStampsPokestop?.Invoke(); _pokestopLimitReached = true; return(true); } // Check if user defined time since start reached else if (timeDiff.TotalSeconds >= session.LogicSettings.PokeStopLimitMinutes * 60) { session.EventDispatcher.Send(new ErrorEvent { Message = session.Translation.GetTranslation(TranslationString.PokestopTimerReached) }); // Check Timestamps & delete older than 24h var TSminus24h = DateTime.Now.AddHours(-24).Ticks; for (int i = 0; i < session.Stats.PokeStopTimestamps.Count; i++) { if (session.Stats.PokeStopTimestamps[i] < TSminus24h) { session.Stats.PokeStopTimestamps.Remove(session.Stats.PokeStopTimestamps[i]); } } UpdateTimeStampsPokestop?.Invoke(); _pokestopTimerReached = true; return(true); } return(false); // Continue running }
private static async Task FarmPokestop(ISession session, FortData pokeStop, FortDetailsResponse fortInfo, CancellationToken cancellationToken, bool doNotRetry = false) { if (pokeStop.CooldownCompleteTimestampMs > DateTime.UtcNow.ToUnixTime()) { return; } FortSearchResponse fortSearch; var timesZeroXPawarded = 0; var fortTry = 0; //Current check const int retryNumber = 50; //How many times it needs to check to clear softban const int zeroCheck = 5; //How many times it checks fort before it thinks it's softban do { cancellationToken.ThrowIfCancellationRequested(); if (SearchThresholdExceeds(session)) { break; } fortSearch = await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0) { timesZeroXPawarded = 0; } if (fortSearch.ExperienceAwarded == 0) { timesZeroXPawarded++; if (timesZeroXPawarded > zeroCheck) { if ((int)fortSearch.CooldownCompleteTimestampMs != 0) { break; // Check if successfully looted, if so program can continue as this was "false alarm". } fortTry += 1; session.EventDispatcher.Send(new FortFailedEvent { Name = fortInfo.Name, Try = fortTry, Max = retryNumber - zeroCheck, Looted = false }); if (doNotRetry) { break; } if (!session.LogicSettings.FastSoftBanBypass) { DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 0); } } } else { if (fortTry != 0) { session.EventDispatcher.Send(new FortFailedEvent { Name = fortInfo.Name, Try = fortTry + 1, Max = retryNumber - zeroCheck, Looted = true }); } session.EventDispatcher.Send(new FortUsedEvent { Id = pokeStop.Id, Name = fortInfo.Name, Exp = fortSearch.ExperienceAwarded, Gems = fortSearch.GemsAwarded, Items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded), Latitude = pokeStop.Latitude, Longitude = pokeStop.Longitude, Altitude = session.Client.CurrentAltitude, InventoryFull = fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull }); if (fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull) { _storeRi = 1; } if (session.LogicSettings.UsePokeStopLimit) { session.Stats.PokeStopTimestamps.Add(DateTime.Now.Ticks); UpdateTimeStampsPokestop?.Invoke(); Logger.Write($"(POKESTOP LIMIT) {session.Stats.PokeStopTimestamps.Count}/{session.LogicSettings.PokeStopLimit}", LogLevel.Info, ConsoleColor.Yellow); } break; //Continue with program as loot was succesfull. } } while (fortTry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed. if (session.LogicSettings.RandomlyPauseAtStops && !doNotRetry) { if (++_randomStop >= _randomNumber) { _randomNumber = _rc.Next(4, 11); _randomStop = 0; int randomWaitTime = _rc.Next(30, 120); await Task.Delay(randomWaitTime, cancellationToken); } } }