Ejemplo n.º 1
0
        public async Task <IState> Execute(ISession session, CancellationToken cancellationToken)
        {
            if (session.LogicSettings.UseNearActionRandom)
            {
                await HumanRandomActionTask.Execute(session, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                if (session.LogicSettings.UseEggIncubators)
                {
                    await UseIncubatorsTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }
                if (session.LogicSettings.TransferDuplicatePokemon)
                {
                    await TransferDuplicatePokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }
                if (session.LogicSettings.TransferWeakPokemon)
                {
                    await TransferWeakPokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }
                if (EvolvePokemonTask.IsActivated(session))
                {
                    await EvolvePokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }
                if (session.LogicSettings.UseLuckyEggConstantly)
                {
                    await UseLuckyEggConstantlyTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }
                if (session.LogicSettings.UseIncenseConstantly)
                {
                    await UseIncenseConstantlyTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }

                await GetPokeDexCount.Execute(session, cancellationToken).ConfigureAwait(false);

                if (session.LogicSettings.RenamePokemon)
                {
                    await RenamePokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }

                await RecycleItemsTask.Execute(session, cancellationToken).ConfigureAwait(false);

                if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                {
                    await LevelUpPokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                }
            }

            await SelectBuddyPokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);


            if (session.LogicSettings.UseGpxPathing)
            {
                await FarmPokestopsGpxTask.Execute(session, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await FarmPokestopsTask.Execute(session, cancellationToken).ConfigureAwait(false);
            }

            return(this);
        }
Ejemplo n.º 2
0
        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).ConfigureAwait(false); // Set speed to 0 for random speed.

                    await session.Navigation.Move(
                        new MapLocation(pkm.Latitude, pkm.Longitude, session.Client.CurrentAltitude),
                        null, session, cancellationToken).ConfigureAwait(false);

                    encounter = await session.Client.Encounter.EncounterPokemon(pkm.EncounteredId, pkm.SpawnId).ConfigureAwait(false);
                }
                finally
                {
                    //await
                    //    LocationUtils.UpdatePlayerLocationWithAltitude(session,
                    //        new GeoCoordinate(currentLatitude, currentLongitude, session.Client.CurrentAltitude), 0).ConfigureAwait(false); // 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).ConfigureAwait(false);

                    break;

                case EncounterResponse.Types.Status.PokemonInventoryFull:
                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                    }
                    else
                    {
                        session.EventDispatcher.Send(new WarnEvent
                        {
                            Message = session.Translation.GetTranslation(TranslationString.InvFullTransferManually)
                        });
                    }

                    if (EvolvePokemonTask.IsActivated(session))
                    {
                        await EvolvePokemonTask.Execute(session, cancellationToken).ConfigureAwait(false);
                    }
                    break;

                default:
                    session.EventDispatcher.Send(new WarnEvent
                    {
                        Message =
                            session.Translation.GetTranslation(
                                TranslationString.EncounterProblem, encounter.Status)
                    });
                    break;
                }
                pkm.Checked = true;
                await Task.Delay(1000).ConfigureAwait(false);
            } while (pkm != null);
            await Task.Delay(3000).ConfigureAwait(false);

            return(this);
        }