Class: Brawl::BasicBot

Inherits:
BasicArenaObject show all
Extended by:
Forwardable
Includes:
Eventable
Defined in:
lib/brawl/basic_bot.rb

Constant Summary collapse

DECIMAL_PLACES =
1

Instance Attribute Summary collapse

Attributes inherited from BasicArenaObject

#clock, #heading, #health, #id, #location, #name

Instance Method Summary collapse

Methods inherited from BasicArenaObject

#properties

Constructor Details

#initialize(params = {}) ⇒ BasicBot

Returns a new instance of BasicBot.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/brawl/basic_bot.rb', line 18

def initialize(params={})
  @arena = params[:arena]
  @parts = params[:parts]

  add_parts(@parts, params)
  hook_methods_for_listeners

  super

  @arena.add_object(self)
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



14
15
16
# File 'lib/brawl/basic_bot.rb', line 14

def parts
  @parts
end

Instance Method Details

#damage(damage_points) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/brawl/basic_bot.rb', line 30

def damage(damage_points)
  super
  fire_event(:bot_damaged,
    properties,
    :damage,
    damage_points
  )
  @arena.remove_object(self) if @health <= 0
end