private static async Task MoveToPokemon(WildPokemon pokemon, ISession session, CancellationToken cancellationToken)
        {
            //split the way in 5 steps
            var sourceLocation       = new GeoCoordinate(session.Client.CurrentLatitude, session.Client.CurrentLongitude);
            var targetLocation       = new GeoCoordinate(pokemon.Latitude, pokemon.Longitude);
            var distanceToTarget     = LocationUtils.CalculateDistanceInMeters(sourceLocation, new GeoCoordinate(pokemon.Latitude, pokemon.Longitude));
            var nextWaypointDistance = distanceToTarget / 5;
            var nextWaypointBearing  = LocationUtils.DegreeBearing(sourceLocation, targetLocation);
            var waypoint             = LocationUtils.CreateWaypoint(sourceLocation, nextWaypointDistance, nextWaypointBearing);

            for (var i = 0; i < 5; i++)
            {
                await session.Navigation.Move(new GeoCoordinate(waypoint.Latitude, waypoint.Longitude),
                                              session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax,
                                              async() =>
                {
                    // Catch normal map Pokemon
                    await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                    //Catch Incense Pokemon
                    await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                    return(true);
                }, null, cancellationToken, session);

                if (session.MapCache.CheckPokemonCaught(pokemon.EncounterId))
                {
                    return;
                }
                waypoint = LocationUtils.CreateWaypoint(waypoint, nextWaypointDistance, nextWaypointBearing);
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (wildPokemon_ != null)
            {
                hash ^= WildPokemon.GetHashCode();
            }
            if (Background != 0)
            {
                hash ^= Background.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (captureProbability_ != null)
            {
                hash ^= CaptureProbability.GetHashCode();
            }
            if (ActiveItem != 0)
            {
                hash ^= ActiveItem.GetHashCode();
            }
            if (ArplusAttemptsUntilFlee != 0)
            {
                hash ^= ArplusAttemptsUntilFlee.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #3
0
        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);
            }
        }
Example #4
0
 public static void SaveLocations(WildPokemon pokemon, double iv, double probability)
 {
     if (GlobalVars.SaveLocations)
     {
         if (iv >= GlobalVars.MinIVSave)
         {
             var strIV = iv.ToString("0.00");
             var id    = pokemon.EncounterId;
             if (!ExistYet(id))
             {
                 var date         = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                 var LastModified = StringUtils.TimeMStoString(pokemon.LastModifiedTimestampMs, @"mm\:ss");
                 var TillHidden   = StringUtils.TimeMStoString(pokemon.TimeTillHiddenMs, @"mm\:ss");
                 var name         = GlobalVars.ProfileName;
                 var Latitude     = pokemon.Latitude.ToString(CultureInfo.InvariantCulture);
                 var Longitude    = pokemon.Longitude.ToString(CultureInfo.InvariantCulture);
                 var line         = $"{date}|{LastModified}|{id}|{name}|{TillHidden}|{probability}|{strIV}|pokesniper2://{pokemon.PokemonData.PokemonId}/{Latitude},{Longitude}";
                 try
                 {
                     File.AppendAllLines(GlobalVars.SaveLocationsFile, new string[] { line });
                 }
                 catch (Exception)
                 {
                     Logger.Info("Hey pssst. If you get this message follow these steps:");
                     Logger.Info("1. Open your Pokemonlist and go to the Tab 'Options'");
                     Logger.Info("2. Select Misc");
                     Logger.Info("3. Either you press the two dots and select a path...");
                     Logger.Info("4. Or disable the feature...");
                     Logger.Info("5. Dont forget to press Update Config.");
                 }
             }
         }
     }
 }
Example #5
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            var basepk    = new WildPokemon();
            var Trainerpk = new TrainerPokemon();

            StaticData.PlayerData.CurrentParty[0].ActualStats = StaticData.PlayerData.CurrentParty[0].BaseStats + StaticData.PlayerData.CurrentParty[0].Enhancements + StaticData.PlayerData.CurrentParty[0].IVs + StaticData.PlayerData.CurrentParty[0].EVs;
        }
        private static async Task MoveToPokemon(WildPokemon pokemon, ISession session, CancellationToken cancellationToken)
        {
            //split the way in 5 steps
            var sourceLocation       = new GeoCoordinate(session.Client.CurrentLatitude, session.Client.CurrentLongitude);
            var targetLocation       = new GeoCoordinate(pokemon.Latitude, pokemon.Longitude);
            var distanceToTarget     = LocationUtils.CalculateDistanceInMeters(sourceLocation, new GeoCoordinate(pokemon.Latitude, pokemon.Longitude));
            var nextWaypointDistance = distanceToTarget / 5;
            var nextWaypointBearing  = LocationUtils.DegreeBearing(sourceLocation, targetLocation);
            var waypoint             = LocationUtils.CreateWaypoint(sourceLocation, nextWaypointDistance, nextWaypointBearing);

            for (var i = 0; i < 5; i++)
            {
                if (session.MapCache.CheckPokemonCaught(pokemon.EncounterId) || session.ForceMoveJustDone)
                {
                    break;
                }
                await MoveTo(waypoint, session, cancellationToken);

                waypoint = LocationUtils.CreateWaypoint(waypoint, nextWaypointDistance, nextWaypointBearing);
            }
            if (!session.ForceMoveJustDone)
            {
                await MoveTo(sourceLocation, session, cancellationToken);
            }
        }
Example #7
0
 public static string GetDespawnString(WildPokemon pokemon)
 {
     var despawnSeconds = pokemon.TimeTillHiddenMs;
     var despawnMinutes = despawnSeconds / 60;
     despawnSeconds = despawnSeconds % 60;
     return $", despawn in {despawnMinutes} minutes { despawnSeconds} seconds";
 }
Example #8
0
        private async Task <AllEnum.ItemId> GetBestBerry(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = await _inventory.GetItems();

            var berries = items.Where(i => (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemRazzBerry ||
                                      (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemBlukBerry ||
                                      (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemNanabBerry ||
                                      (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemWeparBerry ||
                                      (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemPinapBerry).GroupBy(i => ((AllEnum.ItemId)i.Item_)).ToList();

            if (berries.Count == 0)
            {
                return(AllEnum.ItemId.ItemUnknown);
            }

            var razzBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_RAZZ_BERRY);

            var blukBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_BLUK_BERRY);

            var nanabBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_NANAB_BERRY);

            var weparBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_WEPAR_BERRY);

            var pinapBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_PINAP_BERRY);

            if (pinapBerryCount > 0 && pokemonCp >= 1000)
            {
                return(AllEnum.ItemId.ItemPinapBerry);
            }
            else if (weparBerryCount > 0 && pokemonCp >= 1000)
            {
                return(AllEnum.ItemId.ItemWeparBerry);
            }
            else if (nanabBerryCount > 0 && pokemonCp >= 1000)
            {
                return(AllEnum.ItemId.ItemNanabBerry);
            }

            if (weparBerryCount > 0 && pokemonCp >= 600)
            {
                return(AllEnum.ItemId.ItemWeparBerry);
            }
            else if (nanabBerryCount > 0 && pokemonCp >= 600)
            {
                return(AllEnum.ItemId.ItemNanabBerry);
            }
            else if (blukBerryCount > 0 && pokemonCp >= 600)
            {
                return(AllEnum.ItemId.ItemBlukBerry);
            }

            if (blukBerryCount > 0 && pokemonCp >= 350)
            {
                return(AllEnum.ItemId.ItemBlukBerry);
            }

            return(berries.OrderBy(g => g.Key).First().Key);
        }
Example #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (wildPokemon_ != null)
            {
                hash ^= WildPokemon.GetHashCode();
            }
            if (Background != 0)
            {
                hash ^= Background.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (captureProbability_ != null)
            {
                hash ^= CaptureProbability.GetHashCode();
            }
            if (ActiveItem != 0)
            {
                hash ^= ActiveItem.GetHashCode();
            }
            return(hash);
        }
Example #10
0
 public void MergeFrom(EncounterResponse other)
 {
     if (other == null)
     {
         return;
     }
     if (other.wildPokemon_ != null)
     {
         if (wildPokemon_ == null)
         {
             wildPokemon_ = new global::POGOProtos.Map.Pokemon.WildPokemon();
         }
         WildPokemon.MergeFrom(other.WildPokemon);
     }
     if (other.Background != 0)
     {
         Background = other.Background;
     }
     if (other.Status != 0)
     {
         Status = other.Status;
     }
     if (other.captureProbability_ != null)
     {
         if (captureProbability_ == null)
         {
             captureProbability_ = new global::POGOProtos.Data.Capture.CaptureProbability();
         }
         CaptureProbability.MergeFrom(other.CaptureProbability);
     }
 }
