Created
October 20, 2015 02:53
-
-
Save rachaelsalter/c5ffe4ebfeb045725fe4 to your computer and use it in GitHub Desktop.
Valid move for Pawn logic
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 valid_move?(x,y) | |
#First move. Allowed to move 1 or 2 spaces. | |
if self.x_position #how to say this is the first move?? | |
return false if (self.x_position - x).abs > 2 || (self.y_position - y).abs > 2 | |
#All moves. Allowed to move 1 space. | |
return false if (self.x_position - x).abs > 1 || (self.y_position - y).abs > 1 | |
#Up 1 and horizonal to capture. | |
#Cannot capture vertically. | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment