Class: Oakdex::Pokemon::UseItemService
- Inherits:
-
Object
- Object
- Oakdex::Pokemon::UseItemService
- Defined in:
- lib/oakdex/pokemon/use_item_service.rb
Overview
Represents Item usage
Instance Method Summary collapse
-
#initialize(pokemon, item_id, options = {}) ⇒ UseItemService
constructor
A new instance of UseItemService.
- #usable? ⇒ Boolean
- #use ⇒ Object
Constructor Details
#initialize(pokemon, item_id, options = {}) ⇒ UseItemService
Returns a new instance of UseItemService.
5 6 7 8 9 |
# File 'lib/oakdex/pokemon/use_item_service.rb', line 5 def initialize(pokemon, item_id, = {}) @pokemon = pokemon @item = Oakdex::Pokedex::Item.find!(item_id) @options = end |
Instance Method Details
#usable? ⇒ Boolean
11 12 13 |
# File 'lib/oakdex/pokemon/use_item_service.rb', line 11 def usable? !evolution.nil? || effect_usable? end |
#use ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/oakdex/pokemon/use_item_service.rb', line 15 def use return unless usable? unless evolution.nil? @pokemon.add_growth_event(GrowthEvents::Evolution, evolution: evolution) end execute_effects true end |