Class: Move

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

Overview

Ein Move repräsentiert eine Bewegung eines Steins auf dem Spielbrett

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to) ⇒ Move

Erstellt ein neuen Zug.



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

def initialize(from, to)
  @from = from
  @to = to
end

Instance Attribute Details

#fromCoordinates (readonly)

Returns:



7
8
9
# File 'lib/software_challenge_client/move.rb', line 7

def from
  @from
end

#Koordinaten von dem der Spielstein in diesem Zug wegbewegt wird(vondemderSpielstein) ⇒ Coordinates (readonly)

Returns:



7
# File 'lib/software_challenge_client/move.rb', line 7

attr_reader :from

#Koordinaten zu denen der Spielstein in diesem Zug hinbewegt wird(zudenenderSpielstein) ⇒ Coordinates (readonly)

Returns:



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

attr_reader :to

#toCoordinates (readonly)

Returns:



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

def to
  @to
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
# File 'lib/software_challenge_client/move.rb', line 28

def ==(other)
  from == other.from &&
    to == other.to
end

#piece(gamestate) ⇒ Object

TODO: Remove these?



20
21
22
# File 'lib/software_challenge_client/move.rb', line 20

def piece(gamestate)
  gamestate.board.field_at(from).piece
end

#piece_t(gamestate) ⇒ Object



24
25
26
# File 'lib/software_challenge_client/move.rb', line 24

def piece_t(gamestate)
  gamestate.board.field_at(to).piece
end

#to_sString

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

Returns:

  • (String)

    Gibt die String-Repräsentation zurück



34
35
36
# File 'lib/software_challenge_client/move.rb', line 34

def to_s
  "Move(#{from}->#{to})"
end