Class: Brawl::BasicArenaObject
- Inherits:
-
Object
- Object
- Brawl::BasicArenaObject
- Defined in:
- lib/brawl/basic_arena_object.rb
Instance Attribute Summary collapse
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#health ⇒ Object
Returns the value of attribute health.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #damage(damage_points) ⇒ Object
-
#initialize(params = {}) ⇒ BasicArenaObject
constructor
A new instance of BasicArenaObject.
-
#properties ⇒ Object
properties are values that are OK to be publicly ‘seen’ in the arena.
Constructor Details
#initialize(params = {}) ⇒ BasicArenaObject
Returns a new instance of BasicArenaObject.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/brawl/basic_arena_object.rb', line 10 def initialize(params={}) @clock = params[:clock] @id = params[:id] || UUIDTools::UUID..to_s @name = params[:name] || self.object_id @location = params[:location] || {x: 0, y: 0} @heading = params[:heading] || 0 @health = params[:health] || 1 @properties = params[:properties] || [:id, :name, :class, :location, :health, :heading] end |
Instance Attribute Details
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
7 8 9 |
# File 'lib/brawl/basic_arena_object.rb', line 7 def clock @clock end |
#heading ⇒ Object
Returns the value of attribute heading.
8 9 10 |
# File 'lib/brawl/basic_arena_object.rb', line 8 def heading @heading end |
#health ⇒ Object
Returns the value of attribute health.
8 9 10 |
# File 'lib/brawl/basic_arena_object.rb', line 8 def health @health end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/brawl/basic_arena_object.rb', line 7 def id @id end |
#location ⇒ Object
Returns the value of attribute location.
8 9 10 |
# File 'lib/brawl/basic_arena_object.rb', line 8 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/brawl/basic_arena_object.rb', line 7 def name @name end |
Instance Method Details
#damage(damage_points) ⇒ Object
28 29 30 31 |
# File 'lib/brawl/basic_arena_object.rb', line 28 def damage(damage_points) @health -= damage_points @health < 0 ? @health = 0 : @health end |
#properties ⇒ Object
properties are values that are OK to be publicly ‘seen’ in the arena
22 23 24 25 26 |
# File 'lib/brawl/basic_arena_object.rb', line 22 def properties @properties.each_with_object({}) do |property, hash| hash[property] = self.send(property) end end |