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); }
private async Task <IEnumerable <ItemPerCount> > GetItemsToRecycle(Client client) { var myItems = await InventoryExtender.GetItems(client.Inventory); return(myItems .Where(x => ItemRecycleFilter.Any(f => f.Key == x.ItemId && x.Count > f.Value)) .Select(x => new ItemPerCount { Item = x.ItemId, Count = x.Count - ItemRecycleFilter.Single(f => f.Key == x.ItemId).Value, Unseen = x.Unseen })); }
public async Task UseBerry(ulong encounterId, string spawnPointId, Client client) { var inventoryBalls = await InventoryExtender.GetItems(client.Inventory); var berries = inventoryBalls.Where(p => p.ItemId == ItemId.ItemRazzBerry); var berry = berries.FirstOrDefault(); if (berry == null) { _logger.Write("No berries to use", LogLevel.WARN); return; } await client.Encounter.UseCaptureItem(encounterId, ItemId.ItemRazzBerry, spawnPointId); await Task.Delay(3000); }
public async Task UseLuckyEgg(Client client) { var inventory = await InventoryExtender.GetItems(client.Inventory); var luckyEggs = inventory.Where(p => p.ItemId == ItemId.ItemLuckyEgg).ToList(); var luckyEgg = luckyEggs.FirstOrDefault(); if (luckyEgg == null) { _logger.Write("No lucky eggs to use", LogLevel.WARN); return; } await client.Inventory.UseItemXpBoost(); _logger.Write($"Successfull used lucky egg. Lucky eggs left {luckyEggs.Count() - 1}", LogLevel.SUCC); await Task.Delay(3000); }
public async Task UseIncense(Client client) { var inventory = await InventoryExtender.GetItems(client.Inventory); var incenses = inventory.Where( p => p.ItemId == ItemId.ItemIncenseCool || p.ItemId == ItemId.ItemIncenseFloral || p.ItemId == ItemId.ItemIncenseOrdinary || p.ItemId == ItemId.ItemIncenseSpicy).ToList(); var incense = incenses.FirstOrDefault(); if (incense == null) { _logger.Write("No incenses to use", LogLevel.WARN); return; } await client.Inventory.UseIncense(incense.ItemId); _logger.Write($"Successfull used {incense.ItemId}. {incense.ItemId} left {incenses.Count() - 1}", LogLevel.SUCC); await Task.Delay(3000); }