Class: Rchess::Paths::Base
- Inherits:
-
Object
- Object
- Rchess::Paths::Base
show all
- Defined in:
- lib/rchess/path.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params) ⇒ Base
Returns a new instance of Base.
7
8
9
10
|
# File 'lib/rchess/path.rb', line 7
def initialize(params)
@coord = params.fetch(:coord)
@board = params.fetch(:board)
end
|
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
5
6
7
|
# File 'lib/rchess/path.rb', line 5
def board
@board
end
|
#coord ⇒ Object
Returns the value of attribute coord.
4
5
6
|
# File 'lib/rchess/path.rb', line 4
def coord
@coord
end
|
Class Method Details
.threaten_destinations_from_coord(coord, board) ⇒ Object
Instance Method Details
#destinations ⇒ Object
20
21
22
|
# File 'lib/rchess/path.rb', line 20
def destinations
@destinations ||= self.paths.map{ |path| apply_delta_to_path(path).delete_if{ |coord| coord.x < 0 || coord.y < 0 } }
end
|
#paths ⇒ Object
24
25
26
|
# File 'lib/rchess/path.rb', line 24
def paths
raise NotImplementedError.new("You must implement paths")
end
|
#srcBox ⇒ Object
12
13
14
|
# File 'lib/rchess/path.rb', line 12
def srcBox
@srcBox ||= @bord.box_at_coord(@coord)
end
|
#srcDirection ⇒ Object
16
17
18
|
# File 'lib/rchess/path.rb', line 16
def srcDirection
@srcDirection ||= srcBox.downcase == srcBox ? -1 : 1 end
|