Example #11
0
        private async Task <MiscEnums.Item> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = await _inventory.GetItems();

            var balls = items.Where(i => (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_POKE_BALL ||
                                    (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_MASTER_BALL ||
                                    (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_ULTRA_BALL ||
                                    (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_GREAT_BALL).GroupBy(i => ((MiscEnums.Item)i.Item_)).ToList();

            if (balls.Count == 0)
            {
                return(MiscEnums.Item.ITEM_UNKNOWN);
            }

            var pokeBalls   = balls.Any(g => g.Key == MiscEnums.Item.ITEM_POKE_BALL);
            var greatBalls  = balls.Any(g => g.Key == MiscEnums.Item.ITEM_GREAT_BALL);
            var ultraBalls  = balls.Any(g => g.Key == MiscEnums.Item.ITEM_ULTRA_BALL);
            var masterBalls = balls.Any(g => g.Key == MiscEnums.Item.ITEM_MASTER_BALL);

            if (masterBalls && pokemonCp >= 1500)
            {
                return(MiscEnums.Item.ITEM_MASTER_BALL);
            }
            else if (ultraBalls && pokemonCp >= 1500)
            {
                return(MiscEnums.Item.ITEM_ULTRA_BALL);
            }
            else if (greatBalls && pokemonCp >= 1500)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            if (ultraBalls && pokemonCp >= 1000)
            {
                return(MiscEnums.Item.ITEM_ULTRA_BALL);
            }
            else if (greatBalls && pokemonCp >= 1000)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            if (ultraBalls && pokemonCp >= 600)
            {
                return(MiscEnums.Item.ITEM_ULTRA_BALL);
            }
            else if (greatBalls && pokemonCp >= 600)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            if (greatBalls && pokemonCp >= 350)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            return(balls.OrderBy(g => g.Key).First().Key);
        }
Example #12
0
    public WildPokemon GetRandomPokemonFromList(List <WildPokemon> pokeList)
    {
        WildPokemon poke      = new WildPokemon();
        int         pokeIndex = Random.Range(0, pokeList.Count - 1);

        poke = pokeList[pokeIndex];
        return(poke);
    }
Example #13
0
 public WildPokemonViewModel(WildPokemon pokemon, Settings settings) : base(pokemon.PokemonData, settings)
 {
     EncounterId             = pokemon.EncounterId;
     LastModifiedTimestampMs = pokemon.LastModifiedTimestampMs;
     Position         = new Position2DViewModel(pokemon.Latitude, pokemon.Longitude);
     SpawnpointId     = pokemon.SpawnPointId;
     TimeTillHiddenMs = pokemon.TimeTillHiddenMs;
 }
Example #14
0
        private async Task <MiscEnums.Item> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var pokeBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_POKE_BALL);

            var greatBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_GREAT_BALL);

            var ultraBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_ULTRA_BALL);

            var masterBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_MASTER_BALL);

            if (masterBallsCount > 0 && pokemonCp >= 1000)
            {
                return(MiscEnums.Item.ITEM_MASTER_BALL);
            }
            else if (ultraBallsCount > 0 && pokemonCp >= 1000)
            {
                return(MiscEnums.Item.ITEM_ULTRA_BALL);
            }
            else if (greatBallsCount > 0 && pokemonCp >= 1000)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            if (ultraBallsCount > 0 && pokemonCp >= 600)
            {
                return(MiscEnums.Item.ITEM_ULTRA_BALL);
            }
            else if (greatBallsCount > 0 && pokemonCp >= 600)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            if (greatBallsCount > 0 && pokemonCp >= 350)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }

            if (pokeBallsCount > 0)
            {
                return(MiscEnums.Item.ITEM_POKE_BALL);
            }
            if (greatBallsCount > 0)
            {
                return(MiscEnums.Item.ITEM_GREAT_BALL);
            }
            if (ultraBallsCount > 0)
            {
                return(MiscEnums.Item.ITEM_ULTRA_BALL);
            }
            if (masterBallsCount > 0)
            {
                return(MiscEnums.Item.ITEM_MASTER_BALL);
            }

            return(MiscEnums.Item.ITEM_POKE_BALL);
        }
Example #15
0
        public async Task <ItemId> GetBestBall(WildPokemon pokemon, Inventory inventory)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var pokeBallsCount = await InventoryExtender.GetItemAmountByType(ItemId.ItemPokeBall, inventory);

            var greatBallsCount = await InventoryExtender.GetItemAmountByType(ItemId.ItemGreatBall, inventory);

            var ultraBallsCount = await InventoryExtender.GetItemAmountByType(ItemId.ItemUltraBall, inventory);

            var masterBallsCount = await InventoryExtender.GetItemAmountByType(ItemId.ItemMasterBall, inventory);

            if (masterBallsCount > 0 && pokemonCp >= HIGH_POKEMON_CP)
            {
                return(ItemId.ItemMasterBall);
            }
            if (ultraBallsCount > 0 && pokemonCp >= HIGH_POKEMON_CP)
            {
                return(ItemId.ItemUltraBall);
            }
            if (greatBallsCount > 0 && pokemonCp >= HIGH_POKEMON_CP)
            {
                return(ItemId.ItemGreatBall);
            }

            if (ultraBallsCount > 0 && pokemonCp >= MIDIUM_POKEMON_CP)
            {
                return(ItemId.ItemUltraBall);
            }
            if (greatBallsCount > 0 && pokemonCp >= MIDIUM_POKEMON_CP)
            {
                return(ItemId.ItemGreatBall);
            }

            if (greatBallsCount > 0 && pokemonCp >= LOWER_POKEMON_CP)
            {
                return(ItemId.ItemGreatBall);
            }

            if (pokeBallsCount > 0)
            {
                return(ItemId.ItemPokeBall);
            }
            if (greatBallsCount > 0)
            {
                return(ItemId.ItemGreatBall);
            }
            if (ultraBallsCount > 0)
            {
                return(ItemId.ItemUltraBall);
            }
            if (masterBallsCount > 0)
            {
                return(ItemId.ItemMasterBall);
            }

            return(ItemId.ItemPokeBall);
        }
Example #16
0
        private async Task <ItemId> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;


            await RecycleItems(true);

            var items = await _client.Inventory.GetItems();

            var balls = items.Where(i => ((ItemId)i.ItemId == ItemId.ItemPokeBall ||
                                          (ItemId)i.ItemId == ItemId.ItemGreatBall ||
                                          (ItemId)i.ItemId == ItemId.ItemUltraBall ||
                                          (ItemId)i.ItemId == ItemId.ItemMasterBall) && i.ItemId > 0).GroupBy(i => ((ItemId)i.ItemId)).ToList();

            if (balls.Count() == 0)
            {
                return(ItemId.ItemUnknown);
            }



            var pokeBalls   = balls.Any(g => g.Key == ItemId.ItemPokeBall);
            var greatBalls  = balls.Any(g => g.Key == ItemId.ItemGreatBall);
            var ultraBalls  = balls.Any(g => g.Key == ItemId.ItemUltraBall);
            var masterBalls = balls.Any(g => g.Key == ItemId.ItemMasterBall);

            if (masterBalls && pokemonCp >= 2000)
            {
                return(ItemId.ItemMasterBall);
            }
            else if (ultraBalls && pokemonCp >= 2000)
            {
                return(ItemId.ItemUltraBall);
            }
            else if (greatBalls && pokemonCp >= 2000)
            {
                return(ItemId.ItemGreatBall);
            }

            if (ultraBalls && pokemonCp >= 1000)
            {
                return(ItemId.ItemUltraBall);
            }
            else if (greatBalls && pokemonCp >= 1000)
            {
                return(ItemId.ItemGreatBall);
            }

            if (greatBalls && pokemonCp >= 500)
            {
                return(ItemId.ItemGreatBall);
            }

            return(balls.OrderBy(c => c.Key).First().Key);
        }
