chess_validator 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chess_validator.rb +0 -1
- data/lib/move_logic.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d293dc8df9520f07a2f6d92b6d9e896f96b244e77088c400ec2896afe099ef
|
4
|
+
data.tar.gz: 52af33ff9401c878693c751483bedcc05f0e5713e39af53ac5c82d99c7ac09bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb8d4a4129e5bb7d639dd2851bb4d1c9ce4c44879f2541eb1baf5f3c0ec272cc9c368d6bc7af1a9718eb303263c3405e189bcfeae4bc38b6761877f5f85af7e1
|
7
|
+
data.tar.gz: 0abbe121cba65bebfae2f3ed8caa4115e4daee8c35c82af697e215db9fc144ff182490690ed843a8bc1943a232d211cba4b01a9e0448ddca67e83ee28d1acf2a
|
data/lib/chess_validator.rb
CHANGED
data/lib/move_logic.rb
CHANGED
@@ -114,8 +114,6 @@ module ChessValidator
|
|
114
114
|
def king_will_be_safe?(piece, board, move)
|
115
115
|
new_board = with_next_move(piece, board, move)
|
116
116
|
king, occupied_spaces = find_king_and_spaces(new_board, piece.color)
|
117
|
-
|
118
|
-
return false if king.nil?
|
119
117
|
king_is_safe?(king.color, new_board, king.position, occupied_spaces)
|
120
118
|
end
|
121
119
|
|
@@ -164,11 +162,12 @@ module ChessValidator
|
|
164
162
|
position = piece.position
|
165
163
|
|
166
164
|
if position[0] == move[0]
|
167
|
-
advance_pawn?(piece, board, move)
|
165
|
+
valid = advance_pawn?(piece, board, move)
|
168
166
|
else
|
169
167
|
target_piece = find_piece(board, move)
|
170
|
-
(target_piece && target_piece.color != piece.color) || move == fen.en_passant
|
168
|
+
valid = (target_piece && target_piece.color != piece.color) || move == fen.en_passant
|
171
169
|
end
|
170
|
+
valid && king_will_be_safe?(piece, board, move)
|
172
171
|
end
|
173
172
|
|
174
173
|
def advance_pawn?(pawn, board, move)
|