{"action":"created","comment":{"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments/123827508","pull_request_review_id":46071341,"id":123827508,"diff_hunk":"@@ -0,0 +1,124 @@\n+class Game\n+  WIN_COMBINATIONS = [\n+    [0,1,2],\n+    [3,4,5],\n+    [6,7,8],\n+    [0,3,6],\n+    [1,4,7],\n+    [2,5,8],\n+    [0,4,8],\n+    [2,4,6],\n+  ]\n+\n+  attr_accessor :board, :player_1, :player_2\n+\n+  def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n+      @board = board\n+      @player_1 = player_1\n+      @player_2 = player_2\n+    end\n+\n+  def won?\n+    no_win = true\n+    WIN_COMBINATIONS.each do |win_array|\n+      win = []\n+      win_array.select do |position|\n+        if @board.taken?(position + 1)\n+          win << position\n+          if win.length == 3 && win_array == win && (@board.cells[win[0]] == @board.cells[win[1]] && @board.cells[win[0]] == @board.cells[win[2]])\n+            no_win = false\n+            return win_array\n+          end\n+        end\n+      end\n+    end\n+    if no_win\n+     false\n+    end\n+  end\n+\n+  def over?\n+    won? || draw?\n+  end\n+\n+  def draw?\n+    !won? && @board.full?\n+  end\n+\n+  def winner\n+    won? ? @board.position((won?[0] + 1).to_s) : nil","path":"lib/game.rb","position":49,"original_position":49,"commit_id":"b8e448c5b41ebaa2035cc6d036935ee9ea15756f","original_commit_id":"b8e448c5b41ebaa2035cc6d036935ee9ea15756f","user":{"login":"cernanb","id":7960757,"avatar_url":"https://avatars2.githubusercontent.com/u/7960757?v=3","gravatar_id":"","url":"https://api.github.com/users/cernanb","html_url":"https://github.com/cernanb","followers_url":"https://api.github.com/users/cernanb/followers","following_url":"https://api.github.com/users/cernanb/following{/other_user}","gists_url":"https://api.github.com/users/cernanb/gists{/gist_id}","starred_url":"https://api.github.com/users/cernanb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cernanb/subscriptions","organizations_url":"https://api.github.com/users/cernanb/orgs","repos_url":"https://api.github.com/users/cernanb/repos","events_url":"https://api.github.com/users/cernanb/events{/privacy}","received_events_url":"https://api.github.com/users/cernanb/received_events","type":"User","site_admin":false},"body":"Instead of calling `Game#won?` twice, consider using an if statement assignment. For example:\r\n\r\n```ruby\r\nif won = won?\r\n  board.cells[won.first]\r\nend\r\n```\r\n\r\nIf `won?` returns true, then and only then will the local variable `won` be assigned, otherwise, the method will just abort with a false return value. But if `won` is assigned, we can use that variable instead of calling `won?` again within the if statement.","created_at":"2017-06-23T19:27:25Z","updated_at":"2017-06-23T19:28:20Z","html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/510#discussion_r123827508","pull_request_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510","_links":{"self":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments/123827508"},"html":{"href":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/510#discussion_r123827508"},"pull_request":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510"}}},"pull_request":{"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510","id":123525277,"html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/510","diff_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/510.diff","patch_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/510.patch","issue_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/510","number":510,"state":"open","locked":false,"title":"Done","user":{"login":"vtsowell","id":25122363,"avatar_url":"https://avatars3.githubusercontent.com/u/25122363?v=3","gravatar_id":"","url":"https://api.github.com/users/vtsowell","html_url":"https://github.com/vtsowell","followers_url":"https://api.github.com/users/vtsowell/followers","following_url":"https://api.github.com/users/vtsowell/following{/other_user}","gists_url":"https://api.github.com/users/vtsowell/gists{/gist_id}","starred_url":"https://api.github.com/users/vtsowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtsowell/subscriptions","organizations_url":"https://api.github.com/users/vtsowell/orgs","repos_url":"https://api.github.com/users/vtsowell/repos","events_url":"https://api.github.com/users/vtsowell/events{/privacy}","received_events_url":"https://api.github.com/users/vtsowell/received_events","type":"User","site_admin":false},"body":null,"created_at":"2017-06-01T15:18:13Z","updated_at":"2017-06-23T19:28:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54ccd49a914268c876fd9893c89ff1753a669b6a","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510/commits","review_comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510/comments","review_comment_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments{/number}","comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/510/comments","statuses_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/b8e448c5b41ebaa2035cc6d036935ee9ea15756f","head":{"label":"vtsowell:master","ref":"master","sha":"b8e448c5b41ebaa2035cc6d036935ee9ea15756f","user":{"login":"vtsowell","id":25122363,"avatar_url":"https://avatars3.githubusercontent.com/u/25122363?v=3","gravatar_id":"","url":"https://api.github.com/users/vtsowell","html_url":"https://github.com/vtsowell","followers_url":"https://api.github.com/users/vtsowell/followers","following_url":"https://api.github.com/users/vtsowell/following{/other_user}","gists_url":"https://api.github.com/users/vtsowell/gists{/gist_id}","starred_url":"https://api.github.com/users/vtsowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtsowell/subscriptions","organizations_url":"https://api.github.com/users/vtsowell/orgs","repos_url":"https://api.github.com/users/vtsowell/repos","events_url":"https://api.github.com/users/vtsowell/events{/privacy}","received_events_url":"https://api.github.com/users/vtsowell/received_events","type":"User","site_admin":false},"repo":{"id":93005261,"name":"ttt-with-ai-project-v-000","full_name":"vtsowell/ttt-with-ai-project-v-000","owner":{"login":"vtsowell","id":25122363,"avatar_url":"https://avatars3.githubusercontent.com/u/25122363?v=3","gravatar_id":"","url":"https://api.github.com/users/vtsowell","html_url":"https://github.com/vtsowell","followers_url":"https://api.github.com/users/vtsowell/followers","following_url":"https://api.github.com/users/vtsowell/following{/other_user}","gists_url":"https://api.github.com/users/vtsowell/gists{/gist_id}","starred_url":"https://api.github.com/users/vtsowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtsowell/subscriptions","organizations_url":"https://api.github.com/users/vtsowell/orgs","repos_url":"https://api.github.com/users/vtsowell/repos","events_url":"https://api.github.com/users/vtsowell/events{/privacy}","received_events_url":"https://api.github.com/users/vtsowell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vtsowell/ttt-with-ai-project-v-000","description":null,"fork":true,"url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000","forks_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/forks","keys_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/teams","hooks_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/hooks","issue_events_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/issues/events{/number}","events_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/events","assignees_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/assignees{/user}","branches_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/branches{/branch}","tags_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/tags","blobs_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/git/refs{/sha}","trees_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/statuses/{sha}","languages_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/languages","stargazers_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/stargazers","contributors_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/contributors","subscribers_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/subscribers","subscription_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/subscription","commits_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/commits{/sha}","git_commits_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/git/commits{/sha}","comments_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/comments{/number}","issue_comment_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/issues/comments{/number}","contents_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/contents/{+path}","compare_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/merges","archive_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/downloads","issues_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/issues{/number}","pulls_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/pulls{/number}","milestones_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/milestones{/number}","notifications_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/labels{/name}","releases_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/releases{/id}","deployments_url":"https://api.github.com/repos/vtsowell/ttt-with-ai-project-v-000/deployments","created_at":"2017-06-01T01:49:08Z","updated_at":"2017-06-01T01:49:09Z","pushed_at":"2017-06-01T15:18:10Z","git_url":"git://github.com/vtsowell/ttt-with-ai-project-v-000.git","ssh_url":"git@github.com:vtsowell/ttt-with-ai-project-v-000.git","clone_url":"https://github.com/vtsowell/ttt-with-ai-project-v-000.git","svn_url":"https://github.com/vtsowell/ttt-with-ai-project-v-000","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"learn-co-students:master","ref":"master","sha":"7f7dd92aaea115368e91881671ec600ae1acc089","user":{"login":"learn-co-students","id":8825476,"avatar_url":"https://avatars0.githubusercontent.com/u/8825476?v=3","gravatar_id":"","url":"https://api.github.com/users/learn-co-students","html_url":"https://github.com/learn-co-students","followers_url":"https://api.github.com/users/learn-co-students/followers","following_url":"https://api.github.com/users/learn-co-students/following{/other_user}","gists_url":"https://api.github.com/users/learn-co-students/gists{/gist_id}","starred_url":"https://api.github.com/users/learn-co-students/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learn-co-students/subscriptions","organizations_url":"https://api.github.com/users/learn-co-students/orgs","repos_url":"https://api.github.com/users/learn-co-students/repos","events_url":"https://api.github.com/users/learn-co-students/events{/privacy}","received_events_url":"https://api.github.com/users/learn-co-students/received_events","type":"Organization","site_admin":false},"repo":{"id":46080145,"name":"ttt-with-ai-project-v-000","full_name":"learn-co-students/ttt-with-ai-project-v-000","owner":{"login":"learn-co-students","id":8825476,"avatar_url":"https://avatars0.githubusercontent.com/u/8825476?v=3","gravatar_id":"","url":"https://api.github.com/users/learn-co-students","html_url":"https://github.com/learn-co-students","followers_url":"https://api.github.com/users/learn-co-students/followers","following_url":"https://api.github.com/users/learn-co-students/following{/other_user}","gists_url":"https://api.github.com/users/learn-co-students/gists{/gist_id}","starred_url":"https://api.github.com/users/learn-co-students/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learn-co-students/subscriptions","organizations_url":"https://api.github.com/users/learn-co-students/orgs","repos_url":"https://api.github.com/users/learn-co-students/repos","events_url":"https://api.github.com/users/learn-co-students/events{/privacy}","received_events_url":"https://api.github.com/users/learn-co-students/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000","description":null,"fork":false,"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000","forks_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/forks","keys_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/keys{/key_id}","collaborators_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/teams","hooks_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/hooks","issue_events_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/events{/number}","events_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/events","assignees_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/assignees{/user}","branches_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/branches{/branch}","tags_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/tags","blobs_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/refs{/sha}","trees_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/trees{/sha}","statuses_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/{sha}","languages_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/languages","stargazers_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/stargazers","contributors_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/contributors","subscribers_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/subscribers","subscription_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/subscription","commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/commits{/sha}","git_commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/commits{/sha}","comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/comments{/number}","issue_comment_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/comments{/number}","contents_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/contents/{+path}","compare_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/compare/{base}...{head}","merges_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/merges","archive_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/downloads","issues_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues{/number}","pulls_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls{/number}","milestones_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/milestones{/number}","notifications_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/labels{/name}","releases_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/releases{/id}","deployments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/deployments","created_at":"2015-11-12T20:52:43Z","updated_at":"2017-01-16T05:11:51Z","pushed_at":"2017-06-23T15:04:11Z","git_url":"git://github.com/learn-co-students/ttt-with-ai-project-v-000.git","ssh_url":"git@github.com:learn-co-students/ttt-with-ai-project-v-000.git","clone_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000.git","svn_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000","homepage":null,"size":36,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":533,"mirror_url":null,"open_issues_count":346,"forks":533,"open_issues":346,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510"},"html":{"href":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/510"},"issue":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/510"},"comments":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/510/comments"},"review_comments":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510/comments"},"review_comment":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/510/commits"},"statuses":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/b8e448c5b41ebaa2035cc6d036935ee9ea15756f"}}}}
{"actor":{"display_login":"cernanb"}}