Example #17
0
        public SpawnedPokemon(WildPokemon wildPokemon, string instanceName) : this(instanceName)
        {
            this.PokemonID    = wildPokemon.PokemonData.PokemonId;
            this.EncounterID  = wildPokemon.EncounterId.ToString();
            this.SpawnPointID = wildPokemon.SpawnPointId;

            this.Latitude  = wildPokemon.Latitude;
            this.Longitude = wildPokemon.Longitude;

            this.Despawn = DateTime.Now.AddMilliseconds(wildPokemon.TimeTillHiddenMs);
        }
            public Sir0 ToSir0()
            {
                var sir0 = new Sir0Builder(8);

                void align(int length)
                {
                    var paddingLength = length - (sir0.Length % length);

                    if (paddingLength != length)
                    {
                        sir0.WritePadding(sir0.Length, paddingLength);
                    }
                }

                var floorInfoPointer = sir0.Length;

                foreach (var floor in FloorInfos)
                {
                    sir0.Write(sir0.Length, floor.ToByteArray());
                }

                align(16);
                var wildPokemonPointer = sir0.Length;

                if (WildPokemon != null)
                {
                    sir0.Write(sir0.Length, WildPokemon.ToSir0().Data.ReadArray());
                }

                align(16);
                var data3Pointer = sir0.Length;

                if (Data3 != null)
                {
                    sir0.Write(sir0.Length, Data3.ToSir0().Data.ReadArray());
                }

                align(16);
                var data4Pointer = sir0.Length;

                if (Data4 != null)
                {
                    sir0.Write(sir0.Length, Data4.ToSir0().Data.ReadArray());
                }

                // Write the content header
                align(16);
                sir0.SubHeaderOffset = sir0.Length;
                sir0.WritePointer(sir0.Length, floorInfoPointer);
                sir0.WritePointer(sir0.Length, wildPokemonPointer);
                sir0.WritePointer(sir0.Length, data3Pointer);
                sir0.WritePointer(sir0.Length, data4Pointer);
                return(sir0.Build());
            }
Example #19
0
    public Pokemon GetRandomEncounter(EncounterTypes type)
    {
        float       roll  = Random.Range(0.0f, 1.0f);
        WildPokemon match = null;

        // Set the match variable
        if (type == EncounterTypes.Roam)
        {
            if (roll < global.extremelyRareEncounterRate)
            {
                if (roamExtremelyRare.Length > 0)
                {
                    match = roamExtremelyRare[Random.Range(0, roamExtremelyRare.Length)];
                }
            }
            else if (roll < global.veryRareEncounterRate)
            {
                if (roamVeryRare.Length > 0)
                {
                    match = roamVeryRare[Random.Range(0, roamVeryRare.Length)];
                }
            }
            else if (roll < global.rareEncounterRate)
            {
                if (roamRare.Length > 0)
                {
                    match = roamRare[Random.Range(0, roamRare.Length)];
                }
            }
            else if (roll < global.uncommonEncounterRate)
            {
                if (roamUncommon.Length > 0)
                {
                    match = roamUncommon[Random.Range(0, roamUncommon.Length)];
                }
            }
            else
            {
                match = roamCommon[Random.Range(0, roamCommon.Length)];
            }
        }

        if (match == null)
        {
            match = roamCommon[Random.Range(0, roamCommon.Length)];
        }

        return(new Pokemon(
                   match.ID,
                   Pokemon.Gender.CALCULATE,
                   Random.Range(match.minLevel, match.maxLevel + 1),
                   Pokemon.Ball.POKE, null, null, -1));
    }
Example #20
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (WildPokemon != 0)
            {
                hash ^= WildPokemon.GetHashCode();
            }
            if (Fort != 0)
            {
                hash ^= Fort.GetHashCode();
            }
            if (FortsNearby != 0)
            {
                hash ^= FortsNearby.GetHashCode();
            }
            return(hash);
        }
Example #21
0
        private static async Task <bool> EncounterPokemon(WildPokemon pokemon, ItemId pokebolaId, ItemId berryId)
        {
            var encounterResponse =
                await PogoGlobalSettings.PogoClient.Encounter.EncounterPokemon(pokemon.EncounterId,
                                                                               pokemon.SpawnPointId);

            switch (encounterResponse.Status)
            {
            case EncounterResponse.Types.Status.EncounterAlreadyHappened:
                _sayLog.Warn("Não conseguimos iniciar o processo de captura pois o mesmo já ocorreu.");
                return(false);

            case EncounterResponse.Types.Status.PokemonInventoryFull:
                _sayLog.Warn("Não é possível capturar, pois sua mochila de Pokémon está cheia");
                return(false);

            case EncounterResponse.Types.Status.EncounterClosed:
                _sayLog.Warn("Não é possível mais realizar o inicio de captura para este pokemon.");
                return(false);

            case EncounterResponse.Types.Status.EncounterNotFound:
                _sayLog.Warn("Não encontramos o Pokémon para iniciar o processo de captura");
                return(false);

            case EncounterResponse.Types.Status.EncounterNotInRange:
                _sayLog.Warn("Não foi possível iniciar o processo de captura pois o Pokémon está muito longe");
                return(false);

            case EncounterResponse.Types.Status.EncounterError:
                _sayLog.Warn("Não foi possivel capturar o Pokémon, pois ocorreu um erro desconhecido.");
                return(false);

            case EncounterResponse.Types.Status.EncounterPokemonFled:
                _sayLog.Fatal("O Pokémon fugiu e não foi possível iniciar o processo de captura");
                return(false);

            case EncounterResponse.Types.Status.EncounterSuccess:
                _sayLog.Info("Batalha contra o Pokémon iniciada.");
                //Inicia captura
                return(await CatchPokemon(encounterResponse.WildPokemon, pokebolaId, berryId));
            }
            return(false);
        }
 public void MergeFrom(EncounterResponse other)
 {
     if (other == null)
     {
         return;
     }
     if (other.wildPokemon_ != null)
     {
         if (wildPokemon_ == null)
         {
             wildPokemon_ = new global::POGOProtos.Map.Pokemon.WildPokemon();
         }
         WildPokemon.MergeFrom(other.WildPokemon);
     }
     if (other.Background != 0)
     {
         Background = other.Background;
     }
     if (other.Status != 0)
     {
         Status = other.Status;
     }
     if (other.captureProbability_ != null)
     {
         if (captureProbability_ == null)
         {
             captureProbability_ = new global::POGOProtos.Data.Capture.CaptureProbability();
         }
         CaptureProbability.MergeFrom(other.CaptureProbability);
     }
     if (other.ActiveItem != 0)
     {
         ActiveItem = other.ActiveItem;
     }
     if (other.ArplusAttemptsUntilFlee != 0)
     {
         ArplusAttemptsUntilFlee = other.ArplusAttemptsUntilFlee;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Example #23
0
        //Evaluate if a pokemon is worth tweeting about.
        private static FoundPokemon ProcessPokemon(WildPokemon pokemon, Queue <FoundPokemon> alreadyFound, DateTime lastTweet)
        {
            FoundPokemon foundPokemon = new FoundPokemon
            {
                Location = new Location {
                    Latitude = pokemon.Latitude, Longitude = pokemon.Longitude
                },
                Kind           = pokemon.PokemonData.PokemonId,
                LifeExpectancy = pokemon.TimeTillHiddenMs / 1000
            };

            if ((s_config.ExcludedPokemon.Contains(foundPokemon.Kind) && !(s_currentScan.Inclusions != null && s_currentScan.Inclusions.Contains(foundPokemon.Kind))) || (s_currentScan.Exclusions != null && s_currentScan.Exclusions.Contains(foundPokemon.Kind)))
            {
                PokewatchLogger.Log($"[!]Excluded: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}", AccountManager.GetAccountName(s_account));
                return(null);
            }

            if (foundPokemon.LifeExpectancy < s_config.MinimumLifeExpectancy || foundPokemon.LifeExpectancy > 1000)
            {
                PokewatchLogger.Log($"[!]Expiring: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}", AccountManager.GetAccountName(s_account));
                return(null);
            }

            if (alreadyFound.Contains(foundPokemon))
            {
                PokewatchLogger.Log($"[!]Duplicate: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}", AccountManager.GetAccountName(s_account));
                return(null);
            }

            if ((lastTweet + TimeSpan.FromSeconds(s_config.RateLimit) > DateTime.Now) && !s_config.PriorityPokemon.Contains(foundPokemon.Kind))
            {
                PokewatchLogger.Log($"[!]Limiting: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}", AccountManager.GetAccountName(s_account));
                return(null);
            }

            PokewatchLogger.Log($"[!]Tweeting: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}", AccountManager.GetAccountName(s_account));
            return(foundPokemon);
        }
Example #24
0
        private async Task <ItemId> GetBestBerry(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = await _inventory.GetItems();

            var berries = items.Where(i => (ItemId)i.Item_ == ItemId.ItemRazzBerry ||
                                      (ItemId)i.Item_ == ItemId.ItemBlukBerry ||
                                      (ItemId)i.Item_ == ItemId.ItemNanabBerry ||
                                      (ItemId)i.Item_ == ItemId.ItemWeparBerry ||
                                      (ItemId)i.Item_ == ItemId.ItemPinapBerry).GroupBy(i => (ItemId)i.Item_).ToList();

            if (berries.Count == 0)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"No Berrys to select!", LogLevel.Info);
                return(ItemId.ItemUnknown);
            }

            var razzBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_RAZZ_BERRY);

            var blukBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_BLUK_BERRY);

            var nanabBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_NANAB_BERRY);

            var weparBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_WEPAR_BERRY);

            var pinapBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_PINAP_BERRY);

            if (pinapBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemPinapBerry);
            }
            else if (weparBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemWeparBerry);
            }
            else if (nanabBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemNanabBerry);
            }
            else if (nanabBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemBlukBerry);
            }

            if (weparBerryCount > 0 && pokemonCp >= 1500)
            {
                return(ItemId.ItemWeparBerry);
            }
            else if (nanabBerryCount > 0 && pokemonCp >= 1500)
            {
                return(ItemId.ItemNanabBerry);
            }
            else if (blukBerryCount > 0 && pokemonCp >= 1500)
            {
                return(ItemId.ItemBlukBerry);
            }

            if (nanabBerryCount > 0 && pokemonCp >= 1000)
            {
                return(ItemId.ItemNanabBerry);
            }
            else if (blukBerryCount > 0 && pokemonCp >= 1000)
            {
                return(ItemId.ItemBlukBerry);
            }

            if (blukBerryCount > 0 && pokemonCp >= 500)
            {
                return(ItemId.ItemBlukBerry);
            }

            return(berries.OrderBy(g => g.Key).First().Key);
        }
