{"action":"created","comment":{"url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/comments/64251721","id":64251721,"diff_hunk":"@@ -0,0 +1,80 @@\n+module Codebreaker\n+  class Console\n+    attr_accessor :game\n+\n+    def initialize\n+      @game = Game.new\n+    end\n+\n+    def play\n+      puts \"Welcome to the game codebreaker!\\n\"\n+      puts 'Enter your name:'\n+      game.name = gets.chomp\n+      new_game\n+    end\n+\n+    def new_game\n+      game.start\n+      say(get_choice) while game.status == :play\n+      game.save if ask :save?\n+      if ask(:play_again?)\n+        new_game\n+      else\n+        say(:scores)\n+        say(:goodby)\n+      end\n+    end\n+\n+    def messages\n+      {\n+          win: 'You win!',\n+          lose: 'Game over, you are lose.',\n+          play_again?: 'Do you want play again?(yes/no)',\n+          again?: 'Do you want play again?(yes/no)',\n+          save?: 'Do you want to save result?(yes/no)',\n+          scores: \"BEST SCORES\\n#{game.score}\",\n+          goodby: \"Goodby #{game.name}\"\n+      }\n+    end\n+\n+    def say(message)\n+      if messages.has_key? message\n+        puts messages[message]\n+        true\n+      else\n+        false\n+      end\n+    end\n+\n+    def ask(question)\n+      ['yes','y'].include? gets.chomp if say question\n+    end\n+\n+    def get_choice\n+      puts 'Enter your choice:'\n+      choice = gets.chomp\n+      if game.valid_code? choice\n+        answer = game.check(choice)\n+        answer = 'Nothing matched' if answer.empty?\n+        puts \"answer: #{answer}. #{game.attempts} attempts left\" if game.status == :play\n+        answer\n+      elsif choice == 'q' || choice == 'quit'","path":"lib/codebreaker/console.rb","position":61,"original_position":61,"commit_id":"ba289f288dd236fa55052ea4578a39746e683a0b","original_commit_id":"ba289f288dd236fa55052ea4578a39746e683a0b","user":{"login":"yamnich","id":1251643,"avatar_url":"https://avatars.githubusercontent.com/u/1251643?v=3","gravatar_id":"","url":"https://api.github.com/users/yamnich","html_url":"https://github.com/yamnich","followers_url":"https://api.github.com/users/yamnich/followers","following_url":"https://api.github.com/users/yamnich/following{/other_user}","gists_url":"https://api.github.com/users/yamnich/gists{/gist_id}","starred_url":"https://api.github.com/users/yamnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamnich/subscriptions","organizations_url":"https://api.github.com/users/yamnich/orgs","repos_url":"https://api.github.com/users/yamnich/repos","events_url":"https://api.github.com/users/yamnich/events{/privacy}","received_events_url":"https://api.github.com/users/yamnich/received_events","type":"User","site_admin":false},"body":"include?\r\n","created_at":"2016-05-23T17:02:40Z","updated_at":"2016-05-23T17:02:40Z","html_url":"https://github.com/andy1341/mycodebreaker/pull/1#discussion_r64251721","pull_request_url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/comments/64251721"},"html":{"href":"https://github.com/andy1341/mycodebreaker/pull/1#discussion_r64251721"},"pull_request":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1","id":71083573,"html_url":"https://github.com/andy1341/mycodebreaker/pull/1","diff_url":"https://github.com/andy1341/mycodebreaker/pull/1.diff","patch_url":"https://github.com/andy1341/mycodebreaker/pull/1.patch","issue_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues/1","number":1,"state":"open","locked":false,"title":"Realise","user":{"login":"andy1341","id":12830139,"avatar_url":"https://avatars.githubusercontent.com/u/12830139?v=3","gravatar_id":"","url":"https://api.github.com/users/andy1341","html_url":"https://github.com/andy1341","followers_url":"https://api.github.com/users/andy1341/followers","following_url":"https://api.github.com/users/andy1341/following{/other_user}","gists_url":"https://api.github.com/users/andy1341/gists{/gist_id}","starred_url":"https://api.github.com/users/andy1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy1341/subscriptions","organizations_url":"https://api.github.com/users/andy1341/orgs","repos_url":"https://api.github.com/users/andy1341/repos","events_url":"https://api.github.com/users/andy1341/events{/privacy}","received_events_url":"https://api.github.com/users/andy1341/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-23T16:58:15Z","updated_at":"2016-05-23T17:02:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues/1/comments","statuses_url":"https://api.github.com/repos/andy1341/mycodebreaker/statuses/ba289f288dd236fa55052ea4578a39746e683a0b","head":{"label":"andy1341:realise","ref":"realise","sha":"ba289f288dd236fa55052ea4578a39746e683a0b","user":{"login":"andy1341","id":12830139,"avatar_url":"https://avatars.githubusercontent.com/u/12830139?v=3","gravatar_id":"","url":"https://api.github.com/users/andy1341","html_url":"https://github.com/andy1341","followers_url":"https://api.github.com/users/andy1341/followers","following_url":"https://api.github.com/users/andy1341/following{/other_user}","gists_url":"https://api.github.com/users/andy1341/gists{/gist_id}","starred_url":"https://api.github.com/users/andy1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy1341/subscriptions","organizations_url":"https://api.github.com/users/andy1341/orgs","repos_url":"https://api.github.com/users/andy1341/repos","events_url":"https://api.github.com/users/andy1341/events{/privacy}","received_events_url":"https://api.github.com/users/andy1341/received_events","type":"User","site_admin":false},"repo":{"id":59501541,"name":"mycodebreaker","full_name":"andy1341/mycodebreaker","owner":{"login":"andy1341","id":12830139,"avatar_url":"https://avatars.githubusercontent.com/u/12830139?v=3","gravatar_id":"","url":"https://api.github.com/users/andy1341","html_url":"https://github.com/andy1341","followers_url":"https://api.github.com/users/andy1341/followers","following_url":"https://api.github.com/users/andy1341/following{/other_user}","gists_url":"https://api.github.com/users/andy1341/gists{/gist_id}","starred_url":"https://api.github.com/users/andy1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy1341/subscriptions","organizations_url":"https://api.github.com/users/andy1341/orgs","repos_url":"https://api.github.com/users/andy1341/repos","events_url":"https://api.github.com/users/andy1341/events{/privacy}","received_events_url":"https://api.github.com/users/andy1341/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andy1341/mycodebreaker","description":"","fork":false,"url":"https://api.github.com/repos/andy1341/mycodebreaker","forks_url":"https://api.github.com/repos/andy1341/mycodebreaker/forks","keys_url":"https://api.github.com/repos/andy1341/mycodebreaker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andy1341/mycodebreaker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andy1341/mycodebreaker/teams","hooks_url":"https://api.github.com/repos/andy1341/mycodebreaker/hooks","issue_events_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues/events{/number}","events_url":"https://api.github.com/repos/andy1341/mycodebreaker/events","assignees_url":"https://api.github.com/repos/andy1341/mycodebreaker/assignees{/user}","branches_url":"https://api.github.com/repos/andy1341/mycodebreaker/branches{/branch}","tags_url":"https://api.github.com/repos/andy1341/mycodebreaker/tags","blobs_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/refs{/sha}","trees_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andy1341/mycodebreaker/statuses/{sha}","languages_url":"https://api.github.com/repos/andy1341/mycodebreaker/languages","stargazers_url":"https://api.github.com/repos/andy1341/mycodebreaker/stargazers","contributors_url":"https://api.github.com/repos/andy1341/mycodebreaker/contributors","subscribers_url":"https://api.github.com/repos/andy1341/mycodebreaker/subscribers","subscription_url":"https://api.github.com/repos/andy1341/mycodebreaker/subscription","commits_url":"https://api.github.com/repos/andy1341/mycodebreaker/commits{/sha}","git_commits_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/commits{/sha}","comments_url":"https://api.github.com/repos/andy1341/mycodebreaker/comments{/number}","issue_comment_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues/comments{/number}","contents_url":"https://api.github.com/repos/andy1341/mycodebreaker/contents/{+path}","compare_url":"https://api.github.com/repos/andy1341/mycodebreaker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andy1341/mycodebreaker/merges","archive_url":"https://api.github.com/repos/andy1341/mycodebreaker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andy1341/mycodebreaker/downloads","issues_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues{/number}","pulls_url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls{/number}","milestones_url":"https://api.github.com/repos/andy1341/mycodebreaker/milestones{/number}","notifications_url":"https://api.github.com/repos/andy1341/mycodebreaker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andy1341/mycodebreaker/labels{/name}","releases_url":"https://api.github.com/repos/andy1341/mycodebreaker/releases{/id}","deployments_url":"https://api.github.com/repos/andy1341/mycodebreaker/deployments","created_at":"2016-05-23T16:56:31Z","updated_at":"2016-05-23T16:56:31Z","pushed_at":"2016-05-23T16:56:32Z","git_url":"git://github.com/andy1341/mycodebreaker.git","ssh_url":"git@github.com:andy1341/mycodebreaker.git","clone_url":"https://github.com/andy1341/mycodebreaker.git","svn_url":"https://github.com/andy1341/mycodebreaker","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"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":"andy1341:master","ref":"master","sha":"1a76b1577fe117fc57c93624a2ec50d3825fb06a","user":{"login":"andy1341","id":12830139,"avatar_url":"https://avatars.githubusercontent.com/u/12830139?v=3","gravatar_id":"","url":"https://api.github.com/users/andy1341","html_url":"https://github.com/andy1341","followers_url":"https://api.github.com/users/andy1341/followers","following_url":"https://api.github.com/users/andy1341/following{/other_user}","gists_url":"https://api.github.com/users/andy1341/gists{/gist_id}","starred_url":"https://api.github.com/users/andy1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy1341/subscriptions","organizations_url":"https://api.github.com/users/andy1341/orgs","repos_url":"https://api.github.com/users/andy1341/repos","events_url":"https://api.github.com/users/andy1341/events{/privacy}","received_events_url":"https://api.github.com/users/andy1341/received_events","type":"User","site_admin":false},"repo":{"id":59501541,"name":"mycodebreaker","full_name":"andy1341/mycodebreaker","owner":{"login":"andy1341","id":12830139,"avatar_url":"https://avatars.githubusercontent.com/u/12830139?v=3","gravatar_id":"","url":"https://api.github.com/users/andy1341","html_url":"https://github.com/andy1341","followers_url":"https://api.github.com/users/andy1341/followers","following_url":"https://api.github.com/users/andy1341/following{/other_user}","gists_url":"https://api.github.com/users/andy1341/gists{/gist_id}","starred_url":"https://api.github.com/users/andy1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy1341/subscriptions","organizations_url":"https://api.github.com/users/andy1341/orgs","repos_url":"https://api.github.com/users/andy1341/repos","events_url":"https://api.github.com/users/andy1341/events{/privacy}","received_events_url":"https://api.github.com/users/andy1341/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andy1341/mycodebreaker","description":"","fork":false,"url":"https://api.github.com/repos/andy1341/mycodebreaker","forks_url":"https://api.github.com/repos/andy1341/mycodebreaker/forks","keys_url":"https://api.github.com/repos/andy1341/mycodebreaker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andy1341/mycodebreaker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andy1341/mycodebreaker/teams","hooks_url":"https://api.github.com/repos/andy1341/mycodebreaker/hooks","issue_events_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues/events{/number}","events_url":"https://api.github.com/repos/andy1341/mycodebreaker/events","assignees_url":"https://api.github.com/repos/andy1341/mycodebreaker/assignees{/user}","branches_url":"https://api.github.com/repos/andy1341/mycodebreaker/branches{/branch}","tags_url":"https://api.github.com/repos/andy1341/mycodebreaker/tags","blobs_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/refs{/sha}","trees_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andy1341/mycodebreaker/statuses/{sha}","languages_url":"https://api.github.com/repos/andy1341/mycodebreaker/languages","stargazers_url":"https://api.github.com/repos/andy1341/mycodebreaker/stargazers","contributors_url":"https://api.github.com/repos/andy1341/mycodebreaker/contributors","subscribers_url":"https://api.github.com/repos/andy1341/mycodebreaker/subscribers","subscription_url":"https://api.github.com/repos/andy1341/mycodebreaker/subscription","commits_url":"https://api.github.com/repos/andy1341/mycodebreaker/commits{/sha}","git_commits_url":"https://api.github.com/repos/andy1341/mycodebreaker/git/commits{/sha}","comments_url":"https://api.github.com/repos/andy1341/mycodebreaker/comments{/number}","issue_comment_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues/comments{/number}","contents_url":"https://api.github.com/repos/andy1341/mycodebreaker/contents/{+path}","compare_url":"https://api.github.com/repos/andy1341/mycodebreaker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andy1341/mycodebreaker/merges","archive_url":"https://api.github.com/repos/andy1341/mycodebreaker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andy1341/mycodebreaker/downloads","issues_url":"https://api.github.com/repos/andy1341/mycodebreaker/issues{/number}","pulls_url":"https://api.github.com/repos/andy1341/mycodebreaker/pulls{/number}","milestones_url":"https://api.github.com/repos/andy1341/mycodebreaker/milestones{/number}","notifications_url":"https://api.github.com/repos/andy1341/mycodebreaker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andy1341/mycodebreaker/labels{/name}","releases_url":"https://api.github.com/repos/andy1341/mycodebreaker/releases{/id}","deployments_url":"https://api.github.com/repos/andy1341/mycodebreaker/deployments","created_at":"2016-05-23T16:56:31Z","updated_at":"2016-05-23T16:56:31Z","pushed_at":"2016-05-23T16:56:32Z","git_url":"git://github.com/andy1341/mycodebreaker.git","ssh_url":"git@github.com:andy1341/mycodebreaker.git","clone_url":"https://github.com/andy1341/mycodebreaker.git","svn_url":"https://github.com/andy1341/mycodebreaker","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"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/andy1341/mycodebreaker/pulls/1"},"html":{"href":"https://github.com/andy1341/mycodebreaker/pull/1"},"issue":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/issues/1"},"comments":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andy1341/mycodebreaker/statuses/ba289f288dd236fa55052ea4578a39746e683a0b"}}}}
{"actor":{"display_login":"yamnich"}}