Esempio n. 1
0
        public async Task <IState> Execute(ISession session, CancellationToken cancellationToken)
        {
            if (session.LogicSettings.UseNearActionRandom)
            {
                await HumanRandomActionTask.Execute(session, cancellationToken);
            }
            else
            {
                if (session.LogicSettings.EvolveAllPokemonAboveIv || session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                    session.LogicSettings.UseLuckyEggsWhileEvolving || session.LogicSettings.KeepPokemonsThatCanEvolve)
                {
                    await EvolvePokemonTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.UseEggIncubators)
                {
                    await UseIncubatorsTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.TransferDuplicatePokemon)
                {
                    await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.UseLuckyEggConstantly)
                {
                    await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.UseIncenseConstantly)
                {
                    await UseIncenseConstantlyTask.Execute(session, cancellationToken);
                }

                await GetPokeDexCount.Execute(session, cancellationToken);

                if (session.LogicSettings.RenamePokemon)
                {
                    await RenamePokemonTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.AutoFavoritePokemon)
                {
                    await FavoritePokemonTask.Execute(session, cancellationToken);
                }

                await RecycleItemsTask.Execute(session, cancellationToken);

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

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

            return(this);
        }
Esempio n. 2
0
        public void Run(CancellationToken cancellationToken)
        {
            if (_session.LogicSettings.UseNearActionRandom)
            {
                HumanRandomActionTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            else
            {
                if (_session.LogicSettings.EvolveAllPokemonAboveIv || _session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                    _session.LogicSettings.UseLuckyEggsWhileEvolving || _session.LogicSettings.KeepPokemonsThatCanEvolve)
                {
                    EvolvePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.AutomaticallyLevelUpPokemon)
                {
                    LevelUpPokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.UseLuckyEggConstantly)
                {
                    UseLuckyEggConstantlyTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.UseIncenseConstantly)
                {
                    UseIncenseConstantlyTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.TransferDuplicatePokemon)
                {
                    TransferDuplicatePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.TransferWeakPokemon)
                {
                    TransferWeakPokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.RenamePokemon)
                {
                    RenamePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
                if (_session.LogicSettings.AutoFavoritePokemon)
                {
                    FavoritePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }

                RecycleItemsTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                GetPokeDexCount.Execute(_session, cancellationToken).Wait(cancellationToken);

                if (_session.LogicSettings.UseEggIncubators)
                {
                    UseIncubatorsTask.Execute(_session, cancellationToken).Wait(cancellationToken);
                }
            }

            if (_session.LogicSettings.UseGpxPathing)
            {
                FarmPokestopsGpxTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            else
            {
                FarmPokestopsTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
        }
Esempio n. 3
0
        private async void BtnFavorite_Click(object sender, RoutedEventArgs e)
        {
            var model = DataContext as PokemonListViewModel;

            ulong pokemonId = (ulong)((Button)sender).CommandParameter;
            bool  state     = model.Favorite(pokemonId);

            await FavoritePokemonTask.Execute(Session, pokemonId, !state);
        }
        private void btnFavorite_Click(object sender, RoutedEventArgs e)
        {
            var model = this.DataContext as PokemonListModel;

            ulong pokemonId = (ulong)((Button)sender).CommandParameter;
            bool  state     = model.Favorite(pokemonId);

            Task.Run(async() => { await FavoritePokemonTask.Execute(Session, pokemonId, !state); });
        }
Esempio n. 5
0
        public void Run(CancellationToken cancellationToken)
        {
            if (_session.LogicSettings.TransferDuplicatePokemon)
            {
                EvolvePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            if (_session.LogicSettings.AutomaticallyLevelUpPokemon)
            {
                LevelUpPokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            if (_session.LogicSettings.UseLuckyEggConstantly)
            {
                UseLuckyEggConstantlyTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            if (_session.LogicSettings.UseIncenseConstantly)
            {
                UseIncenseConstantlyTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            GetPokeDexCount.Execute(_session, cancellationToken).Wait(cancellationToken);
            if (_session.LogicSettings.TransferDuplicatePokemon)
            {
                TransferDuplicatePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }

            if (_session.LogicSettings.RenamePokemon)
            {
                RenamePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }

            if (_session.LogicSettings.AutoFavoritePokemon)
            {
                FavoritePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }

            RecycleItemsTask.Execute(_session, cancellationToken).Wait(cancellationToken);

            if (_session.LogicSettings.UseEggIncubators)
            {
                UseIncubatorsTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }

            if (_session.LogicSettings.UseGpxPathing)
            {
                FarmPokestopsGpxTask.Execute(_session, cancellationToken).Wait(cancellationToken);
            }
            else
            {
                FarmPokestopsTask.ExeCuteMyFarm(_session, cancellationToken).Wait(cancellationToken);
            }
        }
Esempio n. 6
0
        public async Task <IState> Execute(ISession session, CancellationToken cancellationToken)
        {
            try
            {
                await CheckChallengeDoneTask.Execute(session, cancellationToken);

                await CheckChallengeTask.Execute(session, cancellationToken);

                if (session.LogicSettings.EvolveAllPokemonAboveIv || session.LogicSettings.EvolveAllPokemonWithEnoughCandy)
                {
                    await EvolvePokemonTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.BeLikeRobot)
                {
                    if (session.LogicSettings.AutoFavoritePokemon)
                    {
                        await FavoritePokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                    {
                        await LevelUpPokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.RenamePokemon)
                    {
                        await RenamePokemonTask.Execute(session, cancellationToken);
                    }

                    await RecycleItemsTask.Execute(session, cancellationToken);
                }
                if (session.LogicSettings.UseEggIncubators)
                {
                    await session.EggWalker.InitEggWalker(cancellationToken);
                }

                if (session.LogicSettings.UseCustomRoute)
                {
                    await FarmPokestopsCustomRouteTask.Execute(session, cancellationToken);
                }
                else
                {
                    if (session.LogicSettings.UseDiscoveryPathing)
                    {
                        await FarmPokeStopsDiscoveryTask.Execute(session, cancellationToken);
                    }
                    else
                    {
                        await FarmPokestopsTask.Execute(session, cancellationToken);
                    }
                }
            }
            catch (PtcOfflineException)
            {
                session.EventDispatcher.Send(new ErrorEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.PtcOffline)
                });
                session.EventDispatcher.Send(new NoticeEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.TryingAgainIn, 20)
                });
                await Task.Delay(20000, cancellationToken);

                return(new LoginState());
            }
            catch (AccessTokenExpiredException)
            {
                session.EventDispatcher.Send(new ErrorEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.AccessTokenExpired)
                });
                session.EventDispatcher.Send(new NoticeEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.TryingAgainIn, 60)
                });
                await Task.Delay(60000, cancellationToken);

                return(new LoginState());
            }
            catch (InvalidResponseException ex)
            {
                session.EventDispatcher.Send(new ErrorEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.NianticServerUnstable)
                });
                Logger.Write("[NIANTIC] " + ex.Message, LogLevel.Error);
                return(this);
            }
            catch (AccountNotVerifiedException)
            {
                session.EventDispatcher.Send(new ErrorEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.AccountNotVerified)
                });
                await Task.Delay(2000, cancellationToken);

                session.EventDispatcher.Send(new BotCompleteFailureEvent
                {
                    Shutdown = false,
                    Stop     = true
                });
            }
            catch (GoogleException e)
            {
                if (e.Message.Contains("NeedsBrowser"))
                {
                    session.EventDispatcher.Send(new ErrorEvent
                    {
                        Message = session.Translation.GetTranslation(TranslationString.GoogleTwoFactorAuth)
                    });
                    session.EventDispatcher.Send(new ErrorEvent
                    {
                        Message = session.Translation.GetTranslation(TranslationString.GoogleTwoFactorAuthExplanation)
                    });
                    await Task.Delay(7000, cancellationToken);

                    try
                    {
                        Process.Start("https://security.google.com/settings/security/apppasswords");
                    }
                    catch (Exception)
                    {
                        session.EventDispatcher.Send(new ErrorEvent
                        {
                            Message = "https://security.google.com/settings/security/apppasswords"
                        });
                        throw;
                    }
                }
                session.EventDispatcher.Send(new ErrorEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.GoogleError)
                });
                await Task.Delay(2000, cancellationToken);

                session.EventDispatcher.Send(new BotCompleteFailureEvent
                {
                    Shutdown = false,
                    Stop     = true
                });
            }

            return(this);
        }
        public async Task <IState> Execute(ISession session, CancellationToken cancellationToken)
        {
            if (session.LogicSettings.TransferDuplicatePokemon)
            {
                await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
            }

            if (session.LogicSettings.TransferDuplicatePokemon)
            {
                await DisplayPokemonStatsTask.WriteHighest(session);
            }

            if (session.LogicSettings.EvolveAllPokemonAboveIv || session.LogicSettings.EvolveAllPokemonWithEnoughCandy)
            {
                await EvolvePokemonTask.Execute(session, cancellationToken);
            }

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

            if (session.LogicSettings.UseLuckyEggConstantly)
            {
                await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
            }

            if (session.LogicSettings.UseIncenseConstantly)
            {
                await UseIncenseConstantlyTask.Execute(session, cancellationToken);
            }

            await GetPokeDexCount.Execute(session, cancellationToken);

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

            if (session.LogicSettings.AutoFavoritePokemon)
            {
                await FavoritePokemonTask.Execute(session, cancellationToken);
            }

            await RecycleItemsTask.Execute(session, cancellationToken);

            if (session.LogicSettings.UseEggIncubators)
            {
                await UseIncubatorsTask.Execute(session, cancellationToken);
            }

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

            return(this);
        }
Esempio n. 8
0
 public async Task Handle(ISession session, WebSocketSession webSocketSession, dynamic message)
 {
     await FavoritePokemonTask.Execute(session, (ulong)message.PokemonId, (bool)message.Favorite);
 }