/// <summary>Selects the pokeball type from Inventory</summary> /// <param name="itemId">The item identifier</param> /// <returns>Found balls or null</returns> private ItemData SelectPokeballType(ItemId?itemId) { if (itemId == null) { return(null); } return(ItemsInventory?.FirstOrDefault(item => item.ItemId == itemId)); }
/// <summary>Selects the modifier type from Inventory</summary> /// <param name="itemId">The item identifier</param> /// <returns>Found modifier or null</returns> private ItemData SelectModifierType(ItemId?itemId) { if (itemId == null) { return(null); } var modifier = ItemsInventory?.FirstOrDefault(item => item.ItemId == itemId); if (modifier == null || modifier.Count <= 0) { return(null); } return(modifier); }
/// <summary>Selects the pokeball type from Inventory</summary> /// <param name="itemId">The item identifier</param> /// <returns>Found balls or null</returns> private ItemData SelectPokeballType(ItemId?itemId) { if (itemId == null) { return(null); } var ball = ItemsInventory?.FirstOrDefault(item => item.ItemId == itemId); if (ball == null || ball.Count <= 0) { return(null); } return(ball); }
/// <summary> /// Selects the first ball based on available items /// </summary> private void SelectStartingBall(bool keepPreviousSelection = false) { // Set default item (switch to other balls if user has none) if (!keepPreviousSelection) { SelectedCaptureItem = ItemsInventory.First(item => item.ItemId == ItemId.ItemPokeBall) ?? new ItemData { Count = 0, ItemId = ItemId.ItemPokeBall }; } else { // Start with a ball of the same type as the one that's currently used SelectedCaptureItem = ItemsInventory.First(item => item.ItemId == SelectedCaptureItem.ItemId); } while (SelectedCaptureItem != null && SelectedCaptureItem.Count == 0) { switch (SelectedCaptureItem.ItemId) { case ItemId.ItemPokeBall: // Try with Greatball SelectedCaptureItem = ItemsInventory.FirstOrDefault(item => item.ItemId == ItemId.ItemGreatBall); if (SelectedCaptureItem == null) { SelectedCaptureItem = new ItemData() { Count = 0, ItemId = ItemId.ItemGreatBall }; } break; case ItemId.ItemGreatBall: // Try with Ultraball SelectedCaptureItem = ItemsInventory.FirstOrDefault(item => item.ItemId == ItemId.ItemUltraBall); if (SelectedCaptureItem == null) { SelectedCaptureItem = new ItemData() { Count = 0, ItemId = ItemId.ItemUltraBall }; } break; case ItemId.ItemUltraBall: // Try with Masterball SelectedCaptureItem = ItemsInventory.FirstOrDefault(item => item.ItemId == ItemId.ItemMasterBall); if (SelectedCaptureItem == null) { SelectedCaptureItem = new ItemData() { Count = 0, ItemId = ItemId.ItemMasterBall }; } break; case ItemId.ItemMasterBall: // User has no left balls, choose a non-existing Pokeball to stop him from trying to capture SelectedCaptureItem = new ItemData { Count = 0, ItemId = ItemId.ItemPokeBall }; return; } } }