Example #25
0
        private static ItemId GetBestBall(WildPokemon pokemon, bool escaped)
        {
            //pokemon cp to determine ball type
            var pokemonCp          = pokemon?.PokemonData?.Cp;
            var pokeballCollection = GetPokeballQty();

            #region Set Available ball types

            var pokeBalls    = false;
            var greatBalls   = false;
            var ultraBalls   = false;
            var masterBalls  = false;
            var pokeballqty  = 0;
            var greatballqty = 0;
            var ultraballqty = 0;

            foreach (var pokeballtype in pokeballCollection)
            {
                switch (pokeballtype.Key)
                {
                case "pokeBalls":
                    pokeballqty = pokeballtype.Value;
                    break;

                case "greatBalls":
                    greatballqty = pokeballtype.Value;
                    break;

                case "ultraBalls":
                    ultraballqty = pokeballtype.Value;
                    break;
                }
            }
            if (pokeballCollection.ContainsKey("pokeBalls"))
            {
                pokeBalls  = true;
                pokeBalls &= (pokeballqty > GlobalVars.InventoryBasePokeball && GlobalVars.InventoryBasePokeball != 0) || !GlobalVars.LimitPokeballUse;
            }
            if (pokeballCollection.ContainsKey("greatBalls"))
            {
                greatBalls  = true;
                greatBalls &= (greatballqty > GlobalVars.InventoryBaseGreatball && GlobalVars.InventoryBaseGreatball != 0) || !GlobalVars.LimitGreatballUse;
            }

            if (pokeballCollection.ContainsKey("ultraBalls"))
            {
                ultraBalls  = true;
                ultraBalls &= (ultraballqty > GlobalVars.InventoryBaseUltraball && GlobalVars.InventoryBaseUltraball != 0) || !GlobalVars.LimitUltraballUse;
            }

            masterBalls |= pokeballCollection.ContainsKey("masterBalls");

            #endregion

            #region Get Lowest Appropriate Ball by CP and escape status

            var lowestAppropriateBall = ItemId.ItemUnknown;

            var minCPforGreatBall = 500;
            var minCPforUltraBall = 1000;

            if (GlobalVars.MinCPforGreatBall > 0 && GlobalVars.MinCPforUltraBall > 0 && GlobalVars.MinCPforGreatBall < GlobalVars.MinCPforUltraBall)
            {
                minCPforGreatBall = GlobalVars.MinCPforGreatBall;
                minCPforUltraBall = GlobalVars.MinCPforUltraBall;
            }

            var getMyLowestAppropriateBall = new Dictionary <Func <int?, bool>, Action>
            {
                { x => x < minCPforGreatBall, () => lowestAppropriateBall = ItemId.ItemPokeBall }, { x => x < minCPforUltraBall, () => lowestAppropriateBall = ItemId.ItemGreatBall }, { x => x < 2000, () => lowestAppropriateBall = ItemId.ItemUltraBall }, { x => x >= 2000, () => lowestAppropriateBall = ItemId.ItemMasterBall }
            };
            getMyLowestAppropriateBall.First(sw => sw.Key(pokemonCp)).Value();
            //use next best ball if pokemon has escped before
            if (escaped && GlobalVars.NextBestBallOnEscape)
            {
                switch (lowestAppropriateBall)
                {
                case ItemId.ItemGreatBall:
                    lowestAppropriateBall = ItemId.ItemUltraBall;
                    break;

                case ItemId.ItemUltraBall:
                    lowestAppropriateBall = ItemId.ItemMasterBall;
                    break;

                case ItemId.ItemMasterBall:
                    lowestAppropriateBall = ItemId.ItemMasterBall;
                    break;

                default:
                    lowestAppropriateBall = ItemId.ItemGreatBall;
                    break;
                }
            }
            //handle appropriate ball out of stock
            switch (lowestAppropriateBall)
            {
            case ItemId.ItemGreatBall:
                if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                if (masterBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                return(pokeBalls ? ItemId.ItemPokeBall : ItemId.ItemUnknown);

            case ItemId.ItemUltraBall:
                if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                if (masterBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                return(pokeBalls ? ItemId.ItemPokeBall : ItemId.ItemUnknown);

            case ItemId.ItemMasterBall:
                if (masterBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                return(pokeBalls ? ItemId.ItemPokeBall : ItemId.ItemUnknown);

            default:
                if (pokeBalls)
                {
                    return(ItemId.ItemPokeBall);
                }
                if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                return(pokeBalls ? ItemId.ItemMasterBall : ItemId.ItemUnknown);
            }

            #endregion
        }
Example #26
0
        public static string FormatMessage(WildPokemon wildPokemon, double dbliv, double probability)
        {
            PokemonData pokemonData = wildPokemon?.PokemonData;
            var         iv          = (int)dbliv;
            var         ivIcon      = (iv >= 90 ? iv == 100 ? ":100:" : ":ok_hand:" : "");
            var         prob        = (int)probability;
            var         cp          = pokemonData.Cp;
            var         level       = PokemonInfo.GetLevel(pokemonData);
            var         gender      = "";
            var         genderIcon  = "";

            if (pokemonData.PokemonDisplay.Gender == Gender.Male)
            {
                genderIcon = "♂";
                gender     = " " + pokemonData.PokemonDisplay.Gender;
            }
            else if (pokemonData.PokemonDisplay.Gender == Gender.Female)
            {
                genderIcon = "♀";
                gender     = " " + pokemonData.PokemonDisplay.Gender;
            }
            var form = "";

            if (pokemonData.PokemonDisplay.Form != Form.Unset)
            {
                form = $" ({pokemonData.PokemonDisplay.Form})";
                form = form.Replace("Unown", "");
            }
            var costume    = pokemonData.PokemonDisplay.Costume.ToString();
            var address    = LocationUtils.FindAddress(wildPokemon.Latitude, wildPokemon.Longitude);
            var despawn    = StringUtils.TimeMStoString(wildPokemon.LastModifiedTimestampMs, @"mm\:ss");
            var tillhidden = StringUtils.TimeMStoString(wildPokemon.TimeTillHiddenMs, @"mm\:ss");
            var move1      = pokemonData.Move1;
            var move2      = pokemonData.Move2;
            var shiny      = (pokemonData.PokemonDisplay.Shiny?"shiny":"");

            var shinyIcon = (shiny == "")?"":"✵";


            var message = "{EncounterId}= {ivIcon} {shinyIcon}**{name}**{genderIcon}{form} {lat}, {lon} ({address}) IV: {iv}% LV: {level} **CP: {cp}**{gender} {move1}/{move2} Costume: {costume} Prob: {prob}% {despawn} {tillhidden} {shiny}";

            message = message.Replace("{EncounterId}", "" + wildPokemon.EncounterId);
            message = message.Replace("{name}", "" + pokemonData.PokemonId);
            message = message.Replace("{iv}", "" + iv);
            message = message.Replace("{ivIcon}", "" + ivIcon);
            message = message.Replace("{prob}", "" + prob);
            message = message.Replace("{cp}", "" + cp);

            message = message.Replace("{level}", "" + level);
            message = message.Replace("{gender}", "" + gender);
            message = message.Replace("{genderIcon}", "" + genderIcon);
            message = message.Replace("{form}", "" + form);
            message = message.Replace("{costume}", "" + costume);

            message = message.Replace("{lat}", "" + wildPokemon.Latitude.ToString(CultureInfo.InvariantCulture));
            message = message.Replace("{lon}", "" + wildPokemon.Longitude.ToString(CultureInfo.InvariantCulture));
            message = message.Replace("{address}", "" + address);

            message = message.Replace("{despawn}", "" + despawn);
            message = message.Replace("{tillhidden}", "" + tillhidden);
            message = message.Replace("{move1}", "" + move1);
            message = message.Replace("{move2}", "" + move2);
            message = message.Replace("{shiny}", "" + shiny);
            message = message.Replace("{shinyIcon}", "" + shinyIcon);
            return(message);
        }
Example #27
0
        private async Task<ItemId> GetBestBerry(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = await _inventory.GetItems();
            var berries = items.Where(i => (ItemId)i.Item_ == ItemId.ItemRazzBerry
                                        || (ItemId)i.Item_ == ItemId.ItemBlukBerry
                                        || (ItemId)i.Item_ == ItemId.ItemNanabBerry
                                        || (ItemId)i.Item_ == ItemId.ItemWeparBerry
                                        || (ItemId)i.Item_ == ItemId.ItemPinapBerry).GroupBy(i => ((ItemId)i.Item_)).ToList();
            if (berries.Count == 0 || pokemonCp <= 350) return ItemId.ItemUnknown;

            var razzBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_RAZZ_BERRY);
            var blukBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_BLUK_BERRY);
            var nanabBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_NANAB_BERRY);
            var weparBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_WEPAR_BERRY);
            var pinapBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_PINAP_BERRY);

            if (pinapBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemPinapBerry;
            else if (weparBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemWeparBerry;
            else if (nanabBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemNanabBerry;
            else if (nanabBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemBlukBerry;

            if (weparBerryCount > 0 && pokemonCp >= 1500)
                return ItemId.ItemWeparBerry;
            else if (nanabBerryCount > 0 && pokemonCp >= 1500)
                return ItemId.ItemNanabBerry;
            else if (blukBerryCount > 0 && pokemonCp >= 1500)
                return ItemId.ItemBlukBerry;

            if (nanabBerryCount > 0 && pokemonCp >= 1000)
                return ItemId.ItemNanabBerry;
            else if (blukBerryCount > 0 && pokemonCp >= 1000)
                return ItemId.ItemBlukBerry;

            if (blukBerryCount > 0 && pokemonCp >= 500)
                return ItemId.ItemBlukBerry;

            return berries.OrderBy(g => g.Key).First().Key;
        }
Example #28
0
        private async Task<MiscEnums.Item> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = await _inventory.GetItemsNonCache();
            var balls = items.Where(i => ((MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_POKE_BALL
                                      || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_GREAT_BALL
                                      || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_ULTRA_BALL
                                      || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_MASTER_BALL) && i.Count > 0).GroupBy(i => ((MiscEnums.Item)i.Item_)).ToList();
            if (balls.Count == 0) return MiscEnums.Item.ITEM_UNKNOWN;

            var pokeBalls = balls.Any(g => g.Key == MiscEnums.Item.ITEM_POKE_BALL);
            var greatBalls = balls.Any(g => g.Key == MiscEnums.Item.ITEM_GREAT_BALL);
            var ultraBalls = balls.Any(g => g.Key == MiscEnums.Item.ITEM_ULTRA_BALL);
            var masterBalls = balls.Any(g => g.Key == MiscEnums.Item.ITEM_MASTER_BALL);

            if (masterBalls && pokemonCp >= 2000)
                return MiscEnums.Item.ITEM_MASTER_BALL;
            else if (ultraBalls && pokemonCp >= 2000)
                return MiscEnums.Item.ITEM_ULTRA_BALL;
            else if (greatBalls && pokemonCp >= 2000)
                return MiscEnums.Item.ITEM_GREAT_BALL;

            if (ultraBalls && pokemonCp >= 1000)
                return MiscEnums.Item.ITEM_ULTRA_BALL;
            else if (greatBalls && pokemonCp >= 1000)
                return MiscEnums.Item.ITEM_GREAT_BALL;

            if (greatBalls && pokemonCp >= 500)
                return MiscEnums.Item.ITEM_GREAT_BALL;

            return balls.OrderBy(g => g.Key).First().Key;
        }
Example #29
0
        private async Task<ItemId> GetBestBerry(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = await _client.Inventory.GetItems();
            var berries = items.Where(i => (ItemId)i.ItemId == ItemId.ItemRazzBerry
                                        || (ItemId)i.ItemId == ItemId.ItemBlukBerry
                                        || (ItemId)i.ItemId == ItemId.ItemNanabBerry
                                        || (ItemId)i.ItemId == ItemId.ItemWeparBerry
                                        || (ItemId)i.ItemId == ItemId.ItemPinapBerry).GroupBy(i => (ItemId)i.ItemId).ToList();
            if (berries.Count() == 0)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"No Berrys to select!", LogLevel.Info);
                return ItemId.ItemUnknown;
            }

            var razzBerryCount = await _client.Inventory.GetItemAmountByType(ItemId.ItemRazzBerry);
            var blukBerryCount = await _client.Inventory.GetItemAmountByType(ItemId.ItemBlukBerry);
            var nanabBerryCount = await _client.Inventory.GetItemAmountByType(ItemId.ItemNanabBerry);
            var weparBerryCount = await _client.Inventory.GetItemAmountByType(ItemId.ItemWeparBerry);
            var pinapBerryCount = await _client.Inventory.GetItemAmountByType(ItemId.ItemPinapBerry);

            if (pinapBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemPinapBerry;
            else if (weparBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemWeparBerry;
            else if (nanabBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemNanabBerry;
            else if (nanabBerryCount > 0 && pokemonCp >= 2000)
                return ItemId.ItemBlukBerry;

            if (weparBerryCount > 0 && pokemonCp >= 1500)
                return ItemId.ItemWeparBerry;
            else if (nanabBerryCount > 0 && pokemonCp >= 1500)
                return ItemId.ItemNanabBerry;
            else if (blukBerryCount > 0 && pokemonCp >= 1500)
                return ItemId.ItemBlukBerry;

            if (nanabBerryCount > 0 && pokemonCp >= 1000)
                return ItemId.ItemNanabBerry;
            else if (blukBerryCount > 0 && pokemonCp >= 1000)
                return ItemId.ItemBlukBerry;

            if (blukBerryCount > 0 && pokemonCp >= 500)
                return ItemId.ItemBlukBerry;

            return berries.OrderBy(g => g.Key).First().Key;
        }
Example #30
0
        private static async Task <bool> CatchPokemon(WildPokemon pokemon, ItemId pokebola, ItemId berry)
        {
            if (berry != ItemId.ItemUnknown)
            {
                if (berry == ItemId.ItemGoldenRazzBerry || berry == ItemId.ItemGoldenNanabBerry ||
                    berry == ItemId.ItemGoldenPinapBerry)
                {
                    var useItemResponse =
                        await PogoGlobalSettings.PogoClient.Inventory.UseRareCandy(SelectBerry(berry),
                                                                                   pokemon.PokemonData.PokemonId);


                    if (useItemResponse.Result == UseItemRareCandyResponse.Types.Result.Success)
                    {
                        _sayLog.Info($"{berry} Utilizada!");
                    }
                    else
                    {
                        _sayLog.Error($"Erro ao utilizar {berry}.");
                    }
                }
                else
                {
                    var useItemResponse = await PogoGlobalSettings.PogoClient.Encounter.UseCaptureItem(pokemon.EncounterId, SelectBerry(berry),
                                                                                                       pokemon.SpawnPointId);

                    if (useItemResponse.Success)
                    {
                        _sayLog.Info($"{berry} Utilizada!");
                    }
                    else
                    {
                        _sayLog.Error($"Erro ao utilizar {berry}.");
                    }
                }
            }

            _sayLog.Info($"Arremesando ({pokebola}) no Pokemon {pokemon.PokemonData.PokemonId}");

            var catchPokemonResponse = await PogoGlobalSettings.PogoClient.Encounter.CatchPokemon(pokemon.EncounterId,
                                                                                                  pokemon.SpawnPointId,
                                                                                                  SelectPokeball(pokebola));

            switch (catchPokemonResponse.Status)
            {
            case CatchPokemonResponse.Types.CatchStatus.CatchError:
                _sayLog.Warn("Ocorreu um erro desconhecido ao tentar capturar o Pokémon.");
                await PokemonRaro.PokemonRaro.PokemonCaughtFail();

                return(false);

            case CatchPokemonResponse.Types.CatchStatus.CatchFlee:
                _sayLog.Error($"{pokemon.PokemonData.PokemonId} Fugiu ):!\n" +
                              $"CP: {pokemon.PokemonData.Cp}\n" +
                              $"IV: {Iv(pokemon.PokemonData.IndividualAttack, pokemon.PokemonData.IndividualDefense, pokemon.PokemonData.IndividualStamina):0.##}\n" +
                              $"Moves: ({pokemon.PokemonData.Move1},{pokemon.PokemonData.Move2})");
                await PokemonRaro.PokemonRaro.PokemonCaughtFail();

                return(false);

            case CatchPokemonResponse.Types.CatchStatus.CatchSuccess:
                LastCatchName = pokemon.PokemonData.PokemonId.ToString();
                LastCatchInfo =
                    string.Format(
                        $"[CP:{pokemon.PokemonData.Cp}]-[IV:{Iv(pokemon.PokemonData.IndividualAttack, pokemon.PokemonData.IndividualDefense, pokemon.PokemonData.IndividualStamina):0.##}]");
                LastCatchDate   = DateTime.Now;
                LastCatchNumber = (int)Enum.Parse(typeof(PokemonId), pokemon.PokemonData.PokemonId.ToString());
                LastCatchLat    = pokemon.Latitude.ToString();
                LastCatchLong   = pokemon.Longitude.ToString();

                await PokemonRaro.PokemonRaro.SendPokemonLogToDatabase();

                await PokemonRaro.PokemonRaro.PokemonCaughtSucess();

                _sayLog.Debug($"{LastCatchName} foi capturado com sucesso!\n" +
                              $"CP: {pokemon.PokemonData.Cp}\n" +
                              $"IV: {Iv(pokemon.PokemonData.IndividualAttack,pokemon.PokemonData.IndividualDefense,pokemon.PokemonData.IndividualStamina):0.##}\n" +
                              $"Moves: ({pokemon.PokemonData.Move1},{pokemon.PokemonData.Move2})");


                UserGlobalConfiguration.SaveSettingsFromUserWithTime();
                return(true);

            case CatchPokemonResponse.Types.CatchStatus.CatchEscape:
                if (_catchTryCount > 5)
                {
                    _sayLog.Info(
                        $"O total de tentativas se esgotou. Tente outro Pokémon. [Tentativas:{_catchTryCount+1}/5]");
                    return(false);
                }
                else if (_catchTryCount < 5)
                {
                    _sayLog.Info($"O Pokémon escapou, tentando capturar novamente. [Tentativas:{_catchTryCount+1}/5]");
                    await Task.Delay(1000);

                    _catchTryCount++;
                    await CatchPokemon(pokemon, pokebola, berry);
                }
                break;

            case CatchPokemonResponse.Types.CatchStatus.CatchMissed:
                _sayLog.Info("Erramos a pokebola, tentando capturar novamente.");
                await CatchPokemon(pokemon, pokebola, berry);

                break;
            }

            return(false);
        }
Example #31
0
        private async Task <ItemId> GetBestBall(WildPokemon pokemon, bool escaped)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;
            //await RecycleItems(true);
            var items = await _client.Inventory.GetItems();

            var balls = items.Where(i => ((ItemId)i.ItemId == ItemId.ItemPokeBall ||
                                          (ItemId)i.ItemId == ItemId.ItemGreatBall ||
                                          (ItemId)i.ItemId == ItemId.ItemUltraBall ||
                                          (ItemId)i.ItemId == ItemId.ItemMasterBall) && i.ItemId > 0).GroupBy(i => ((ItemId)i.ItemId)).ToList();

            if (balls.Count() == 0)
            {
                return(ItemId.ItemUnknown);
            }

            var pokeBalls = false;

            if (balls.Any(g => g.Key == ItemId.ItemPokeBall))
            {
                if (balls.First(g => g.Key == ItemId.ItemPokeBall).First().Count > 0)
                {
                    pokeBalls = true;
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"FYI - PokeBall Count is Zero", LogLevel.Info);
                }
            }

            var greatBalls = false;

            if (balls.Any(g => g.Key == ItemId.ItemGreatBall))
            {
                if (balls.First(g => g.Key == ItemId.ItemGreatBall).First().Count > 0)
                {
                    greatBalls = true;
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"FYI - GreatBall Count is Zero", LogLevel.Info);
                }
            }

            var ultraBalls = false;

            if (balls.Any(g => g.Key == ItemId.ItemUltraBall))
            {
                if (balls.First(g => g.Key == ItemId.ItemUltraBall).First().Count > 0)
                {
                    ultraBalls = true;
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"FYI - UltraBall Count is Zero", LogLevel.Info);
                }
            }

            var masterBalls = false;

            if (balls.Any(g => g.Key == ItemId.ItemMasterBall))
            {
                if (balls.First(g => g.Key == ItemId.ItemMasterBall).First().Count > 0)
                {
                    masterBalls = true;
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"FYI - MasterBall Count is Zero", LogLevel.Info);
                }
            }

            var _lowestAppropriateBall     = ItemId.ItemUnknown;
            var getMyLowestAppropriateBall = new Dictionary <Func <int?, bool>, Action>
            {
                { x => x < 500, () => _lowestAppropriateBall = ItemId.ItemPokeBall },
                { x => x < 1000, () => _lowestAppropriateBall = ItemId.ItemGreatBall },
                { x => x < 2000, () => _lowestAppropriateBall = ItemId.ItemUltraBall },
                { x => x >= 2000, () => _lowestAppropriateBall = ItemId.ItemMasterBall }
            };

            getMyLowestAppropriateBall.First(sw => sw.Key(pokemonCp)).Value();
            if (escaped)
            {
                switch (_lowestAppropriateBall)
                {
                case ItemId.ItemGreatBall:
                {
                    _lowestAppropriateBall = ItemId.ItemUltraBall;
                    break;
                }

                case ItemId.ItemUltraBall:
                {
                    _lowestAppropriateBall = ItemId.ItemMasterBall;
                    break;
                }

                case ItemId.ItemMasterBall:
                {
                    _lowestAppropriateBall = ItemId.ItemMasterBall;
                    break;
                }

                default:
                {
                    _lowestAppropriateBall = ItemId.ItemGreatBall;
                    break;
                }
                }
            }
            switch (_lowestAppropriateBall)
            {
            case ItemId.ItemGreatBall:
            {
                if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                else if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                else if (masterBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                else if (pokeBalls)
                {
                    return(ItemId.ItemPokeBall);
                }
                else
                {
                    return(ItemId.ItemUnknown);
                }
            }

            case ItemId.ItemUltraBall:
            {
                if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                else if (masterBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                else if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                else if (pokeBalls)
                {
                    return(ItemId.ItemPokeBall);
                }
                else
                {
                    return(ItemId.ItemUnknown);
                }
            }

            case ItemId.ItemMasterBall:
            {
                if (masterBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                else if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                else if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                else if (pokeBalls)
                {
                    return(ItemId.ItemPokeBall);
                }
                else
                {
                    return(ItemId.ItemUnknown);
                }
            }

            default:
            {
                if (pokeBalls)
                {
                    return(ItemId.ItemPokeBall);
                }
                else if (greatBalls)
                {
                    return(ItemId.ItemGreatBall);
                }
                else if (ultraBalls)
                {
                    return(ItemId.ItemUltraBall);
                }
                else if (pokeBalls)
                {
                    return(ItemId.ItemMasterBall);
                }
                else
                {
                    return(ItemId.ItemUnknown);
                }
            }
            }
        }
Example #32
0
        private async Task<MiscEnums.Item> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var pokeBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_POKE_BALL);
            var greatBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_GREAT_BALL);
            var ultraBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_ULTRA_BALL);
            var masterBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_MASTER_BALL);

            if (masterBallsCount > 0 && pokemonCp >= 1000)
                return MiscEnums.Item.ITEM_MASTER_BALL;
            else if (ultraBallsCount > 0 && pokemonCp >= 1000)
                return MiscEnums.Item.ITEM_ULTRA_BALL;
            else if (greatBallsCount > 0 && pokemonCp >= 1000)
                return MiscEnums.Item.ITEM_GREAT_BALL;

            if (ultraBallsCount > 0 && pokemonCp >= 600)
                return MiscEnums.Item.ITEM_ULTRA_BALL;
            else if (greatBallsCount > 0 && pokemonCp >= 600)
                return MiscEnums.Item.ITEM_GREAT_BALL;

            if (greatBallsCount > 0 && pokemonCp >= 350)
                return MiscEnums.Item.ITEM_GREAT_BALL;

            if (pokeBallsCount > 0)
                return MiscEnums.Item.ITEM_POKE_BALL;
            if (greatBallsCount > 0)
                return MiscEnums.Item.ITEM_GREAT_BALL;
            if (ultraBallsCount > 0)
                return MiscEnums.Item.ITEM_ULTRA_BALL;
            if (masterBallsCount > 0)
                return MiscEnums.Item.ITEM_MASTER_BALL;

            return MiscEnums.Item.ITEM_POKE_BALL;
        }
