internal void UpdateWith(IEnumerable <MapCell> mapCells) { var pokestopsFromResponse = mapCells.SelectMany(m => m.Forts).Where(f => f.Type == FortType.Checkpoint).Select(f => new PokestopViewModel(f, session, Player, settings)).ToList(); if (pokestopsFromResponse.Any()) { Pokestops.UpdateWith(pokestopsFromResponse); } var gymsFromResponse = mapCells.SelectMany(m => m.Forts).Where(f => f.Type == FortType.Gym).Select(f => new GymViewModel(f, session)).ToList(); if (gymsFromResponse.Any()) { Gyms.UpdateWith(gymsFromResponse); } var wildPokemonFromResponse = mapCells.SelectMany(m => m.WildPokemons).Select(p => new WildPokemonViewModel(p, settings)).ToList(); if (wildPokemonFromResponse.Any()) { WildPokemon.UpdateWith(wildPokemonFromResponse); } var catchablePokemonFromLure = mapCells.SelectMany(m => m.Forts).Where(f => f.LureInfo != null).Select(f => new MapPokemonViewModel(f, session, settings, player, this)); var catchablePokemonFromResponse = mapCells.SelectMany(m => m.CatchablePokemons).Select(p => new MapPokemonViewModel(p, session, settings, Player, this)); var catchablePokemon = catchablePokemonFromLure.Concat(catchablePokemonFromResponse).ToList(); if (catchablePokemon.Any()) { CatchablePokemon.UpdateWith(catchablePokemon); } }
/// <summary> /// /// </summary> public override void ResetState() { CatchablePokemon.Clear(); NearbyPokemon.Clear(); NearbyPokestops.Clear(); // @robertmclaws: Should we re-initialize the Geolocator here? }
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); }