Class: Piece

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/software_challenge_client/piece.rb

Overview

Ein Spielstein mit Ausrichtung, Koordinaten und Farbe

Constant Summary

Constants included from Constants

Constants::BOARD_SIZE, Constants::GAME_IDENTIFIER, Constants::ROUND_LIMIT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team, coords = Coordinates.origin) ⇒ Piece

Erstellt einen neuen Spielstein.



18
19
20
21
# File 'lib/software_challenge_client/piece.rb', line 18

def initialize(team, coords = Coordinates.origin)
  @team = team
  @coords = coords
end

Instance Attribute Details

#coordsCoordinates

Returns:



15
16
17
# File 'lib/software_challenge_client/piece.rb', line 15

def coords
  @coords
end

#KoordinatenCoordinates

Returns:



15
# File 'lib/software_challenge_client/piece.rb', line 15

attr_accessor :coords

#TeamTeam

Returns:



11
# File 'lib/software_challenge_client/piece.rb', line 11

attr_accessor :team

#teamTeam

Returns:



11
12
13
# File 'lib/software_challenge_client/piece.rb', line 11

def team
  @team
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
# File 'lib/software_challenge_client/piece.rb', line 23

def ==(other)
  !other.nil? &&
    team == other.team &&
    coords == other.coords
end

#inspectObject



40
41
42
# File 'lib/software_challenge_client/piece.rb', line 40

def inspect
  to_s
end

#to_sString

Returns Gibt die String-Repräsentation zurück.

Returns:

  • (String)

    Gibt die String-Repräsentation zurück



30
31
32
# File 'lib/software_challenge_client/piece.rb', line 30

def to_s
  "#{team.key} at #{coords}"
end

#to_ssString

To short string

Returns:

  • (String)

    Gibt eine Kurzfassung der String-Repräsentation zurück



36
37
38
# File 'lib/software_challenge_client/piece.rb', line 36

def to_ss
  "#{team.key.to_s[0]}"
end