Example #33
0
        //Evaluate if a pokemon is worth tweeting about.
        private static FoundPokemon ProcessPokemon(WildPokemon pokemon, Queue<FoundPokemon> alreadyFound, DateTime lastTweet)
        {
            FoundPokemon foundPokemon = new FoundPokemon
            {
                Location = new Location { Latitude = pokemon.Latitude, Longitude = pokemon.Longitude},
                Kind = pokemon.PokemonData.PokemonId,
                LifeExpectancy = pokemon.TimeTillHiddenMs / 1000
            };

            if (s_config.ExcludedPokemon.Contains(foundPokemon.Kind))
            {
                Log($"[!]Excluded: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}");
                return null;
            }

            if (foundPokemon.LifeExpectancy < s_config.MinimumLifeExpectancy)
            {
                Log($"[!]Expiring: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}");
                return null;
            }

            if (alreadyFound.Contains(foundPokemon))
            {
                Log($"[!]Duplicate: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}");
                return null;
            }

            if ((lastTweet + TimeSpan.FromSeconds(s_config.RateLimit) > DateTime.Now) && !s_config.PriorityPokemon.Contains(foundPokemon.Kind))
            {
                Log($"[!]Limiting: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}");
                return null;
            }

            Log($"[!]Tweeting: {foundPokemon.Kind} ({foundPokemon.LifeExpectancy} seconds): {Math.Round(foundPokemon.Location.Latitude, 6)},{Math.Round(foundPokemon.Location.Longitude, 6)}");
            return foundPokemon;
        }
Example #34
0
        // TODO: can be used in a future api that have different berries to decrease capture probability
        private static ItemId GetBestBerry(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;

            var items = client.Inventory.GetItems();

            var berries = items.Where(i => i.ItemId == ItemId.ItemRazzBerry || i.ItemId == ItemId.ItemBlukBerry || i.ItemId == ItemId.ItemWeparBerry).GroupBy(i => i.ItemId).ToList();

            //NOTE: removed || i.ItemId == ItemId.ItemPinapBerry || i.ItemId == ItemId.ItemNanabBerry
            if (!berries.Any())
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"No Berrys to select! - Using next best ball instead");
                return(ItemId.ItemUnknown);
            }

            var razzBerryCount  = client.Inventory.GetItemAmountByType(ItemId.ItemRazzBerry);
            var blukBerryCount  = client.Inventory.GetItemAmountByType(ItemId.ItemBlukBerry);
            var nanabBerryCount = client.Inventory.GetItemAmountByType(ItemId.ItemNanabBerry);
            var weparBerryCount = client.Inventory.GetItemAmountByType(ItemId.ItemWeparBerry);
            var pinapBerryCount = client.Inventory.GetItemAmountByType(ItemId.ItemPinapBerry);

            if (pinapBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemPinapBerry);
            }
            if (weparBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemWeparBerry);
            }
            if (nanabBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemNanabBerry);
            }
            if (nanabBerryCount > 0 && pokemonCp >= 2000)
            {
                return(ItemId.ItemBlukBerry);
            }

            if (weparBerryCount > 0 && pokemonCp >= 1500)
            {
                return(ItemId.ItemWeparBerry);
            }
            if (nanabBerryCount > 0 && pokemonCp >= 1500)
            {
                return(ItemId.ItemNanabBerry);
            }
            if (blukBerryCount > 0 && pokemonCp >= 1500)
            {
                return(ItemId.ItemBlukBerry);
            }

            if (nanabBerryCount > 0 && pokemonCp >= 1000)
            {
                return(ItemId.ItemNanabBerry);
            }
            if (blukBerryCount > 0 && pokemonCp >= 1000)
            {
                return(ItemId.ItemBlukBerry);
            }

            if (blukBerryCount > 0 && pokemonCp >= 500)
            {
                return(ItemId.ItemBlukBerry);
            }

            return(berries.OrderBy(g => g.Key).First().Key);
        }
