{"action":"created","comment":{"url":"https://api.github.com/repos/team-rook/chess-app/pulls/comments/73193388","id":73193388,"diff_hunk":"@@ -1,18 +1,53 @@\n class King < Piece\n-  # ensures king piece can only move 1 square in any direction\n+\n   def valid_move?(x,y)\n     # checks critera for valid_move? that apply to all pieces and returns false if fails\n     return false unless super(x,y)\n     x_diff = x_diff(x)\n     y_diff = y_diff(y)\n     # returns true if moving only 1 square any direction\n-    if (x_diff <= 1) && (y_diff <= 1)\n-      return true\n-    end\n-    # returns false if not moving only 1 square any direction\n+    return true if (x_diff <= 1) && (y_diff <= 1)\n+\n+    #returns true if the king can castle\n+    return true if can_castle?(x,y)\n+\n+    # returns false if not moving only 1 square any direction and can't castle\n     return false\n   end\n \n+  def can_castle?(x,y)\n+    never_moved? && (castle_kingside?(x,y) || castle_queenside?(x,y))\n+  end\n+\n+  #determines if king is attempting to castle on the kingside\n+  def castle_kingside?(x,y)\n+    x == 6 && y == y_position && castle_rook && \\\n+    castle_rook.x_position == 7 && castle_rook.never_moved? && \\\n+    castle_rook.path_blocked?(4, y_position) == false\n+  end\n+\n+  #determines if king is attempting to castle on the queenside\n+  def castle_queenside?(x,y)\n+    x == 2 &&  y == y_position && castle_rook && \\\n+    castle_rook.x_position == 0 && castle_rook.never_moved? && \\\n+    castle_rook.path_blocked?(4, y_position) == false \n+  end\n+\n+  #determines if there is a rook to castle with\n+  def castle_rook\n+    @castle_rook = game.pieces.where(y_position: y_position, user_id: user_id, type: 'Rook').first \n+  end\n+\n+  def castle!\n+    castle_rook.move_to!((castle_rook.x_position - (castle_rook.x_position - x_position).abs + 1), y_position)\n+  end\n+\n+  def move_to!(x,y)","path":"app/models/king.rb","position":50,"original_position":50,"commit_id":"be66c7526dda7a76e7a900ea7db66c7a26c3ba6c","original_commit_id":"be66c7526dda7a76e7a900ea7db66c7a26c3ba6c","user":{"login":"jacobwgillespie","id":130874,"avatar_url":"https://avatars.githubusercontent.com/u/130874?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobwgillespie","html_url":"https://github.com/jacobwgillespie","followers_url":"https://api.github.com/users/jacobwgillespie/followers","following_url":"https://api.github.com/users/jacobwgillespie/following{/other_user}","gists_url":"https://api.github.com/users/jacobwgillespie/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobwgillespie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobwgillespie/subscriptions","organizations_url":"https://api.github.com/users/jacobwgillespie/orgs","repos_url":"https://api.github.com/users/jacobwgillespie/repos","events_url":"https://api.github.com/users/jacobwgillespie/events{/privacy}","received_events_url":"https://api.github.com/users/jacobwgillespie/received_events","type":"User","site_admin":false},"body":"It can't return after `castle!` because `castle!` only moves the rook - this still relies on `super` to move the king.","created_at":"2016-08-02T16:52:10Z","updated_at":"2016-08-02T16:52:10Z","html_url":"https://github.com/team-rook/chess-app/pull/52#discussion_r73193388","pull_request_url":"https://api.github.com/repos/team-rook/chess-app/pulls/52","_links":{"self":{"href":"https://api.github.com/repos/team-rook/chess-app/pulls/comments/73193388"},"html":{"href":"https://github.com/team-rook/chess-app/pull/52#discussion_r73193388"},"pull_request":{"href":"https://api.github.com/repos/team-rook/chess-app/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/team-rook/chess-app/pulls/52","id":79428224,"html_url":"https://github.com/team-rook/chess-app/pull/52","diff_url":"https://github.com/team-rook/chess-app/pull/52.diff","patch_url":"https://github.com/team-rook/chess-app/pull/52.patch","issue_url":"https://api.github.com/repos/team-rook/chess-app/issues/52","number":52,"state":"open","locked":false,"title":"Adding ability to castle, all tests passing so far, still need to test the move is executed correctly.","user":{"login":"hathcode","id":19431253,"avatar_url":"https://avatars.githubusercontent.com/u/19431253?v=3","gravatar_id":"","url":"https://api.github.com/users/hathcode","html_url":"https://github.com/hathcode","followers_url":"https://api.github.com/users/hathcode/followers","following_url":"https://api.github.com/users/hathcode/following{/other_user}","gists_url":"https://api.github.com/users/hathcode/gists{/gist_id}","starred_url":"https://api.github.com/users/hathcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hathcode/subscriptions","organizations_url":"https://api.github.com/users/hathcode/orgs","repos_url":"https://api.github.com/users/hathcode/repos","events_url":"https://api.github.com/users/hathcode/events{/privacy}","received_events_url":"https://api.github.com/users/hathcode/received_events","type":"User","site_admin":false},"body":"Hey team,\r\n\r\nI pushed what I have for creating the ability to castle. Is \"should\" work, but I'm missing something. It passes all previously created rspec tests( and 8 of 10 that I implemented), but will not pass the two most important tests I've created for successful castling (it only passes the tests that expect \"false\" so is it really even passing those?). Any thoughts on how to fix would be appreciated. I'm trying not to split into two sets of methods for queenside castling vs kingside castling, plus trying to keep it generic enough for both white and black users. The devil is probably somewhere in the 1% error in the code.\r\n\r\nYour thoughts? Questions?","created_at":"2016-07-29T21:37:33Z","updated_at":"2016-08-02T16:52:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"233a7f77bb46084a0af8c6090d3af16833aefe45","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/team-rook/chess-app/pulls/52/commits","review_comments_url":"https://api.github.com/repos/team-rook/chess-app/pulls/52/comments","review_comment_url":"https://api.github.com/repos/team-rook/chess-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/team-rook/chess-app/issues/52/comments","statuses_url":"https://api.github.com/repos/team-rook/chess-app/statuses/be66c7526dda7a76e7a900ea7db66c7a26c3ba6c","head":{"label":"team-rook:castle","ref":"castle","sha":"be66c7526dda7a76e7a900ea7db66c7a26c3ba6c","user":{"login":"team-rook","id":20234619,"avatar_url":"https://avatars.githubusercontent.com/u/20234619?v=3","gravatar_id":"","url":"https://api.github.com/users/team-rook","html_url":"https://github.com/team-rook","followers_url":"https://api.github.com/users/team-rook/followers","following_url":"https://api.github.com/users/team-rook/following{/other_user}","gists_url":"https://api.github.com/users/team-rook/gists{/gist_id}","starred_url":"https://api.github.com/users/team-rook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/team-rook/subscriptions","organizations_url":"https://api.github.com/users/team-rook/orgs","repos_url":"https://api.github.com/users/team-rook/repos","events_url":"https://api.github.com/users/team-rook/events{/privacy}","received_events_url":"https://api.github.com/users/team-rook/received_events","type":"Organization","site_admin":false},"repo":{"id":62354746,"name":"chess-app","full_name":"team-rook/chess-app","owner":{"login":"team-rook","id":20234619,"avatar_url":"https://avatars.githubusercontent.com/u/20234619?v=3","gravatar_id":"","url":"https://api.github.com/users/team-rook","html_url":"https://github.com/team-rook","followers_url":"https://api.github.com/users/team-rook/followers","following_url":"https://api.github.com/users/team-rook/following{/other_user}","gists_url":"https://api.github.com/users/team-rook/gists{/gist_id}","starred_url":"https://api.github.com/users/team-rook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/team-rook/subscriptions","organizations_url":"https://api.github.com/users/team-rook/orgs","repos_url":"https://api.github.com/users/team-rook/repos","events_url":"https://api.github.com/users/team-rook/events{/privacy}","received_events_url":"https://api.github.com/users/team-rook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/team-rook/chess-app","description":":tada: Chess Application","fork":false,"url":"https://api.github.com/repos/team-rook/chess-app","forks_url":"https://api.github.com/repos/team-rook/chess-app/forks","keys_url":"https://api.github.com/repos/team-rook/chess-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/team-rook/chess-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/team-rook/chess-app/teams","hooks_url":"https://api.github.com/repos/team-rook/chess-app/hooks","issue_events_url":"https://api.github.com/repos/team-rook/chess-app/issues/events{/number}","events_url":"https://api.github.com/repos/team-rook/chess-app/events","assignees_url":"https://api.github.com/repos/team-rook/chess-app/assignees{/user}","branches_url":"https://api.github.com/repos/team-rook/chess-app/branches{/branch}","tags_url":"https://api.github.com/repos/team-rook/chess-app/tags","blobs_url":"https://api.github.com/repos/team-rook/chess-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/team-rook/chess-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/team-rook/chess-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/team-rook/chess-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/team-rook/chess-app/statuses/{sha}","languages_url":"https://api.github.com/repos/team-rook/chess-app/languages","stargazers_url":"https://api.github.com/repos/team-rook/chess-app/stargazers","contributors_url":"https://api.github.com/repos/team-rook/chess-app/contributors","subscribers_url":"https://api.github.com/repos/team-rook/chess-app/subscribers","subscription_url":"https://api.github.com/repos/team-rook/chess-app/subscription","commits_url":"https://api.github.com/repos/team-rook/chess-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/team-rook/chess-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/team-rook/chess-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/team-rook/chess-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/team-rook/chess-app/contents/{+path}","compare_url":"https://api.github.com/repos/team-rook/chess-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/team-rook/chess-app/merges","archive_url":"https://api.github.com/repos/team-rook/chess-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/team-rook/chess-app/downloads","issues_url":"https://api.github.com/repos/team-rook/chess-app/issues{/number}","pulls_url":"https://api.github.com/repos/team-rook/chess-app/pulls{/number}","milestones_url":"https://api.github.com/repos/team-rook/chess-app/milestones{/number}","notifications_url":"https://api.github.com/repos/team-rook/chess-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/team-rook/chess-app/labels{/name}","releases_url":"https://api.github.com/repos/team-rook/chess-app/releases{/id}","deployments_url":"https://api.github.com/repos/team-rook/chess-app/deployments","created_at":"2016-07-01T02:02:46Z","updated_at":"2016-07-03T21:33:42Z","pushed_at":"2016-08-02T16:22:39Z","git_url":"git://github.com/team-rook/chess-app.git","ssh_url":"git@github.com:team-rook/chess-app.git","clone_url":"https://github.com/team-rook/chess-app.git","svn_url":"https://github.com/team-rook/chess-app","homepage":"https://team-rook.herokuapp.com/","size":2444,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"team-rook:master","ref":"master","sha":"7925c9febc38de6e2e276121a1622518a7f78787","user":{"login":"team-rook","id":20234619,"avatar_url":"https://avatars.githubusercontent.com/u/20234619?v=3","gravatar_id":"","url":"https://api.github.com/users/team-rook","html_url":"https://github.com/team-rook","followers_url":"https://api.github.com/users/team-rook/followers","following_url":"https://api.github.com/users/team-rook/following{/other_user}","gists_url":"https://api.github.com/users/team-rook/gists{/gist_id}","starred_url":"https://api.github.com/users/team-rook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/team-rook/subscriptions","organizations_url":"https://api.github.com/users/team-rook/orgs","repos_url":"https://api.github.com/users/team-rook/repos","events_url":"https://api.github.com/users/team-rook/events{/privacy}","received_events_url":"https://api.github.com/users/team-rook/received_events","type":"Organization","site_admin":false},"repo":{"id":62354746,"name":"chess-app","full_name":"team-rook/chess-app","owner":{"login":"team-rook","id":20234619,"avatar_url":"https://avatars.githubusercontent.com/u/20234619?v=3","gravatar_id":"","url":"https://api.github.com/users/team-rook","html_url":"https://github.com/team-rook","followers_url":"https://api.github.com/users/team-rook/followers","following_url":"https://api.github.com/users/team-rook/following{/other_user}","gists_url":"https://api.github.com/users/team-rook/gists{/gist_id}","starred_url":"https://api.github.com/users/team-rook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/team-rook/subscriptions","organizations_url":"https://api.github.com/users/team-rook/orgs","repos_url":"https://api.github.com/users/team-rook/repos","events_url":"https://api.github.com/users/team-rook/events{/privacy}","received_events_url":"https://api.github.com/users/team-rook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/team-rook/chess-app","description":":tada: Chess Application","fork":false,"url":"https://api.github.com/repos/team-rook/chess-app","forks_url":"https://api.github.com/repos/team-rook/chess-app/forks","keys_url":"https://api.github.com/repos/team-rook/chess-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/team-rook/chess-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/team-rook/chess-app/teams","hooks_url":"https://api.github.com/repos/team-rook/chess-app/hooks","issue_events_url":"https://api.github.com/repos/team-rook/chess-app/issues/events{/number}","events_url":"https://api.github.com/repos/team-rook/chess-app/events","assignees_url":"https://api.github.com/repos/team-rook/chess-app/assignees{/user}","branches_url":"https://api.github.com/repos/team-rook/chess-app/branches{/branch}","tags_url":"https://api.github.com/repos/team-rook/chess-app/tags","blobs_url":"https://api.github.com/repos/team-rook/chess-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/team-rook/chess-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/team-rook/chess-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/team-rook/chess-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/team-rook/chess-app/statuses/{sha}","languages_url":"https://api.github.com/repos/team-rook/chess-app/languages","stargazers_url":"https://api.github.com/repos/team-rook/chess-app/stargazers","contributors_url":"https://api.github.com/repos/team-rook/chess-app/contributors","subscribers_url":"https://api.github.com/repos/team-rook/chess-app/subscribers","subscription_url":"https://api.github.com/repos/team-rook/chess-app/subscription","commits_url":"https://api.github.com/repos/team-rook/chess-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/team-rook/chess-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/team-rook/chess-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/team-rook/chess-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/team-rook/chess-app/contents/{+path}","compare_url":"https://api.github.com/repos/team-rook/chess-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/team-rook/chess-app/merges","archive_url":"https://api.github.com/repos/team-rook/chess-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/team-rook/chess-app/downloads","issues_url":"https://api.github.com/repos/team-rook/chess-app/issues{/number}","pulls_url":"https://api.github.com/repos/team-rook/chess-app/pulls{/number}","milestones_url":"https://api.github.com/repos/team-rook/chess-app/milestones{/number}","notifications_url":"https://api.github.com/repos/team-rook/chess-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/team-rook/chess-app/labels{/name}","releases_url":"https://api.github.com/repos/team-rook/chess-app/releases{/id}","deployments_url":"https://api.github.com/repos/team-rook/chess-app/deployments","created_at":"2016-07-01T02:02:46Z","updated_at":"2016-07-03T21:33:42Z","pushed_at":"2016-08-02T16:22:39Z","git_url":"git://github.com/team-rook/chess-app.git","ssh_url":"git@github.com:team-rook/chess-app.git","clone_url":"https://github.com/team-rook/chess-app.git","svn_url":"https://github.com/team-rook/chess-app","homepage":"https://team-rook.herokuapp.com/","size":2444,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/team-rook/chess-app/pulls/52"},"html":{"href":"https://github.com/team-rook/chess-app/pull/52"},"issue":{"href":"https://api.github.com/repos/team-rook/chess-app/issues/52"},"comments":{"href":"https://api.github.com/repos/team-rook/chess-app/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/team-rook/chess-app/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/team-rook/chess-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/team-rook/chess-app/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/team-rook/chess-app/statuses/be66c7526dda7a76e7a900ea7db66c7a26c3ba6c"}}}}
{"actor":{"display_login":"jacobwgillespie"}}