chess_validator 0.2.9 → 0.2.10
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/move_logic.rb +12 -7
- 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: b367a02178081794d8ac5adc34cada855ae9aa3615459fd2c6aa81698f0cc8e7
|
4
|
+
data.tar.gz: 3f49bc22122a0318a991fb6340b0b6f22b0d30d919f07396b0a02de00affc219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6074c987ce55676e9f41e05c501438459757c6fe8ac24dec622f50d9b7ca7e80c637b495393839df2a9bee05efca5601e41088e2b035dfe824b8cd05ff26272
|
7
|
+
data.tar.gz: 3a06c0c82eb0d9317b0b439cb37d47975aaecfe484d65d28d3d0733f71b89b07b7dcae6895f599632921293ed0642ccae113a6517279cfad1f7dee5064d429bd
|
data/lib/move_logic.rb
CHANGED
@@ -191,17 +191,22 @@ module ChessValidator
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def advance_pawn?(pawn, board, move)
|
194
|
-
if (pawn
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
occupied_spaces << piece.position
|
194
|
+
if empty_square?(board, forward_by(pawn, 1))
|
195
|
+
if (pawn.position[1].to_i - move[1].to_i).abs == 2
|
196
|
+
empty_square?(board, forward_by(pawn, 2))
|
197
|
+
else
|
198
|
+
true
|
200
199
|
end
|
201
|
-
|
200
|
+
else
|
201
|
+
false
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
+
def forward_by(piece, count)
|
206
|
+
position = piece.position
|
207
|
+
piece.color == 'w' ? position[0] + (position[1].to_i + count).to_s : position[0] + (position[1].to_i - count).to_s
|
208
|
+
end
|
209
|
+
|
205
210
|
def valid_destination?(piece, board, move)
|
206
211
|
target_piece = find_piece(board, move)
|
207
212
|
if target_piece
|