Example #35
0
        private async Task<ItemId> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;


            await RecycleItems(true);
            var items = await _client.Inventory.GetItems();

            var balls = items.Where(i => ((ItemId)i.ItemId == ItemId.ItemPokeBall
                                      || (ItemId)i.ItemId == ItemId.ItemGreatBall
                                      || (ItemId)i.ItemId == ItemId.ItemUltraBall
                                      || (ItemId)i.ItemId == ItemId.ItemMasterBall) && i.ItemId > 0).GroupBy(i => ((ItemId)i.ItemId)).ToList();
            if (balls.Count() == 0) return ItemId.ItemUnknown;




            var pokeBalls = balls.Any(g => g.Key == ItemId.ItemPokeBall);
            var greatBalls = balls.Any(g => g.Key == ItemId.ItemGreatBall);
            var ultraBalls = balls.Any(g => g.Key == ItemId.ItemUltraBall);
            var masterBalls = balls.Any(g => g.Key == ItemId.ItemMasterBall);

            if (masterBalls && pokemonCp >= 2000)
                return ItemId.ItemMasterBall;
            else if (ultraBalls && pokemonCp >= 2000)
                return ItemId.ItemUltraBall;
            else if (greatBalls && pokemonCp >= 2000)
                return ItemId.ItemGreatBall;

            if (ultraBalls && pokemonCp >= 1000)
                return ItemId.ItemUltraBall;
            else if (greatBalls && pokemonCp >= 1000)
                return ItemId.ItemGreatBall;

            if (greatBalls && pokemonCp >= 500)
                return ItemId.ItemGreatBall;

            return balls.OrderBy(c => c.Key).First().Key;
        }
