Created
April 16, 2018 05:21
-
-
Save ilyakrasnov/20c663280d6a8ea2cf912a62dc3a144b to your computer and use it in GitHub Desktop.
Some notes on is_obstructed? method
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
def is_obstructed?(x1, y1, x2, y2) | |
is_obstructed_vertically?(x1, y1, x2, y2) || | |
is_obstructed_horizontally?(x1, y1, x2, y2) || | |
is_obstructed_diagonally?(x1, y1, x2, y2) | |
end | |
def is_obstructed_vertically?(x1, y1, x2, y2) | |
end | |
# 1. Break up the logic into separate methods | |
# | |
# Game has many Pieces | |
# game = Game.find(22) | |
# game.pieces ( All of the pieces have an x and y position ) | |
# 2. Simplify method call to be is_obsctructed?(target_x, target_y) | |
class Piece | |
attr_accessor :x_position, :y_position | |
def is_obstructed?(target_x, target_y) | |
end | |
end | |
# 3. Start by writing a test | |
# create a game | |
# create 2 pieces associated with this game | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment