Class: EchoLogic

Inherits:
BaseLogic show all
Defined in:
lib/cureutils/logic/echo_logic.rb

Overview

Singleton class for cure echo

Defined Under Namespace

Modules: EchoMode

Instance Method Summary collapse

Methods inherited from BaseLogic

#source_err, #source_input, #source_output

Constructor Details

#initializeEchoLogic

Returns a new instance of EchoLogic.



12
13
14
15
16
17
# File 'lib/cureutils/logic/echo_logic.rb', line 12

def initialize
  super
  @cure_name = 'echo'
  @message_mode = EchoMode::TRANSFORM
  @style_priority = []
end

Instance Method Details

#msg_attack(flag = false) ⇒ Object



27
28
29
# File 'lib/cureutils/logic/echo_logic.rb', line 27

def msg_attack(flag = false)
  @message_mode = EchoMode::ATTACK if flag
end

#msg_transform(flag = true) ⇒ Object



23
24
25
# File 'lib/cureutils/logic/echo_logic.rb', line 23

def msg_transform(flag = true)
  @message_mode = EchoMode::TRANSFORM if flag
end

#nosleep(flag = true) ⇒ Object



31
32
33
34
# File 'lib/cureutils/logic/echo_logic.rb', line 31

def nosleep(flag = true)
  Rubicure::Girl.sleep_sec = 1
  Rubicure::Girl.sleep_sec = 0 if flag
end

#precure(cure_name = false) ⇒ Object



19
20
21
# File 'lib/cureutils/logic/echo_logic.rb', line 19

def precure(cure_name = false)
  @cure_name = cure_name || 'echo'
end


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cureutils/logic/echo_logic.rb', line 40

def print_results
  return 1 unless existing_precure?

  precure = Cure.send(@cure_name.to_sym)
  if @message_mode == EchoMode::TRANSFORM
    original_transform(precure)
  elsif @message_mode == EchoMode::ATTACK
    precure = original_transform(precure)
    precure.attack!
  end
  0
end

#style(style) ⇒ Object



36
37
38
# File 'lib/cureutils/logic/echo_logic.rb', line 36

def style(style)
  @style_priority << style.to_sym if style
end