Created
May 23, 2018 20:24
-
-
Save msarit/cb2cab3c6b6931ab3ef2712015bfe56f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def move_to!(x,y) | |
| destination = game.pieces.find_by(location_x: x, location_y: y) | |
| if destination.nil? | |
| self.update_attributes(location_x: x, location_y: y) | |
| elsif self.white != destination.white | |
| destination.update_attributes(location_x: nil, location_y: nil, notcaptured: false) | |
| self.update_attributes(location_x: x, location_y: y) | |
| else | |
| flash[:alert] = "Cannot move there; occupied by friendly" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment