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
26 27 28 29 30 31 |
# File 'lib/software_challenge_client/field.rb', line 26 def initialize(type, x, y) self.ownerColor = PlayerColor::NONE self.type = type @x = x @y = y end |
Instance Attribute Details
#ownerColor ⇒ PlayerColor
10 11 12 |
# File 'lib/software_challenge_client/field.rb', line 10 def ownerColor @ownerColor end |
#type ⇒ PlayerColor
13 14 15 |
# File 'lib/software_challenge_client/field.rb', line 13 def type @type end |
#x ⇒ Integer (readonly)
16 17 18 |
# File 'lib/software_challenge_client/field.rb', line 16 def x @x end |
#y ⇒ Integer (readonly)
19 20 21 |
# File 'lib/software_challenge_client/field.rb', line 19 def y @y end |
Instance Method Details
#==(another_field) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/software_challenge_client/field.rb', line 33 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
40 41 42 |
# File 'lib/software_challenge_client/field.rb', line 40 def to_s return "Field: x = #{self.x}, y = #{self.y}, owner = #{self.ownerColor}, type = #{self.type}" end |