Skip to content

Instantly share code, notes, and snippets.

@ilyakrasnov
Created April 16, 2018 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyakrasnov/20c663280d6a8ea2cf912a62dc3a144b to your computer and use it in GitHub Desktop.
Save ilyakrasnov/20c663280d6a8ea2cf912a62dc3a144b to your computer and use it in GitHub Desktop.
Some notes on is_obstructed? method
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