{"action":"created","comment":{"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments/52831161","id":52831161,"diff_hunk":"@@ -0,0 +1,193 @@\n+require 'pry'\n+class Game\n+\tWIN_COMBINATIONS = [\n+\t\t\t\t\t\t\t\t\t\t\t[0,1,2],\n+\t\t\t\t\t\t\t\t\t\t\t[3,4,5],\n+\t\t\t\t\t\t\t\t\t\t\t[6,7,8],\n+\t\t\t\t\t\t\t\t\t\t\t[0,3,6],\n+\t\t\t\t\t\t\t\t\t\t\t[1,4,7],\n+\t\t\t\t\t\t\t\t\t\t\t[2,5,8],\n+\t\t\t\t\t\t\t\t\t\t\t[0,4,8],\n+\t\t\t\t\t\t\t\t\t\t\t[6,4,2]\n+\t\t\t\t\t\t\t\t\t\t\t]\n+\tDIVIDER = \"===================\\n\"\t\t\t\t\t\t\t\t\t\n+\t\t\t\t\t\t\t\t\t\t\t\n+\tattr_accessor :player_1, :player_2, :board, :war_mode, :war_stats\n+\tattr_reader :the_winner, :complete\n+\t\n+\tdef initialize(player_1=Human.new(\"X\"), player_2=Human.new(\"O\"), board=Board.new)\n+\t\t@player_1 = player_1\n+\t\t@player_2 = player_2\n+\t\t@board = board\n+\t\t@complete = false\n+\t\t@war_mode = false\n+\t\t@war_stats = {\n+\t\t\t:num_games => 0,\n+\t\t\t:x_wins => 0,\n+\t\t\t:o_wins => 0,\n+\t\t\t:draws => 0\n+\t\t}\n+\tend\n+\t\n+\tdef current_player\n+\t\tboard.turn_count.even? ? player_1 : player_2\n+\tend\n+\t\n+\tdef over?\n+\t\twon? ? true : draw?\n+\tend\n+\t\n+\tdef completed?\n+\t\twar_mode ? @complete : over?\n+\tend\n+\t\n+\tdef won?\n+\t\tWIN_COMBINATIONS.any? do |combo|\n+\t\t\tall_same?(combo, \"X\") || all_same?(combo, \"O\")\n+\t\tend\n+\tend\n+\t\n+\tdef all_same?(array, token)\n+\t\tif array.all? {|i| board.cells[i] == token}\n+\t\t\t@the_winner = token\n+\t\t\ttrue\n+\t\telse\n+\t\t\t@the_winner = nil\n+\t\t\tfalse\n+\t\tend\n+\tend\n+\t\n+\tdef draw?\n+\t\t!board.full? ? false : !won?\n+\tend\n+\t\n+\tdef winner\n+\t\twon? ? the_winner : nil","path":"lib/game.rb","position":65,"original_position":65,"commit_id":"f0eaf2f469c3f488a2c221a05c56be6488deda06","original_commit_id":"f0eaf2f469c3f488a2c221a05c56be6488deda06","user":{"login":"randallreedjr","id":2908283,"avatar_url":"https://avatars.githubusercontent.com/u/2908283?v=3","gravatar_id":"","url":"https://api.github.com/users/randallreedjr","html_url":"https://github.com/randallreedjr","followers_url":"https://api.github.com/users/randallreedjr/followers","following_url":"https://api.github.com/users/randallreedjr/following{/other_user}","gists_url":"https://api.github.com/users/randallreedjr/gists{/gist_id}","starred_url":"https://api.github.com/users/randallreedjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randallreedjr/subscriptions","organizations_url":"https://api.github.com/users/randallreedjr/orgs","repos_url":"https://api.github.com/users/randallreedjr/repos","events_url":"https://api.github.com/users/randallreedjr/events{/privacy}","received_events_url":"https://api.github.com/users/randallreedjr/received_events","type":"User","site_admin":false},"body":"When you see the pattern of a ternary operator returning `nil`, you can replace it with an inline if statement, which has the same effect.\r\n`the_winner if won?`","created_at":"2016-02-13T17:58:07Z","updated_at":"2016-02-13T17:58:07Z","html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/71#discussion_r52831161","pull_request_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71","_links":{"self":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments/52831161"},"html":{"href":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/71#discussion_r52831161"},"pull_request":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71"}}},"pull_request":{"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71","id":58530066,"html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/71","diff_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/71.diff","patch_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/71.patch","issue_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/71","number":71,"state":"open","locked":false,"title":"Done","user":{"login":"tjnz","id":5639727,"avatar_url":"https://avatars.githubusercontent.com/u/5639727?v=3","gravatar_id":"","url":"https://api.github.com/users/tjnz","html_url":"https://github.com/tjnz","followers_url":"https://api.github.com/users/tjnz/followers","following_url":"https://api.github.com/users/tjnz/following{/other_user}","gists_url":"https://api.github.com/users/tjnz/gists{/gist_id}","starred_url":"https://api.github.com/users/tjnz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjnz/subscriptions","organizations_url":"https://api.github.com/users/tjnz/orgs","repos_url":"https://api.github.com/users/tjnz/repos","events_url":"https://api.github.com/users/tjnz/events{/privacy}","received_events_url":"https://api.github.com/users/tjnz/received_events","type":"User","site_admin":false},"body":null,"created_at":"2016-02-06T20:53:21Z","updated_at":"2016-02-13T17:58:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e95fafb14a05077a628ce61229b2da2823ee4a91","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71/commits","review_comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71/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/71/comments","statuses_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/f0eaf2f469c3f488a2c221a05c56be6488deda06","head":{"label":"tjnz:master","ref":"master","sha":"f0eaf2f469c3f488a2c221a05c56be6488deda06","user":{"login":"tjnz","id":5639727,"avatar_url":"https://avatars.githubusercontent.com/u/5639727?v=3","gravatar_id":"","url":"https://api.github.com/users/tjnz","html_url":"https://github.com/tjnz","followers_url":"https://api.github.com/users/tjnz/followers","following_url":"https://api.github.com/users/tjnz/following{/other_user}","gists_url":"https://api.github.com/users/tjnz/gists{/gist_id}","starred_url":"https://api.github.com/users/tjnz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjnz/subscriptions","organizations_url":"https://api.github.com/users/tjnz/orgs","repos_url":"https://api.github.com/users/tjnz/repos","events_url":"https://api.github.com/users/tjnz/events{/privacy}","received_events_url":"https://api.github.com/users/tjnz/received_events","type":"User","site_admin":false},"repo":{"id":51110850,"name":"ttt-with-ai-project-v-000","full_name":"tjnz/ttt-with-ai-project-v-000","owner":{"login":"tjnz","id":5639727,"avatar_url":"https://avatars.githubusercontent.com/u/5639727?v=3","gravatar_id":"","url":"https://api.github.com/users/tjnz","html_url":"https://github.com/tjnz","followers_url":"https://api.github.com/users/tjnz/followers","following_url":"https://api.github.com/users/tjnz/following{/other_user}","gists_url":"https://api.github.com/users/tjnz/gists{/gist_id}","starred_url":"https://api.github.com/users/tjnz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjnz/subscriptions","organizations_url":"https://api.github.com/users/tjnz/orgs","repos_url":"https://api.github.com/users/tjnz/repos","events_url":"https://api.github.com/users/tjnz/events{/privacy}","received_events_url":"https://api.github.com/users/tjnz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tjnz/ttt-with-ai-project-v-000","description":null,"fork":true,"url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000","forks_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/forks","keys_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/teams","hooks_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/hooks","issue_events_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/issues/events{/number}","events_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/events","assignees_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/assignees{/user}","branches_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/branches{/branch}","tags_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/tags","blobs_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/git/refs{/sha}","trees_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/statuses/{sha}","languages_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/languages","stargazers_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/stargazers","contributors_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/contributors","subscribers_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/subscribers","subscription_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/subscription","commits_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/commits{/sha}","git_commits_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/git/commits{/sha}","comments_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/comments{/number}","issue_comment_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/issues/comments{/number}","contents_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/contents/{+path}","compare_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/merges","archive_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/downloads","issues_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/issues{/number}","pulls_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/pulls{/number}","milestones_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/milestones{/number}","notifications_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/labels{/name}","releases_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/releases{/id}","deployments_url":"https://api.github.com/repos/tjnz/ttt-with-ai-project-v-000/deployments","created_at":"2016-02-04T22:37:08Z","updated_at":"2016-02-11T06:46:12Z","pushed_at":"2016-02-06T20:55:09Z","git_url":"git://github.com/tjnz/ttt-with-ai-project-v-000.git","ssh_url":"git@github.com:tjnz/ttt-with-ai-project-v-000.git","clone_url":"https://github.com/tjnz/ttt-with-ai-project-v-000.git","svn_url":"https://github.com/tjnz/ttt-with-ai-project-v-000","homepage":null,"size":32,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"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":1,"default_branch":"master"}},"base":{"label":"learn-co-students:master","ref":"master","sha":"8323dbabbe4087a3987d6fc26fa444695e75f6c2","user":{"login":"learn-co-students","id":8825476,"avatar_url":"https://avatars.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://avatars.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":"2015-11-12T20:52:52Z","pushed_at":"2016-02-13T17:46:26Z","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":92,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":96,"mirror_url":null,"open_issues_count":18,"forks":96,"open_issues":18,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71"},"html":{"href":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/71"},"issue":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/71"},"comments":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/71/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/71/commits"},"statuses":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/f0eaf2f469c3f488a2c221a05c56be6488deda06"}}}}