Class: Mind

Inherits:
Object
  • Object
show all
Defined in:
lib/Olib/character/mind.rb

Constant Summary collapse

@@states =
OpenStruct.new(
  :saturated        => "saturated",
  :must_rest        => "must rest",
  :numbed           => "numbed",
  :becoming_numbed  => "becoming numbed",
  :muddled          => "muddled",
  :clear            => "clear",
  :fresh_and_clear  => "fresh and clear",
  :clear_as_a_bell  => "clear as a bell"
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.percentObject

Returns Fixnum.

Returns:

  • Fixnum


35
36
37
# File 'lib/Olib/character/mind.rb', line 35

def Mind.percent
  percentmind
end

.rest!(state = Mind.states.saturated) ⇒ Object

Returns nil.

Parameters:

  • state (defaults to: Mind.states.saturated)

    The state

Returns:

  • nil


66
67
68
69
# File 'lib/Olib/character/mind.rb', line 66

def Mind.rest!(state=Mind.states.saturated)
  Go2.origin
  wait_until { Mind.state != state }
end

.stateObject

Returns String.

Returns:

  • String


27
28
29
# File 'lib/Olib/character/mind.rb', line 27

def Mind.state
  checkmind
end

.statesObject

Returns OpenStruct.

Returns:

  • OpenStruct


19
20
21
# File 'lib/Olib/character/mind.rb', line 19

def Mind.states
  @@states
end

Instance Method Details

#nameObject

dynamically defines all methods to check state

Example:

Mind.saturated?
Mind.must_rest?

45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/Olib/character/mind.rb', line 45

Mind.states.each_pair { |name, str|
  Mind.define_singleton_method((name.to_s + "?").to_sym) do
    Mind.state == str
  end

  Mind.define_singleton_method("until_not_#{name.to_s}".to_sym) do
    wait_until { Mind.state != str }
  end

  Mind.define_singleton_method("until_#{name.to_s}".to_sym) do
    wait_until { Mind.state == str }
  end
}