{"action":"created","comment":{"url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/comments/220758205","pull_request_review_id":159241272,"id":220758205,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMDc1ODIwNQ==","diff_hunk":"@@ -3,46 +3,38 @@ class Game < ApplicationRecord\n   has_many :pieces, dependent: :destroy\n   has_many :captured_pieces, dependent: :destroy\n   scope :available, -> { where(opponent: nil) }\n-  after_create :populate_board!\n-  # one potential limitation of this method is that pieces will only be populated if the game has a valid user_id AND an opponent\n-  def populate_board!\n-    # QUEENS - the user who created the game will be black, the opponent will be white\n+  after_create :populate_black_pieces!\n+  after_update :populate_white_pieces!\n+\n+  # upon game creation, populate the black pieces for the user who created the game\n+  def populate_black_pieces!\n     Queen.create(game_id: id, user_id: user_id, position_x: 3, position_y: 7, color: \"black\", name: \"black queen\")\n-    Queen.create(game_id: id, user_id: opponent, position_x: 3, position_y: 0, color: \"white\", name: \"white queen\")\n-    # KINGS\n     King.create(game_id: id, user_id: user_id, position_x: 4, position_y: 7, color: \"black\", name: \"black king\")\n-    King.create(game_id: id, user_id: opponent, position_x: 4, position_y: 0, color: \"white\", name: \"white king\")\n-    # BISHOPS\n-    # black bishops\n     Bishop.create(game_id: id, user_id: user_id, position_x: 2, position_y: 7, color: \"black\", name: \"black bishop 1\")\n     Bishop.create(game_id: id, user_id: user_id, position_x: 5, position_y: 7, color: \"black\", name: \"black bishop 2\")\n-    # white bishops\n-    Bishop.create(game_id: id, user_id: opponent, position_x: 2, position_y: 0, color: \"white\", name: \"white bishop 1\")\n-    Bishop.create(game_id: id, user_id: opponent, position_x: 5, position_y: 0, color: \"white\", name: \"white bishop 2\")\n-    # KNIGHTS\n-    # black knights\n     Knight.create(game_id: id, user_id: user_id, position_x: 1, position_y: 7, color: \"black\", name: \"black knight 1\")\n     Knight.create(game_id: id, user_id: user_id, position_x: 6, position_y: 7, color: \"black\", name: \"black knight 2\")\n-    # white knights\n-    Knight.create(game_id: id, user_id: opponent, position_x: 1, position_y: 0, color: \"white\", name: \"white knight 1\")\n-    Knight.create(game_id: id, user_id: opponent, position_x: 6, position_y: 0, color: \"white\", name: \"white knight 2\")\n-    # rooks\n-    # black rooks\n     Rook.create(game_id: id, user_id: user_id, position_x: 0, position_y: 7, color: \"black\", name: \"black rook 1\")\n     Rook.create(game_id: id, user_id: user_id, position_x: 7, position_y: 7, color: \"black\", name: \"black rook 2\")\n-    # white rooks\n-    Rook.create(game_id: id, user_id: opponent, position_x: 0, position_y: 0, color: \"white\", name: \"white rook 1\")\n-    Rook.create(game_id: id, user_id: opponent, position_x: 7, position_y: 0, color: \"white\", name: \"white rook 2\")\n-    # PAWNS\n-    # populate black pawns\n     black_pawn_x = 0\n     black_pawn_number = 1\n     8.times do\n       Pawn.create(game_id: id, user_id: user_id, position_x: black_pawn_x, position_y: 6, color: \"black\", name: \"black pawn #{black_pawn_number}\")\n       black_pawn_x += 1\n       black_pawn_number += 1\n     end\n-    # populate white pawns\n+  end\n+\n+  # upon game update, populate the white pieces for the opponent user who joined the game\n+  def populate_white_pieces!\n+    Queen.create(game_id: id, user_id: opponent, position_x: 3, position_y: 0, color: \"white\", name: \"white queen\")\n+    King.create(game_id: id, user_id: opponent, position_x: 4, position_y: 0, color: \"white\", name: \"white king\")\n+    Bishop.create(game_id: id, user_id: opponent, position_x: 2, position_y: 0, color: \"white\", name: \"white bishop 1\")\n+    Bishop.create(game_id: id, user_id: opponent, position_x: 5, position_y: 0, color: \"white\", name: \"white bishop 2\")\n+    Knight.create(game_id: id, user_id: opponent, position_x: 1, position_y: 0, color: \"white\", name: \"white knight 1\")\n+    Knight.create(game_id: id, user_id: opponent, position_x: 6, position_y: 0, color: \"white\", name: \"white knight 2\")\n+    Rook.create(game_id: id, user_id: opponent, position_x: 0, position_y: 0, color: \"white\", name: \"white rook 1\")\n+    Rook.create(game_id: id, user_id: opponent, position_x: 7, position_y: 0, color: \"white\", name: \"white rook 2\")\n     white_pawn_x = 0","path":"app/models/game.rb","position":61,"original_position":61,"commit_id":"d5c24293c84d5e8e7331401c0fab5c4d0f42c529","original_commit_id":"d5c24293c84d5e8e7331401c0fab5c4d0f42c529","user":{"login":"knoll3","id":34484576,"node_id":"MDQ6VXNlcjM0NDg0NTc2","avatar_url":"https://avatars1.githubusercontent.com/u/34484576?v=4","gravatar_id":"","url":"https://api.github.com/users/knoll3","html_url":"https://github.com/knoll3","followers_url":"https://api.github.com/users/knoll3/followers","following_url":"https://api.github.com/users/knoll3/following{/other_user}","gists_url":"https://api.github.com/users/knoll3/gists{/gist_id}","starred_url":"https://api.github.com/users/knoll3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoll3/subscriptions","organizations_url":"https://api.github.com/users/knoll3/orgs","repos_url":"https://api.github.com/users/knoll3/repos","events_url":"https://api.github.com/users/knoll3/events{/privacy}","received_events_url":"https://api.github.com/users/knoll3/received_events","type":"User","site_admin":false},"body":"This way all 32 pieces appear on the board when the board is rendered as would happen when playing other online chess games.","created_at":"2018-09-26T23:54:14Z","updated_at":"2018-09-26T23:54:14Z","html_url":"https://github.com/JF-Chess-Application/JFchess/pull/43#discussion_r220758205","pull_request_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/comments/220758205"},"html":{"href":"https://github.com/JF-Chess-Application/JFchess/pull/43#discussion_r220758205"},"pull_request":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43"}},"in_reply_to_id":220037486},"pull_request":{"url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43","id":217486739,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NDg2NzM5","html_url":"https://github.com/JF-Chess-Application/JFchess/pull/43","diff_url":"https://github.com/JF-Chess-Application/JFchess/pull/43.diff","patch_url":"https://github.com/JF-Chess-Application/JFchess/pull/43.patch","issue_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/43","number":43,"state":"open","locked":false,"title":"Add check to game model","user":{"login":"amyhenning","id":20273892,"node_id":"MDQ6VXNlcjIwMjczODky","avatar_url":"https://avatars3.githubusercontent.com/u/20273892?v=4","gravatar_id":"","url":"https://api.github.com/users/amyhenning","html_url":"https://github.com/amyhenning","followers_url":"https://api.github.com/users/amyhenning/followers","following_url":"https://api.github.com/users/amyhenning/following{/other_user}","gists_url":"https://api.github.com/users/amyhenning/gists{/gist_id}","starred_url":"https://api.github.com/users/amyhenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amyhenning/subscriptions","organizations_url":"https://api.github.com/users/amyhenning/orgs","repos_url":"https://api.github.com/users/amyhenning/repos","events_url":"https://api.github.com/users/amyhenning/events{/privacy}","received_events_url":"https://api.github.com/users/amyhenning/received_events","type":"User","site_admin":false},"body":"- Made several changes necessary for testing the `check?` method and its helpers\r\n- Added some (preemptive) helper methods that we may be able to use in setting up `checkmate?` later","created_at":"2018-09-23T01:14:41Z","updated_at":"2018-09-26T23:54:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"894ba9a2f3d58b1abd1111270d2cd43a9f0a28d1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43/commits","review_comments_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43/comments","review_comment_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/43/comments","statuses_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/statuses/d5c24293c84d5e8e7331401c0fab5c4d0f42c529","head":{"label":"JF-Chess-Application:add-check-to-game-model","ref":"add-check-to-game-model","sha":"d5c24293c84d5e8e7331401c0fab5c4d0f42c529","user":{"login":"JF-Chess-Application","id":42365296,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMzY1Mjk2","avatar_url":"https://avatars2.githubusercontent.com/u/42365296?v=4","gravatar_id":"","url":"https://api.github.com/users/JF-Chess-Application","html_url":"https://github.com/JF-Chess-Application","followers_url":"https://api.github.com/users/JF-Chess-Application/followers","following_url":"https://api.github.com/users/JF-Chess-Application/following{/other_user}","gists_url":"https://api.github.com/users/JF-Chess-Application/gists{/gist_id}","starred_url":"https://api.github.com/users/JF-Chess-Application/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JF-Chess-Application/subscriptions","organizations_url":"https://api.github.com/users/JF-Chess-Application/orgs","repos_url":"https://api.github.com/users/JF-Chess-Application/repos","events_url":"https://api.github.com/users/JF-Chess-Application/events{/privacy}","received_events_url":"https://api.github.com/users/JF-Chess-Application/received_events","type":"Organization","site_admin":false},"repo":{"id":144664063,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQ2NjQwNjM=","name":"JFchess","full_name":"JF-Chess-Application/JFchess","private":false,"owner":{"login":"JF-Chess-Application","id":42365296,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMzY1Mjk2","avatar_url":"https://avatars2.githubusercontent.com/u/42365296?v=4","gravatar_id":"","url":"https://api.github.com/users/JF-Chess-Application","html_url":"https://github.com/JF-Chess-Application","followers_url":"https://api.github.com/users/JF-Chess-Application/followers","following_url":"https://api.github.com/users/JF-Chess-Application/following{/other_user}","gists_url":"https://api.github.com/users/JF-Chess-Application/gists{/gist_id}","starred_url":"https://api.github.com/users/JF-Chess-Application/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JF-Chess-Application/subscriptions","organizations_url":"https://api.github.com/users/JF-Chess-Application/orgs","repos_url":"https://api.github.com/users/JF-Chess-Application/repos","events_url":"https://api.github.com/users/JF-Chess-Application/events{/privacy}","received_events_url":"https://api.github.com/users/JF-Chess-Application/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/JF-Chess-Application/JFchess","description":null,"fork":false,"url":"https://api.github.com/repos/JF-Chess-Application/JFchess","forks_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/forks","keys_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/teams","hooks_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/hooks","issue_events_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/events{/number}","events_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/events","assignees_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/assignees{/user}","branches_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/branches{/branch}","tags_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/tags","blobs_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/refs{/sha}","trees_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/statuses/{sha}","languages_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/languages","stargazers_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/stargazers","contributors_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/contributors","subscribers_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/subscribers","subscription_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/subscription","commits_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/commits{/sha}","git_commits_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/commits{/sha}","comments_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/comments{/number}","issue_comment_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/comments{/number}","contents_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/contents/{+path}","compare_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/merges","archive_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/downloads","issues_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues{/number}","pulls_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls{/number}","milestones_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/milestones{/number}","notifications_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/labels{/name}","releases_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/releases{/id}","deployments_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/deployments","created_at":"2018-08-14T03:33:10Z","updated_at":"2018-09-23T15:10:58Z","pushed_at":"2018-09-26T00:42:03Z","git_url":"git://github.com/JF-Chess-Application/JFchess.git","ssh_url":"git@github.com:JF-Chess-Application/JFchess.git","clone_url":"https://github.com/JF-Chess-Application/JFchess.git","svn_url":"https://github.com/JF-Chess-Application/JFchess","homepage":null,"size":358,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"JF-Chess-Application:master","ref":"master","sha":"7dd3caef818388fce77cb8f30171f60407944c20","user":{"login":"JF-Chess-Application","id":42365296,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMzY1Mjk2","avatar_url":"https://avatars2.githubusercontent.com/u/42365296?v=4","gravatar_id":"","url":"https://api.github.com/users/JF-Chess-Application","html_url":"https://github.com/JF-Chess-Application","followers_url":"https://api.github.com/users/JF-Chess-Application/followers","following_url":"https://api.github.com/users/JF-Chess-Application/following{/other_user}","gists_url":"https://api.github.com/users/JF-Chess-Application/gists{/gist_id}","starred_url":"https://api.github.com/users/JF-Chess-Application/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JF-Chess-Application/subscriptions","organizations_url":"https://api.github.com/users/JF-Chess-Application/orgs","repos_url":"https://api.github.com/users/JF-Chess-Application/repos","events_url":"https://api.github.com/users/JF-Chess-Application/events{/privacy}","received_events_url":"https://api.github.com/users/JF-Chess-Application/received_events","type":"Organization","site_admin":false},"repo":{"id":144664063,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQ2NjQwNjM=","name":"JFchess","full_name":"JF-Chess-Application/JFchess","private":false,"owner":{"login":"JF-Chess-Application","id":42365296,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMzY1Mjk2","avatar_url":"https://avatars2.githubusercontent.com/u/42365296?v=4","gravatar_id":"","url":"https://api.github.com/users/JF-Chess-Application","html_url":"https://github.com/JF-Chess-Application","followers_url":"https://api.github.com/users/JF-Chess-Application/followers","following_url":"https://api.github.com/users/JF-Chess-Application/following{/other_user}","gists_url":"https://api.github.com/users/JF-Chess-Application/gists{/gist_id}","starred_url":"https://api.github.com/users/JF-Chess-Application/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JF-Chess-Application/subscriptions","organizations_url":"https://api.github.com/users/JF-Chess-Application/orgs","repos_url":"https://api.github.com/users/JF-Chess-Application/repos","events_url":"https://api.github.com/users/JF-Chess-Application/events{/privacy}","received_events_url":"https://api.github.com/users/JF-Chess-Application/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/JF-Chess-Application/JFchess","description":null,"fork":false,"url":"https://api.github.com/repos/JF-Chess-Application/JFchess","forks_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/forks","keys_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/teams","hooks_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/hooks","issue_events_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/events{/number}","events_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/events","assignees_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/assignees{/user}","branches_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/branches{/branch}","tags_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/tags","blobs_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/refs{/sha}","trees_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/statuses/{sha}","languages_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/languages","stargazers_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/stargazers","contributors_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/contributors","subscribers_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/subscribers","subscription_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/subscription","commits_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/commits{/sha}","git_commits_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/git/commits{/sha}","comments_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/comments{/number}","issue_comment_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/comments{/number}","contents_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/contents/{+path}","compare_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/merges","archive_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/downloads","issues_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues{/number}","pulls_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls{/number}","milestones_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/milestones{/number}","notifications_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/labels{/name}","releases_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/releases{/id}","deployments_url":"https://api.github.com/repos/JF-Chess-Application/JFchess/deployments","created_at":"2018-08-14T03:33:10Z","updated_at":"2018-09-23T15:10:58Z","pushed_at":"2018-09-26T00:42:03Z","git_url":"git://github.com/JF-Chess-Application/JFchess.git","ssh_url":"git@github.com:JF-Chess-Application/JFchess.git","clone_url":"https://github.com/JF-Chess-Application/JFchess.git","svn_url":"https://github.com/JF-Chess-Application/JFchess","homepage":null,"size":358,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43"},"html":{"href":"https://github.com/JF-Chess-Application/JFchess/pull/43"},"issue":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/43"},"comments":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/JF-Chess-Application/JFchess/statuses/d5c24293c84d5e8e7331401c0fab5c4d0f42c529"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"knoll3"}}