{"action":"created","comment":{"url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/comments/45996675","id":45996675,"diff_hunk":"@@ -1,2 +1,64 @@\n class Pawn < ChessPiece\n+  INITIAL_MOVE_FACTOR = 2\n+  POST_INITIAL_MOVE_FACTOR = 1\n+\n+  def valid_move?(destination_x, destination_y)\n+    return false unless forward_move?(destination_y)\n+    if vertical_move?(destination_x, destination_y)\n+      valid_vertical_move?(destination_x, destination_y)\n+    else\n+      valid_capture?(destination_x, destination_y)\n+    end\n+  end\n+\n+  private\n+\n+  def valid_vertical_move?(destination_x, destination_y)\n+    return false if moved_to_far?(destination_y)\n+    return false if position_occupied?(destination_x, destination_y)\n+    !obstructed?(destination_x, destination_y)\n+  end\n+\n+  def moved_to_far?(destination_y)\n+    diff_in_y(destination_y) > y_move_factor\n+  end\n+\n+  def valid_capture?(destination_x, destination_y)\n+    return false unless single_diagonal_move?(destination_x, destination_y)\n+    opponent_at?(destination_x, destination_y)\n+  end\n+\n+  def single_diagonal_move?(destination_x, destination_y)\n+    diff_in_x(destination_x) == 1 && diff_in_y(destination_y) == 1\n+  end\n+\n+  def opponent_at?(destination_x, destination_y)\n+    destination_piece = find_piece(destination_x, destination_y)\n+    opponent?(destination_piece)\n+  end\n+\n+  def find_piece(destination_x, destination_y)\n+    game.chess_pieces.find_by(position_x: destination_x, position_y: destination_y)\n+  end\n+\n+  def opponent?(piece)\n+    !piece.nil? && piece.color != color\n+  end\n+\n+  def y_move_factor\n+    moved? ? POST_INITIAL_MOVE_FACTOR : INITIAL_MOVE_FACTOR\n+  end\n+\n+  def moved?\n+    updated_at != created_at\n+  end\n+\n+  def forward_move?(destination_y)\n+    y_distance = destination_y - position_y","path":"app/models/pawn.rb","position":57,"original_position":57,"commit_id":"6b11c93c28240d018f727f5f089c9b4361fa91a0","original_commit_id":"6b11c93c28240d018f727f5f089c9b4361fa91a0","user":{"login":"radiofreemattd","id":10587273,"avatar_url":"https://avatars.githubusercontent.com/u/10587273?v=3","gravatar_id":"","url":"https://api.github.com/users/radiofreemattd","html_url":"https://github.com/radiofreemattd","followers_url":"https://api.github.com/users/radiofreemattd/followers","following_url":"https://api.github.com/users/radiofreemattd/following{/other_user}","gists_url":"https://api.github.com/users/radiofreemattd/gists{/gist_id}","starred_url":"https://api.github.com/users/radiofreemattd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radiofreemattd/subscriptions","organizations_url":"https://api.github.com/users/radiofreemattd/orgs","repos_url":"https://api.github.com/users/radiofreemattd/repos","events_url":"https://api.github.com/users/radiofreemattd/events{/privacy}","received_events_url":"https://api.github.com/users/radiofreemattd/received_events","type":"User","site_admin":false},"body":"You're right :+1: ","created_at":"2015-11-26T17:00:59Z","updated_at":"2015-11-26T17:00:59Z","html_url":"https://github.com/KnightsOfTheRemoteTable/chess_app/pull/59#discussion_r45996675","pull_request_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59","_links":{"self":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/comments/45996675"},"html":{"href":"https://github.com/KnightsOfTheRemoteTable/chess_app/pull/59#discussion_r45996675"},"pull_request":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59","id":51740400,"html_url":"https://github.com/KnightsOfTheRemoteTable/chess_app/pull/59","diff_url":"https://github.com/KnightsOfTheRemoteTable/chess_app/pull/59.diff","patch_url":"https://github.com/KnightsOfTheRemoteTable/chess_app/pull/59.patch","issue_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/59","number":59,"state":"open","locked":false,"title":"Add valid_move? method to pawn","user":{"login":"jonmast","id":599037,"avatar_url":"https://avatars.githubusercontent.com/u/599037?v=3","gravatar_id":"","url":"https://api.github.com/users/jonmast","html_url":"https://github.com/jonmast","followers_url":"https://api.github.com/users/jonmast/followers","following_url":"https://api.github.com/users/jonmast/following{/other_user}","gists_url":"https://api.github.com/users/jonmast/gists{/gist_id}","starred_url":"https://api.github.com/users/jonmast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonmast/subscriptions","organizations_url":"https://api.github.com/users/jonmast/orgs","repos_url":"https://api.github.com/users/jonmast/repos","events_url":"https://api.github.com/users/jonmast/events{/privacy}","received_events_url":"https://api.github.com/users/jonmast/received_events","type":"User","site_admin":false},"body":"Thanks to @radiofreemattd for helping clean this up.","created_at":"2015-11-25T01:09:08Z","updated_at":"2015-11-26T17:00:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa728e0ee379315a91607f2b7dd51a35fa22d919","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59/commits","review_comments_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59/comments","review_comment_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/59/comments","statuses_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/statuses/6b11c93c28240d018f727f5f089c9b4361fa91a0","head":{"label":"KnightsOfTheRemoteTable:pawn_valid_move","ref":"pawn_valid_move","sha":"6b11c93c28240d018f727f5f089c9b4361fa91a0","user":{"login":"KnightsOfTheRemoteTable","id":15571644,"avatar_url":"https://avatars.githubusercontent.com/u/15571644?v=3","gravatar_id":"","url":"https://api.github.com/users/KnightsOfTheRemoteTable","html_url":"https://github.com/KnightsOfTheRemoteTable","followers_url":"https://api.github.com/users/KnightsOfTheRemoteTable/followers","following_url":"https://api.github.com/users/KnightsOfTheRemoteTable/following{/other_user}","gists_url":"https://api.github.com/users/KnightsOfTheRemoteTable/gists{/gist_id}","starred_url":"https://api.github.com/users/KnightsOfTheRemoteTable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnightsOfTheRemoteTable/subscriptions","organizations_url":"https://api.github.com/users/KnightsOfTheRemoteTable/orgs","repos_url":"https://api.github.com/users/KnightsOfTheRemoteTable/repos","events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/events{/privacy}","received_events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/received_events","type":"Organization","site_admin":false},"repo":{"id":45347594,"name":"chess_app","full_name":"KnightsOfTheRemoteTable/chess_app","owner":{"login":"KnightsOfTheRemoteTable","id":15571644,"avatar_url":"https://avatars.githubusercontent.com/u/15571644?v=3","gravatar_id":"","url":"https://api.github.com/users/KnightsOfTheRemoteTable","html_url":"https://github.com/KnightsOfTheRemoteTable","followers_url":"https://api.github.com/users/KnightsOfTheRemoteTable/followers","following_url":"https://api.github.com/users/KnightsOfTheRemoteTable/following{/other_user}","gists_url":"https://api.github.com/users/KnightsOfTheRemoteTable/gists{/gist_id}","starred_url":"https://api.github.com/users/KnightsOfTheRemoteTable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnightsOfTheRemoteTable/subscriptions","organizations_url":"https://api.github.com/users/KnightsOfTheRemoteTable/orgs","repos_url":"https://api.github.com/users/KnightsOfTheRemoteTable/repos","events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/events{/privacy}","received_events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KnightsOfTheRemoteTable/chess_app","description":"Knights of the Remote Table Awesome Chess Application","fork":false,"url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app","forks_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/forks","keys_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/teams","hooks_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/hooks","issue_events_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/events{/number}","events_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/events","assignees_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/assignees{/user}","branches_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/branches{/branch}","tags_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/tags","blobs_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/statuses/{sha}","languages_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/languages","stargazers_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/stargazers","contributors_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/contributors","subscribers_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/subscribers","subscription_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/subscription","commits_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/contents/{+path}","compare_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/merges","archive_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/downloads","issues_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues{/number}","pulls_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls{/number}","milestones_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/milestones{/number}","notifications_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/labels{/name}","releases_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/releases{/id}","created_at":"2015-11-01T16:17:34Z","updated_at":"2015-11-01T16:18:00Z","pushed_at":"2015-11-26T16:58:25Z","git_url":"git://github.com/KnightsOfTheRemoteTable/chess_app.git","ssh_url":"git@github.com:KnightsOfTheRemoteTable/chess_app.git","clone_url":"https://github.com/KnightsOfTheRemoteTable/chess_app.git","svn_url":"https://github.com/KnightsOfTheRemoteTable/chess_app","homepage":null,"size":351,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"KnightsOfTheRemoteTable:master","ref":"master","sha":"236355463b2b7462f8d722314fcc391cf0c422f3","user":{"login":"KnightsOfTheRemoteTable","id":15571644,"avatar_url":"https://avatars.githubusercontent.com/u/15571644?v=3","gravatar_id":"","url":"https://api.github.com/users/KnightsOfTheRemoteTable","html_url":"https://github.com/KnightsOfTheRemoteTable","followers_url":"https://api.github.com/users/KnightsOfTheRemoteTable/followers","following_url":"https://api.github.com/users/KnightsOfTheRemoteTable/following{/other_user}","gists_url":"https://api.github.com/users/KnightsOfTheRemoteTable/gists{/gist_id}","starred_url":"https://api.github.com/users/KnightsOfTheRemoteTable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnightsOfTheRemoteTable/subscriptions","organizations_url":"https://api.github.com/users/KnightsOfTheRemoteTable/orgs","repos_url":"https://api.github.com/users/KnightsOfTheRemoteTable/repos","events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/events{/privacy}","received_events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/received_events","type":"Organization","site_admin":false},"repo":{"id":45347594,"name":"chess_app","full_name":"KnightsOfTheRemoteTable/chess_app","owner":{"login":"KnightsOfTheRemoteTable","id":15571644,"avatar_url":"https://avatars.githubusercontent.com/u/15571644?v=3","gravatar_id":"","url":"https://api.github.com/users/KnightsOfTheRemoteTable","html_url":"https://github.com/KnightsOfTheRemoteTable","followers_url":"https://api.github.com/users/KnightsOfTheRemoteTable/followers","following_url":"https://api.github.com/users/KnightsOfTheRemoteTable/following{/other_user}","gists_url":"https://api.github.com/users/KnightsOfTheRemoteTable/gists{/gist_id}","starred_url":"https://api.github.com/users/KnightsOfTheRemoteTable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnightsOfTheRemoteTable/subscriptions","organizations_url":"https://api.github.com/users/KnightsOfTheRemoteTable/orgs","repos_url":"https://api.github.com/users/KnightsOfTheRemoteTable/repos","events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/events{/privacy}","received_events_url":"https://api.github.com/users/KnightsOfTheRemoteTable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KnightsOfTheRemoteTable/chess_app","description":"Knights of the Remote Table Awesome Chess Application","fork":false,"url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app","forks_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/forks","keys_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/teams","hooks_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/hooks","issue_events_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/events{/number}","events_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/events","assignees_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/assignees{/user}","branches_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/branches{/branch}","tags_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/tags","blobs_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/statuses/{sha}","languages_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/languages","stargazers_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/stargazers","contributors_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/contributors","subscribers_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/subscribers","subscription_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/subscription","commits_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/contents/{+path}","compare_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/merges","archive_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/downloads","issues_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues{/number}","pulls_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls{/number}","milestones_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/milestones{/number}","notifications_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/labels{/name}","releases_url":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/releases{/id}","created_at":"2015-11-01T16:17:34Z","updated_at":"2015-11-01T16:18:00Z","pushed_at":"2015-11-26T16:58:25Z","git_url":"git://github.com/KnightsOfTheRemoteTable/chess_app.git","ssh_url":"git@github.com:KnightsOfTheRemoteTable/chess_app.git","clone_url":"https://github.com/KnightsOfTheRemoteTable/chess_app.git","svn_url":"https://github.com/KnightsOfTheRemoteTable/chess_app","homepage":null,"size":351,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59"},"html":{"href":"https://github.com/KnightsOfTheRemoteTable/chess_app/pull/59"},"issue":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/59"},"comments":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/KnightsOfTheRemoteTable/chess_app/statuses/6b11c93c28240d018f727f5f089c9b4361fa91a0"}}}}