Class: Improves::AdvancedMove
- Inherits:
-
ImproveHunter
- Object
- ImproveHunter
- Improves::AdvancedMove
- Includes:
- Moveable
- Defined in:
- app/services/improves/advanced_move.rb
Overview
Used to apply an Improvements::AdvancedMove to a hunter if the hunter is a valid target
Instance Method Summary collapse
- #improve ⇒ Object
-
#initialize(hunters_improvement) ⇒ AdvancedMove
constructor
A new instance of AdvancedMove.
- #not_improvable_count? ⇒ Boolean
- #valid? ⇒ Boolean
Methods included from Moveable
#already_advanced_moves?, #hunter_move_exists?, #invalid_move?, #move, #moves, #not_basic_moves?, #not_haven_move?, #playbook_move_match?, #playbook_move_mismatch?
Methods inherited from ImproveHunter
#check, for, #hunter_not_advanced?, #hunter_playbook_mismatch?
Constructor Details
#initialize(hunters_improvement) ⇒ AdvancedMove
Returns a new instance of AdvancedMove.
9 10 11 12 13 14 |
# File 'app/services/improves/advanced_move.rb', line 9 def initialize(hunters_improvement) super moves @count = 2 @hunters_moves = HuntersMove.where(hunter: @hunter, move: @moves) end |
Instance Method Details
#improve ⇒ Object
16 17 18 19 |
# File 'app/services/improves/advanced_move.rb', line 16 def improve return false unless valid? @hunters_moves.update(advanced: true) end |
#not_improvable_count? ⇒ Boolean
29 30 31 |
# File 'app/services/improves/advanced_move.rb', line 29 def not_improvable_count? @improvable.dig('moves').count != @count end |
#valid? ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'app/services/improves/advanced_move.rb', line 21 def valid? super check :not_basic_moves?, :moves, 'are not all Basic' check :not_improvable_count?, :improvable, 'does not have 2 moves' check :already_advanced_moves?, :moves, 'already advanced' @hunters_improvement.errors.none? end |