lib/just_chess/square.rb in just_chess-0.1.0 vs lib/just_chess/square.rb in just_chess-1.0.0
- old
+ new
@@ -1,14 +1,14 @@
require 'just_chess/piece_factory'
-require 'just_chess/point'
+require 'board_game_grid'
module JustChess
# = Square
#
# A Square on a checker board
- class Square
+ class Square < BoardGameGrid::Square
# New objects can be instantiated by passing in a hash with
#
# @param [String] id
# the unique identifier of the square.
@@ -35,36 +35,10 @@
@x = x
@y = y
@piece = PieceFactory.new(piece).build
end
- # @return [String] the unique identifier of the square.
- attr_reader :id
-
- # @return [Fixnum] the x co-ordinate of the square.
- attr_reader :x
-
- # @return [Fixnum] the y co-ordinate of the square.
- attr_reader :y
-
- # @return [Piece,NilClass] The piece on the square if any.
- attr_accessor :piece
-
- # Is the square occupied by a piece?
- #
- # @return [Boolean]
- def occupied?
- !!piece
- end
-
- # Is the square unoccupied by a piece?
- #
- # @return [Boolean]
- def unoccupied?
- !piece
- end
-
# Is the square occupied by the specified player?
#
# @return [Boolean]
def occupied_by_player?(player_number)
piece && piece.player_number == player_number
@@ -91,23 +65,9 @@
# Is the square the last rank for the specified player?
#
# @return [Boolean]
def last_rank(player_number)
rank_number(player_number) == 8
- end
-
- # Is the square the same as another one?
- #
- # @return [Boolean]
- def ==(other)
- self.id == other.id
- end
-
- # A point object with the square's co-ordinates.
- #
- # @return [Point]
- def point
- Point.new(x, y)
end
# A serialized version of the square as a hash
#
# @return [Hash]
\ No newline at end of file