Class: Field
- Inherits:
-
Object
- Object
- Field
- Defined in:
- lib/software_challenge_client/field.rb
Overview
A field on the game board
Instance Attribute Summary collapse
-
#ownerColor ⇒ PlayerColor
The field’s owner’s color.
-
#type ⇒ PlayerColor
The field’s type.
-
#x ⇒ Integer
readonly
The field’s x-coordinate.
-
#y ⇒ Integer
readonly
The field’s y-coordinate.
Instance Method Summary collapse
- #==(another_field) ⇒ Object
-
#initialize(type, x, y) ⇒ Field
constructor
Initializer.
- #to_s ⇒ Object
Constructor Details
#initialize(type, x, y) ⇒ Field
Initializer
25 26 27 28 29 30 |
# File 'lib/software_challenge_client/field.rb', line 25 def initialize(type, x, y) self.ownerColor = PlayerColor::NONE self.type = type @x = x @y = y end |
Instance Attribute Details
#ownerColor ⇒ PlayerColor
Returns the field’s owner’s color.
9 10 11 |
# File 'lib/software_challenge_client/field.rb', line 9 def ownerColor @ownerColor end |
#type ⇒ PlayerColor
Returns the field’s type.
12 13 14 |
# File 'lib/software_challenge_client/field.rb', line 12 def type @type end |
#x ⇒ Integer (readonly)
Returns the field’s x-coordinate.
15 16 17 |
# File 'lib/software_challenge_client/field.rb', line 15 def x @x end |
#y ⇒ Integer (readonly)
Returns the field’s y-coordinate.
18 19 20 |
# File 'lib/software_challenge_client/field.rb', line 18 def y @y end |
Instance Method Details
#==(another_field) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/software_challenge_client/field.rb', line 32 def ==(another_field) return self.ownerColor == another_field.ownerColor && self.type == another_field.type && self.x == another_field.x && self.y == another_field.y end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/software_challenge_client/field.rb', line 39 def to_s return "Field: x = #{self.x}, y = #{self.y}, owner = #{self.ownerColor}, type = #{self.type}" end |