Class: Field

Inherits:
Object
  • Object
show all
Defined in:
lib/software_challenge_client/field.rb

Overview

A field on the game board

Author:

  • Ralf-Tobias Diekert

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#ownerColorPlayerColor



10
11
12
# File 'lib/software_challenge_client/field.rb', line 10

def ownerColor
  @ownerColor
end

#typePlayerColor



13
14
15
# File 'lib/software_challenge_client/field.rb', line 13

def type
  @type
end

#xInteger (readonly)



16
17
18
# File 'lib/software_challenge_client/field.rb', line 16

def x
  @x
end

#yInteger (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_sObject



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