Class: Improves::HavenMove

Inherits:
ImproveHunter show all
Includes:
Moveable
Defined in:
app/services/improves/haven_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) ⇒ HavenMove

Returns a new instance of HavenMove.


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

def initialize(hunters_improvement)
  super
  @move = move
  @haven = @improvement.configured_haven(@hunters_improvement)
end

Instance Method Details

#improveObject


15
16
17
18
# File 'app/services/improves/haven_move.rb', line 15

def improve
  return false unless valid?
  HuntersMove.create(hunter: @hunter, move: @move, haven: @haven)
end

#valid?Boolean

Returns:

  • (Boolean)

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

def valid?
  super
  check :not_haven_move?, :move, 'is not a haven option'
  check :hunter_move_exists?, :hunter,
        "already has move with id #{@move&.id}"
  @hunters_improvement.errors.none?
end