Sha256: e69b7bc1048ae7329b288d70fcee4fbb7f408ebd165f2d1e8b3278816e7cbdf6

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# encoding: UTF-8
require_relative 'player_color'
require_relative 'field_type'

# @author Ralf-Tobias Diekert
# A field on the game board
class Field
  # @!attribute [rw] ownerColor
  # @return [PlayerColor] the field's owner's color
  attr_accessor :ownerColor
  # @!attribute [rw] type
  # @return [PlayerColor] the field's type
  attr_accessor :type
  # @!attribute [r] x
  # @return [Integer] the field's x-coordinate
  attr_reader :x
  # @!attribute [r] y
  # @return [Integer] the field's y-coordinate
  attr_reader :y

  # Initializer
  #
  # @param type [FieldType] field type
  # @param x [Integer] x-coordinate
  # @param y [Integer] y-coordinate
  def initialize(type, x, y)
    self.ownerColor = PlayerColor::NONE
    self.type = type
    @x = x
    @y = y
  end

  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

  def to_s
    return "Field: x = #{self.x}, y = #{self.y}, owner = #{self.ownerColor}, type = #{self.type}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
software_challenge_client-0.1.5 lib/software_challenge_client/field.rb
software_challenge_client-0.1.4 lib/software_challenge_client/field.rb
software_challenge_client-0.1.3 lib/software_challenge_client/field.rb