{"action":"created","comment":{"url":"https://api.github.com/repos/galc0hen/Training/pulls/comments/232454893","pull_request_review_id":173664292,"id":232454893,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjQ1NDg5Mw==","diff_hunk":"@@ -0,0 +1,157 @@\n+from random import randint\r\n+from collections import namedtuple\r\n+\r\n+# Size of board.\r\n+N = 3\r\n+\r\n+\r\n+class Model:\r\n+    def __init__(self):\r\n+        self.board = [[None for x in range(N)] for y in range(N)]\r\n+\r\n+    def get_board_status(self):\r\n+        return self.board\r\n+\r\n+    def update_board(self, line, col, players, curr_player):\r\n+        if self.board[line][col] is not None:\r\n+            return False\r\n+        else:\r\n+            self.board[line][col] = players[curr_player].symbol\r\n+            return True\r\n+\r\n+    def line_won(self, players, curr_player):\r\n+        for line in self.board:\r\n+            if all(x == players[curr_player].symbol for x in line):\r\n+                return True\r\n+        return False\r\n+\r\n+    def col_won(self, players, curr_player):\r\n+        for col in range(N):\r\n+            if all(line[col] == players[curr_player].symbol for line in self.board):\r\n+                return True\r\n+        return False\r\n+\r\n+    def diagonal_won(self, players, curr_player):\r\n+        # Main diagonal.\r\n+        if all(self.board[index][index] == players[curr_player].symbol for index in range(N)):\r\n+            return True\r\n+        # Opposite diagonal.\r\n+        if all(self.board[index][N-1-index] == players[curr_player].symbol for index in range(N)):\r\n+            return True\r\n+        return False\r\n+\r\n+\r\n+class View:\r\n+    def __init__(self):\r\n+        pass\r\n+\r\n+    def print_board(self, board):\r\n+        print()\r\n+        print('Board:')\r\n+        for line in board:\r\n+            for item in line:\r\n+                if item is None:\r\n+                    print('-', end='')\r\n+                else:\r\n+                    print(item, end='')\r\n+            print()\r\n+        print()\r\n+\r\n+    def declare_winner(self, players, curr_player):\r\n+        print()\r\n+        print('***')\r\n+        print(f'The winner is {players[curr_player].name}!!!')\r\n+        print('***')\r\n+\r\n+    def declare_tie(self):\r\n+        print()\r\n+        print('***')\r\n+        print('The result is a tie!!!')\r\n+        print('***')\r\n+\r\n+\r\n+class Controller:\r\n+    def __init__(self, model, view):\r\n+        self.model = model\r\n+        self.view = view\r\n+        self.players, self.curr_player = self.initiate_players()\r\n+        self.number_of_moves_left = N * N  # Equals to number of squares on board.\r\n+\r\n+    def initiate_players(self):\r\n+        Player = namedtuple('Player', 'name symbol')\r\n+        x_player_name = input('Enter X player name\\n')\r\n+        o_player_name = input('Enter O player name\\n')\r\n+        while x_player_name == o_player_name:\r\n+            o_player_name = input('Both names are the same. Choose a different name for O player\\n')\r\n+        players = [Player(name=x_player_name, symbol='x'), Player(name=o_player_name, symbol='o')]\r\n+        curr_player = randint(0, 1)\r\n+        return players, curr_player\r\n+\r\n+    def show_board(self):\r\n+        board = self.model.get_board_status()\r\n+        self.view.print_board(board)\r\n+\r\n+    def get_input(self):\r\n+        line = self.is_input_valid('line')\r\n+        col = self.is_input_valid('column')\r\n+        updated = self.model.update_board(line, col, self.players, self.curr_player)\r\n+        if not updated:\r\n+            print(f'{self.players[self.curr_player].name}, you entered a taken spot on the board, try again')\r\n+            return False\r\n+        return True\r\n+\r\n+    def is_input_valid(self, input_type):\r","path":"XO.py","position":103,"original_position":103,"commit_id":"d3029dd087fc33b5a1d5b588fc9dfa2f99bf1ff4","original_commit_id":"d3029dd087fc33b5a1d5b588fc9dfa2f99bf1ff4","user":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2018-11-10T15:13:37Z","updated_at":"2018-11-10T15:13:37Z","html_url":"https://github.com/galc0hen/Training/pull/3#discussion_r232454893","pull_request_url":"https://api.github.com/repos/galc0hen/Training/pulls/3","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/galc0hen/Training/pulls/comments/232454893"},"html":{"href":"https://github.com/galc0hen/Training/pull/3#discussion_r232454893"},"pull_request":{"href":"https://api.github.com/repos/galc0hen/Training/pulls/3"}},"in_reply_to_id":232274048},"pull_request":{"url":"https://api.github.com/repos/galc0hen/Training/pulls/3","id":220948826,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwOTQ4ODI2","html_url":"https://github.com/galc0hen/Training/pull/3","diff_url":"https://github.com/galc0hen/Training/pull/3.diff","patch_url":"https://github.com/galc0hen/Training/pull/3.patch","issue_url":"https://api.github.com/repos/galc0hen/Training/issues/3","number":3,"state":"open","locked":false,"title":"xo_1","user":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-07T13:42:17Z","updated_at":"2018-11-10T15:13:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bfd43c30b7b89e586f92c6822a41f87739f8ca72","assignee":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"assignees":[{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/galc0hen/Training/pulls/3/commits","review_comments_url":"https://api.github.com/repos/galc0hen/Training/pulls/3/comments","review_comment_url":"https://api.github.com/repos/galc0hen/Training/pulls/comments{/number}","comments_url":"https://api.github.com/repos/galc0hen/Training/issues/3/comments","statuses_url":"https://api.github.com/repos/galc0hen/Training/statuses/d3029dd087fc33b5a1d5b588fc9dfa2f99bf1ff4","head":{"label":"galc0hen:xo_1","ref":"xo_1","sha":"d3029dd087fc33b5a1d5b588fc9dfa2f99bf1ff4","user":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"repo":{"id":151850906,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE4NTA5MDY=","name":"Training","full_name":"galc0hen/Training","private":false,"owner":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"html_url":"https://github.com/galc0hen/Training","description":"My training exercises","fork":false,"url":"https://api.github.com/repos/galc0hen/Training","forks_url":"https://api.github.com/repos/galc0hen/Training/forks","keys_url":"https://api.github.com/repos/galc0hen/Training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/galc0hen/Training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/galc0hen/Training/teams","hooks_url":"https://api.github.com/repos/galc0hen/Training/hooks","issue_events_url":"https://api.github.com/repos/galc0hen/Training/issues/events{/number}","events_url":"https://api.github.com/repos/galc0hen/Training/events","assignees_url":"https://api.github.com/repos/galc0hen/Training/assignees{/user}","branches_url":"https://api.github.com/repos/galc0hen/Training/branches{/branch}","tags_url":"https://api.github.com/repos/galc0hen/Training/tags","blobs_url":"https://api.github.com/repos/galc0hen/Training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/galc0hen/Training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/galc0hen/Training/git/refs{/sha}","trees_url":"https://api.github.com/repos/galc0hen/Training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/galc0hen/Training/statuses/{sha}","languages_url":"https://api.github.com/repos/galc0hen/Training/languages","stargazers_url":"https://api.github.com/repos/galc0hen/Training/stargazers","contributors_url":"https://api.github.com/repos/galc0hen/Training/contributors","subscribers_url":"https://api.github.com/repos/galc0hen/Training/subscribers","subscription_url":"https://api.github.com/repos/galc0hen/Training/subscription","commits_url":"https://api.github.com/repos/galc0hen/Training/commits{/sha}","git_commits_url":"https://api.github.com/repos/galc0hen/Training/git/commits{/sha}","comments_url":"https://api.github.com/repos/galc0hen/Training/comments{/number}","issue_comment_url":"https://api.github.com/repos/galc0hen/Training/issues/comments{/number}","contents_url":"https://api.github.com/repos/galc0hen/Training/contents/{+path}","compare_url":"https://api.github.com/repos/galc0hen/Training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/galc0hen/Training/merges","archive_url":"https://api.github.com/repos/galc0hen/Training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/galc0hen/Training/downloads","issues_url":"https://api.github.com/repos/galc0hen/Training/issues{/number}","pulls_url":"https://api.github.com/repos/galc0hen/Training/pulls{/number}","milestones_url":"https://api.github.com/repos/galc0hen/Training/milestones{/number}","notifications_url":"https://api.github.com/repos/galc0hen/Training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/galc0hen/Training/labels{/name}","releases_url":"https://api.github.com/repos/galc0hen/Training/releases{/id}","deployments_url":"https://api.github.com/repos/galc0hen/Training/deployments","created_at":"2018-10-06T15:01:07Z","updated_at":"2018-10-06T15:01:09Z","pushed_at":"2018-11-04T17:56:51Z","git_url":"git://github.com/galc0hen/Training.git","ssh_url":"git@github.com:galc0hen/Training.git","clone_url":"https://github.com/galc0hen/Training.git","svn_url":"https://github.com/galc0hen/Training","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":7,"license":null,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"base":{"label":"galc0hen:master","ref":"master","sha":"202cadb7b7086ab7f7d76928394c86351c22879b","user":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"repo":{"id":151850906,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE4NTA5MDY=","name":"Training","full_name":"galc0hen/Training","private":false,"owner":{"login":"galc0hen","id":29172851,"node_id":"MDQ6VXNlcjI5MTcyODUx","avatar_url":"https://avatars0.githubusercontent.com/u/29172851?v=4","gravatar_id":"","url":"https://api.github.com/users/galc0hen","html_url":"https://github.com/galc0hen","followers_url":"https://api.github.com/users/galc0hen/followers","following_url":"https://api.github.com/users/galc0hen/following{/other_user}","gists_url":"https://api.github.com/users/galc0hen/gists{/gist_id}","starred_url":"https://api.github.com/users/galc0hen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galc0hen/subscriptions","organizations_url":"https://api.github.com/users/galc0hen/orgs","repos_url":"https://api.github.com/users/galc0hen/repos","events_url":"https://api.github.com/users/galc0hen/events{/privacy}","received_events_url":"https://api.github.com/users/galc0hen/received_events","type":"User","site_admin":false},"html_url":"https://github.com/galc0hen/Training","description":"My training exercises","fork":false,"url":"https://api.github.com/repos/galc0hen/Training","forks_url":"https://api.github.com/repos/galc0hen/Training/forks","keys_url":"https://api.github.com/repos/galc0hen/Training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/galc0hen/Training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/galc0hen/Training/teams","hooks_url":"https://api.github.com/repos/galc0hen/Training/hooks","issue_events_url":"https://api.github.com/repos/galc0hen/Training/issues/events{/number}","events_url":"https://api.github.com/repos/galc0hen/Training/events","assignees_url":"https://api.github.com/repos/galc0hen/Training/assignees{/user}","branches_url":"https://api.github.com/repos/galc0hen/Training/branches{/branch}","tags_url":"https://api.github.com/repos/galc0hen/Training/tags","blobs_url":"https://api.github.com/repos/galc0hen/Training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/galc0hen/Training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/galc0hen/Training/git/refs{/sha}","trees_url":"https://api.github.com/repos/galc0hen/Training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/galc0hen/Training/statuses/{sha}","languages_url":"https://api.github.com/repos/galc0hen/Training/languages","stargazers_url":"https://api.github.com/repos/galc0hen/Training/stargazers","contributors_url":"https://api.github.com/repos/galc0hen/Training/contributors","subscribers_url":"https://api.github.com/repos/galc0hen/Training/subscribers","subscription_url":"https://api.github.com/repos/galc0hen/Training/subscription","commits_url":"https://api.github.com/repos/galc0hen/Training/commits{/sha}","git_commits_url":"https://api.github.com/repos/galc0hen/Training/git/commits{/sha}","comments_url":"https://api.github.com/repos/galc0hen/Training/comments{/number}","issue_comment_url":"https://api.github.com/repos/galc0hen/Training/issues/comments{/number}","contents_url":"https://api.github.com/repos/galc0hen/Training/contents/{+path}","compare_url":"https://api.github.com/repos/galc0hen/Training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/galc0hen/Training/merges","archive_url":"https://api.github.com/repos/galc0hen/Training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/galc0hen/Training/downloads","issues_url":"https://api.github.com/repos/galc0hen/Training/issues{/number}","pulls_url":"https://api.github.com/repos/galc0hen/Training/pulls{/number}","milestones_url":"https://api.github.com/repos/galc0hen/Training/milestones{/number}","notifications_url":"https://api.github.com/repos/galc0hen/Training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/galc0hen/Training/labels{/name}","releases_url":"https://api.github.com/repos/galc0hen/Training/releases{/id}","deployments_url":"https://api.github.com/repos/galc0hen/Training/deployments","created_at":"2018-10-06T15:01:07Z","updated_at":"2018-10-06T15:01:09Z","pushed_at":"2018-11-04T17:56:51Z","git_url":"git://github.com/galc0hen/Training.git","ssh_url":"git@github.com:galc0hen/Training.git","clone_url":"https://github.com/galc0hen/Training.git","svn_url":"https://github.com/galc0hen/Training","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":7,"license":null,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/galc0hen/Training/pulls/3"},"html":{"href":"https://github.com/galc0hen/Training/pull/3"},"issue":{"href":"https://api.github.com/repos/galc0hen/Training/issues/3"},"comments":{"href":"https://api.github.com/repos/galc0hen/Training/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/galc0hen/Training/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/galc0hen/Training/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/galc0hen/Training/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/galc0hen/Training/statuses/d3029dd087fc33b5a1d5b588fc9dfa2f99bf1ff4"}},"author_association":"OWNER"}}
{"actor":{"display_login":"galc0hen"}}