Example #36
0
        private void World_KeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;
            Array.Clear(this.OBJ, Player.Instance.location.Y * 10 + Player.Instance.location.X, 1);
            if (Player.Instance.location.Y == -1)
            {
                Connection connection = Player.Instance.currentMap.connections.Single((Connection c) => c.dir == Direction.Up);
                Player.Instance.currentMap = connection.toMap;
                Player expr_A5_cp_0 = Player.Instance;
                expr_A5_cp_0.location.X    = expr_A5_cp_0.location.X + connection.shift;
                Player.Instance.location.Y = Player.Instance.currentMap.height - 1;
                MusicPlayer.playBG(Player.Instance.currentMap.music);
                this.readMap();
            }
            else
            {
                if (Player.Instance.location.Y == Player.Instance.currentMap.height)
                {
                    Connection connection = Player.Instance.currentMap.connections.Single((Connection c) => c.dir == Direction.Down);
                    Player.Instance.currentMap = connection.toMap;
                    Player expr_176_cp_0 = Player.Instance;
                    expr_176_cp_0.location.X   = expr_176_cp_0.location.X + connection.shift;
                    Player.Instance.location.Y = 0;
                    MusicPlayer.playBG(Player.Instance.currentMap.music);
                    this.readMap();
                }
                else
                {
                    if (Player.Instance.location.X == Player.Instance.currentMap.width)
                    {
                        Connection connection = Player.Instance.currentMap.connections.Single((Connection c) => c.dir == Direction.Right);
                        Player.Instance.currentMap = connection.toMap;
                        Player expr_237_cp_0 = Player.Instance;
                        expr_237_cp_0.location.Y   = expr_237_cp_0.location.Y + connection.shift;
                        Player.Instance.location.X = 0;
                        MusicPlayer.playBG(Player.Instance.currentMap.music);
                        this.readMap();
                    }
                    else
                    {
                        if (Player.Instance.location.X == -1)
                        {
                            Connection connection = Player.Instance.currentMap.connections.Single((Connection c) => c.dir == Direction.Left);
                            Player.Instance.currentMap = connection.toMap;
                            Player expr_2EA_cp_0 = Player.Instance;
                            expr_2EA_cp_0.location.Y   = expr_2EA_cp_0.location.Y + connection.shift;
                            Player.Instance.location.X = Player.Instance.currentMap.width - 1;
                            MusicPlayer.playBG(Player.Instance.currentMap.music);
                            this.readMap();
                        }
                    }
                }
            }
            Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X].Occupied = false;
            switch (e.KeyCode)
            {
            case Keys.Space:
            {
                Event[] events = Player.Instance.currentMap.events;
                for (int i = 0; i < events.Length; i++)
                {
                    Event @event = events[i];
                    if ((Player.Instance.dir == Direction.Up && Player.Instance.location.Y == @event.location.Y + 1 && Player.Instance.location.X == @event.location.X) || (Player.Instance.dir == Direction.Down && Player.Instance.location.Y == @event.location.Y - 1 && Player.Instance.location.X == @event.location.X) || (Player.Instance.dir == Direction.Right && Player.Instance.location.X == @event.location.X - 1 && Player.Instance.location.Y == @event.location.Y) || (Player.Instance.dir == Direction.Left && Player.Instance.location.X == @event.location.X + 1 && Player.Instance.location.Y == @event.location.Y))
                    {
                        @event.script();
                    }
                }
                break;
            }

            case Keys.Left:
            {
                Direction dir = Player.Instance.dir;
                if (dir != Direction.Left)
                {
                    Player.Instance.dir = Direction.Left;
                }
                else
                {
                    if (Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X - 1].attribute != TerrainType.NotWalkable && Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X - 1].attribute != TerrainType.Water && !Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X - 1].Occupied)
                    {
                        Player expr_73B_cp_0 = Player.Instance;
                        expr_73B_cp_0.location.X = expr_73B_cp_0.location.X - 1;
                    }
                }
                break;
            }

            case Keys.Up:
            {
                Direction dir = Player.Instance.dir;
                if (dir != Direction.Up)
                {
                    Player.Instance.dir = Direction.Up;
                }
                else
                {
                    if (Player.Instance.currentMap[Player.Instance.location.Y - 1, Player.Instance.location.X].attribute != TerrainType.NotWalkable && Player.Instance.currentMap[Player.Instance.location.Y - 1, Player.Instance.location.X].attribute != TerrainType.Water && !Player.Instance.currentMap[Player.Instance.location.Y - 1, Player.Instance.location.X].Occupied)
                    {
                        Player expr_474_cp_0 = Player.Instance;
                        expr_474_cp_0.location.Y = expr_474_cp_0.location.Y - 1;
                    }
                }
                break;
            }

            case Keys.Right:
            {
                Direction dir = Player.Instance.dir;
                if (dir != Direction.Right)
                {
                    Player.Instance.dir = Direction.Right;
                }
                else
                {
                    if (Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X + 1].attribute != TerrainType.NotWalkable && Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X + 1].attribute != TerrainType.Water && !Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X + 1].Occupied)
                    {
                        Player expr_64E_cp_0 = Player.Instance;
                        expr_64E_cp_0.location.X = expr_64E_cp_0.location.X + 1;
                    }
                }
                break;
            }

            case Keys.Down:
            {
                Direction dir = Player.Instance.dir;
                if (dir != Direction.Down)
                {
                    Player.Instance.dir = Direction.Down;
                }
                else
                {
                    if (Player.Instance.currentMap[Player.Instance.location.Y + 1, Player.Instance.location.X].attribute != TerrainType.NotWalkable && Player.Instance.currentMap[Player.Instance.location.Y + 1, Player.Instance.location.X].attribute != TerrainType.Water && !Player.Instance.currentMap[Player.Instance.location.Y + 1, Player.Instance.location.X].Occupied)
                    {
                        Player expr_561_cp_0 = Player.Instance;
                        expr_561_cp_0.location.Y = expr_561_cp_0.location.Y + 1;
                    }
                }
                break;
            }
            }
            Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X].Occupied = true;
            this.pnlScreen.Invalidate();

            if (Player.Instance.party.Count > 0)
            {
                WildPokemon[] array = new WildPokemon[0];

                switch (Player.Instance.currentMap[Player.Instance.location.Y, Player.Instance.location.X].attribute)
                {
                case TerrainType.TallGrass:
                    array = Player.Instance.currentMap.tallGrassWild;
                    break;

                case TerrainType.LongGrass:
                    array = Player.Instance.currentMap.longGrassWild;
                    break;

                case TerrainType.Water:
                    array = Player.Instance.currentMap.surfWild;
                    break;

                case TerrainType.Cave:
                    array = Player.Instance.currentMap.caveWild;
                    break;
                }

                WildPokemon[] array2 = array;

                for (int i = 0; i < array2.Length; i++)
                {
                    WildPokemon wildPokemon = array2[i];
                    if (PRNG.Instance.Next((int)(187.5 / (double)wildPokemon.rate)) == 1)
                    {
                        new Battle(new Pokemon(wildPokemon.mon, (int)PRNG.Instance.Next((int)wildPokemon.minLevel, (int)wildPokemon.maxLevel), null, null)).ShowDialog();
                        break;
                    }
                }
            }
        }
Example #37
0
        private async Task <ItemId> GetBestBall(WildPokemon pokemon)
        {
            var pokemonCp = pokemon?.PokemonData?.Cp;


            //await RecycleItems(true);
            var items = await _client.Inventory.GetItems();

            var balls = items.Where(i => ((ItemId)i.ItemId == ItemId.ItemPokeBall ||
                                          (ItemId)i.ItemId == ItemId.ItemGreatBall ||
                                          (ItemId)i.ItemId == ItemId.ItemUltraBall ||
                                          (ItemId)i.ItemId == ItemId.ItemMasterBall) && i.ItemId > 0).GroupBy(i => ((ItemId)i.ItemId)).ToList();

            if (balls.Count() == 0)
            {
                return(ItemId.ItemUnknown);
            }



            var pokeBalls   = balls.Any(g => g.Key == ItemId.ItemPokeBall);
            var greatBalls  = balls.Any(g => g.Key == ItemId.ItemGreatBall);
            var ultraBalls  = balls.Any(g => g.Key == ItemId.ItemUltraBall);
            var masterBalls = balls.Any(g => g.Key == ItemId.ItemMasterBall);

            var coll = _clientSettings.itemRecycleFilter;

            foreach (KeyValuePair <ItemId, int> v in coll)
            {
                if (v.Key == ItemId.ItemPokeBall && v.Value == 0)
                {
                    pokeBalls = false;
                }
                else if (v.Key == ItemId.ItemGreatBall && v.Value == 0)
                {
                    greatBalls = false;
                }
                else if (v.Key == ItemId.ItemUltraBall && v.Value == 0)
                {
                    ultraBalls = false;
                }
                else if (v.Key == ItemId.ItemMasterBall && v.Value == 0)
                {
                    masterBalls = false;
                }
            }

            if (masterBalls && pokemonCp >= 2000)
            {
                return(ItemId.ItemMasterBall);
            }
            else if (ultraBalls && pokemonCp >= 2000)
            {
                return(ItemId.ItemUltraBall);
            }
            else if (greatBalls && pokemonCp >= 2000)
            {
                return(ItemId.ItemGreatBall);
            }

            if (ultraBalls && pokemonCp >= 1000)
            {
                return(ItemId.ItemUltraBall);
            }
            else if (greatBalls && pokemonCp >= 1000)
            {
                return(ItemId.ItemGreatBall);
            }

            if (greatBalls && pokemonCp >= 500)
            {
                return(ItemId.ItemGreatBall);
            }

            if (pokeBalls)
            {
                return(ItemId.ItemPokeBall);
            }

            if (greatBalls)
            {
                return(ItemId.ItemGreatBall);
            }

            if (ultraBalls)
            {
                return(ItemId.ItemUltraBall);
            }

            if (masterBalls)
            {
                return(ItemId.ItemMasterBall);
            }

            return(balls.OrderBy(c => c.Key).First().Key);
        }