Class: Core::Game::Combat::Behaviour

Inherits:
Object
  • Object
show all
Defined in:
lib/game/combat/battle.rb

Overview

For enemies

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Behaviour

Returns a new instance of Behaviour.



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/game/combat/battle.rb', line 41

def initialize(hash)
  @actions = {}
  hash.each { |k, v|
    i = 0
    v.each { |action|
      if !@actions[k]
        @actions.store(k, {})
      end
      @actions[k].store(i, action)
      i += 1
    }
  }
end

Instance Method Details

#execute(sym) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/game/combat/battle.rb', line 55

def execute(sym)
  ary = @actions[sym].values.flatten(1)
  ary.each { |str|
    params = str.split(" ")
    self.send(params.shift, params)
  }
end