Class: Improves::PlaybookMove

Inherits:
ImproveHunter show all
Includes:
Moveable
Defined in:
app/services/improves/playbook_move.rb

Overview

Used to apply an Improvements::HavenMove to a hunter if the hunter is a valid target

Instance Method Summary collapse

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) ⇒ PlaybookMove

Returns a new instance of PlaybookMove.


9
10
11
12
# File 'app/services/improves/playbook_move.rb', line 9

def initialize(hunters_improvement)
  super
  move
end

Instance Method Details

#improveObject


14
15
16
17
# File 'app/services/improves/playbook_move.rb', line 14

def improve
  return false unless valid?
  @hunter.moves << move
end

#valid?Boolean

Returns:

  • (Boolean)

19
20
21
22
23
24
25
26
# File 'app/services/improves/playbook_move.rb', line 19

def valid?
  super
  check :playbook_move_mismatch?, :move,
        "doesn't match improvement playbook"
  check :hunter_move_exists?, :hunter,
        "already has move with id #{@move&.id}"
  @hunters_improvement.errors.none?
end