-
-
Save mscoutermarsh/3ef41e8d46db5cdbae8f to your computer and use it in GitHub Desktop.
Valid_move_pawn2
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
class Pawn < Piece | |
def first_move?(y) | |
#Allowed to move 1 or 2 spaces. | |
if (color: :white && y_position: 1) || (color: :black && y_position: 6) | |
return true | |
if (y_position - y) < 3 | |
else | |
return false | |
end | |
end | |
end | |
def all_moves? | |
#Allowed to move 1 space only. | |
return false if (x_position - x).abs > 1 || (y_position - y).abs > 1 | |
end | |
end | |
#Up 1 and horizonal to capture. | |
#Cannot capture vertically. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment