-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roland Studer
committed
Dec 22, 2021
1 parent
4cd608c
commit d8e1285
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Move | ||
# unlimited horizontal movement for a piece | ||
class Horizontal | ||
def unhindered_legal_end_positions(position) | ||
position = Position.parse(position) if position.is_a? String | ||
letters = ("A".."H").to_a - [position.letter] | ||
letters.map { |l| Position.new(l, position.number) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require "minitest/autorun" | ||
|
||
module Move | ||
class HorizontalTest < Minitest::Test | ||
def test_returns_unhindered_positions | ||
move = Move::Horizontal.new | ||
|
||
legal_end_positions = %w[A3 B3 C3 E3 F3 G3 H3].map { |p| Position.parse(p) } # without D4 | ||
assert_equal legal_end_positions, move.unhindered_legal_end_positions("D3") | ||
end | ||
end | ||
end |