コード例 #1
0
        public void PostLoginExecute()
        {
            try
            {
                //update user location on map
                Task.Factory.StartNew(() => Logic.Instance.infoObservable.PushNewGeoLocations(new GeoCoordinate(GlobalVars.latitude, GlobalVars.longitude)));
                GetPlayerResponse profil = objClient.Player.GetPlayer();
                objClient.Inventory.ExportPokemonToCSV(profil.PlayerData);
                Setout.Execute();
                ExecuteFarmingPokestopsAndPokemons(objClient);
            }
            catch (AccessTokenExpiredException)
            {
                throw new AccessTokenExpiredException();
            }
            catch (Exception ex)
            {
                Logger.Error($"Exception: {ex}");

                if (BotSettings.RelocateDefaultLocation)
                {
                    Logger.Info("Detected User Request to Relocate to a new farming spot!");
                }
            }
        }
コード例 #2
0
        private bool CheckAndFarmNearbyPokeStop(FortData pokeStop, Client client, FortDetailsResponse fortInfo)
        {
            if (Setout.count >= 9)
            {
                Setout.Execute();
            }

            if (pokeStop.CooldownCompleteTimestampMs < (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds && BotSettings.FarmPokestops)
            {
                var fortSearch = objClient.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                Logger.Debug("================[VERBOSE LOGGING - Pokestop Search]================");
                Logger.Debug($"Result: {fortSearch.Result}");
                Logger.Debug($"ChainHackSequenceNumber: {fortSearch.ChainHackSequenceNumber}");
                Logger.Debug($"Cooldown Complete (MS): {fortSearch.CooldownCompleteTimestampMs}");
                Logger.Debug($"EXP Award: {fortSearch.ExperienceAwarded}");
                Logger.Debug($"Gems Award: {fortSearch.GemsAwarded}");
                Logger.Debug($"Item Award: {fortSearch.ItemsAwarded}");
                Logger.Debug($"Egg Data: {fortSearch.PokemonDataEgg}");
                Logger.Debug("==================================================================");

                switch (fortSearch.Result.ToString())
                {
                case "NoResultSet":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: We did not recieve a result from the pokestop.");
                    break;

                case "Success":
                    // It already showed our pokestop Information
                    break;

                case "OutOfRange":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: The pokestop is out of range!");
                    break;

                case "InCooldownPeriod":
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Pokestop Warning: The current Pokestop is in the cooldown period.");
                    break;

                case "InventoryFull":
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Pokestop Warning: Your Inventory is full. You did not recieve any items.");
                    break;

                case "ExceededDailyLimit":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: You are above your daily limit of pokestops! You should stop farming pokestops.");
                    break;
                }

                Setout.count++;
                var strDate      = DateTime.Now.ToString("HH:mm:ss");
                var pokeStopInfo = $"{fortInfo.Name}{Environment.NewLine}Visited:{strDate}{Environment.NewLine}";

                if (fortSearch.ExperienceAwarded > 0)
                {
                    var egg = "/";

                    if (fortSearch.PokemonDataEgg != null)
                    {
                        egg = fortSearch.PokemonDataEgg.EggKmWalkedTarget + "km";
                    }

                    var items = "";

                    if (fortSearch.ItemsAwarded != null)
                    {
                        items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded);
                    }

                    var logrestock = false;

                    if (fortSearch.ItemsAwarded != null)
                    {
                        foreach (var item in fortSearch.ItemsAwarded)
                        {
                            if (item.ItemId == ItemId.ItemPokeBall || item.ItemId == ItemId.ItemGreatBall || item.ItemId == ItemId.ItemUltraBall)
                            {
                                logrestock = true;
                            }
                        }

                        if (logrestock && pokeballoutofstock)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Detected Pokeball Restock - Enabling Catch Pokemon");

                            CatchingLogic.AllowCatchPokemon = true;
                            pokeballoutofstock = false;
                        }

                        FailedSoftban = 0;
                        BotStats.AddExperience(fortSearch.ExperienceAwarded);
                        Setout.RefreshConsoleTitle(client);
                        Setout.pokeStopFarmedCount++;
                        Setout.SaveSession();

                        Logger.Info($"Farmed XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Egg: {egg}, Items: {items}");

                        var strItems = items.Replace(",", Environment.NewLine);
                        pokeStopInfo += $"{fortSearch.ExperienceAwarded} XP{Environment.NewLine}{fortSearch.GemsAwarded}{Environment.NewLine}{egg}{Environment.NewLine}{strItems}";

                        Logger.Debug("LureInfo: " + pokeStop.LureInfo);
                        if (pokeStop.LureInfo != null)
                        {
                            var pokedata = new MapPokemon();
                            pokedata.EncounterId           = pokeStop.LureInfo.EncounterId;
                            pokedata.PokemonId             = pokeStop.LureInfo.ActivePokemonId;
                            pokedata.Latitude              = pokeStop.Latitude;
                            pokedata.Longitude             = pokeStop.Longitude;
                            pokedata.ExpirationTimestampMs = pokeStop.LureInfo.LureExpiresTimestampMs;
                            pokedata.SpawnPointId          = pokeStop.LureInfo.FortId;

                            infoObservable.PushNewPokemonLocation(pokedata);
                            Logger.Debug("Lured Pokemon: " + pokedata);

                            if (!BotSettings.catchPokemonSkipList.Contains(pokedata.PokemonId) && GlobalVars.CatchPokemon)
                            {
                                if (!lureEncounters.Contains(pokedata.EncounterId.ToString()))
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Green, "Catching Lured Pokemon");
                                    CatchingLogic.CatchLuredPokemon(pokedata.EncounterId, pokedata.SpawnPointId, pokedata.PokemonId, pokedata.Longitude, pokedata.Latitude);

                                    lureEncounters.Add(pokedata.EncounterId.ToString());
                                }
                                else
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Green, "Skipped Lure Pokemon: " + pokedata.PokemonId + " because we have already caught him, or catching pokemon is disabled");
                                }
                            }
                        }

                        double eggs = 0;

                        if (fortSearch.PokemonDataEgg != null)
                        {
                            eggs = fortSearch.PokemonDataEgg.EggKmWalkedTarget;
                        }

                        Telegram?.sendInformationText(TelegramUtil.TelegramUtilInformationTopics.Pokestop, fortInfo.Name, fortSearch.ExperienceAwarded, eggs, fortSearch.GemsAwarded, StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded));
                    }
                }

                Task.Factory.StartNew(() => infoObservable.PushPokeStopInfoUpdate(pokeStop, pokeStopInfo));

                return(true);
            }

            if (!BotSettings.FarmPokestops)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Farm Pokestop option unchecked, skipping and only looking for pokemon");

                return(false);
            }

            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Pokestop not ready to farm again, skipping and only looking for pokemon");

            return(false);
        }