{"action":"created","comment":{"url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/comments/77678650","id":77678650,"diff_hunk":"@@ -1,48 +1,158 @@\n-export class Monopoly {\n+import BoardState from \"./boardState\";\n+import Player from \"./player\";\n+import fs from 'fs';\n+import events from 'events';\n+\n+export default class Monopoly {\n   constructor(){\n-    this.PropertyList = null;\n+    this.PropertyArray = null;\n     this.ChanceList = null;\n     this.CommChestList = null;\n-    this.PlayerList = null;\n+    this.PlayerArray = new Array(0);\n+    this.currentPlayer = null;\n+    this.Emitter = new events();\n   }\n \n-  loadPlayer(){}\n+  loadPlayer(name, regID, socketID){\n+    const regArray = JSON.parse(fs.readFileSync('./dist/regIDArray.json'));\n+    //TODO: Check for registered ID\n+    if(regArray.indexOf(regID) >= 0){\n+      this.PlayerArray.push(new Player(name, regID, socketID));\n+      console.log('Player ' + this.PlayerArray[this.PlayerArray.length - 1].person + ' added.');\n+      if(regArray.length == this.PlayerArray.length){\n+        console.log('runGame');\n+        this.runGame();\n+        return this;\n+      }\n+      return this;\n+    }\n+    //TODO if all ID's are registered, runGame;\n+    return this;\n+  }\n \n   runGame(){\n-    cleanBoard();\n+    this.cleanBoard();\n \n-    findFirstPlayer();\n+    this.findFirstPlayer();\n \n-    while(PlayerList.length > 1){\n-      runTurn(PlayerList.current);\n-      PlayerList.Current = PlayerList.Current.Next;//or next index or w.e. I use\n+    while(this.PlayerArray.length > 1){\n+      if(this.PlayerArray[this.currentPlayer].money < 0){//test\n+        this.PlayerArray.splice(this.currentPlayer, 1);\n+        continue;\n+      }\n+      this.runTurn(this.PlayerArray[this.currentPlayer]);\n+      this.currentPlayer++;//or next index or w.e. I use\n+      if(this.PlayerArray.length >= this.currentPlayer){\n+        this.currentPlayer = 0;\n+      }\n     }\n \n-    //add wincount;\n+    //TODO add wincount;\n   }\n \n-  runTurn(){\n-    \n+  runTurn(ActivePlayer){\n+    const thisGame = this;//because 'this' breaks with the event\n+    console.log('runTurn for ' + ActivePlayer.person + '. Player position: ' + ActivePlayer.position);//test\n+\n+    this.Emitter.once('rollDice', function(){\n+      thisGame.toggleListenersOff();\n+\n+      let diceArray = thisGame.rollDice();\n+      console.log('dice: ' + diceArray.reduce(( acc, cur ) => acc + cur, 0));//test\n+      ActivePlayer.movePlayer(diceArray, thisGame.PropertyArray.length);\n+      console.log('new position ' + ActivePlayer.position);//test\n+      ActivePlayer.money -= diceArray.reduce(( acc, cur ) => acc + cur, 0) * 10;//test\n+//      thisGame.landOnFunction(ActivePlayer);TODO\n+\n+      if(diceArray.every(element => element == diceArray[0])){//probably too much.  allows for more than 2 dice\n+        if(++ActivePlayer.doubles >= 3){\n+          ActivePlayer.doubles = 0;\n+          thisGame.goToJail(ActivePlayer);\n+          return this;\n+        }\n+        else {\n+          thisGame.runTurn(ActivePlayer);\n+          return this;\n+        }\n+      }","path":"src/monopoly.js","position":77,"original_position":89,"commit_id":"c91e381239e0a50b764b389413955a5bb0c46d1d","original_commit_id":"c91e381239e0a50b764b389413955a5bb0c46d1d","user":{"login":"jacobgardner","id":245622,"avatar_url":"https://avatars.githubusercontent.com/u/245622?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobgardner","html_url":"https://github.com/jacobgardner","followers_url":"https://api.github.com/users/jacobgardner/followers","following_url":"https://api.github.com/users/jacobgardner/following{/other_user}","gists_url":"https://api.github.com/users/jacobgardner/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobgardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobgardner/subscriptions","organizations_url":"https://api.github.com/users/jacobgardner/orgs","repos_url":"https://api.github.com/users/jacobgardner/repos","events_url":"https://api.github.com/users/jacobgardner/events{/privacy}","received_events_url":"https://api.github.com/users/jacobgardner/received_events","type":"User","site_admin":false},"body":"I think if you make this: \r\n```\r\n} else {\r\nactivePlayer.doubles = 0;\r\n}\r\n```\r\nyou can get rid of the other two return statements and just have them all flow to this one.  ","created_at":"2016-09-06T17:17:03Z","updated_at":"2016-09-06T17:17:03Z","html_url":"https://github.com/jacobgardner/monopoly-server/pull/1#discussion_r77678650","pull_request_url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/comments/77678650"},"html":{"href":"https://github.com/jacobgardner/monopoly-server/pull/1#discussion_r77678650"},"pull_request":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1","id":82773404,"html_url":"https://github.com/jacobgardner/monopoly-server/pull/1","diff_url":"https://github.com/jacobgardner/monopoly-server/pull/1.diff","patch_url":"https://github.com/jacobgardner/monopoly-server/pull/1.patch","issue_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/1","number":1,"state":"open","locked":false,"title":"Review of latest files. ","user":{"login":"jacobgardner","id":245622,"avatar_url":"https://avatars.githubusercontent.com/u/245622?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobgardner","html_url":"https://github.com/jacobgardner","followers_url":"https://api.github.com/users/jacobgardner/followers","following_url":"https://api.github.com/users/jacobgardner/following{/other_user}","gists_url":"https://api.github.com/users/jacobgardner/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobgardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobgardner/subscriptions","organizations_url":"https://api.github.com/users/jacobgardner/orgs","repos_url":"https://api.github.com/users/jacobgardner/repos","events_url":"https://api.github.com/users/jacobgardner/events{/privacy}","received_events_url":"https://api.github.com/users/jacobgardner/received_events","type":"User","site_admin":false},"body":"Created a PR to a different branch because it's easier to review. ","created_at":"2016-08-25T18:54:56Z","updated_at":"2016-09-06T17:17:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64f94c1736310ff60356dd8de306a04a3452e43e","assignee":{"login":"jrhii","id":12740104,"avatar_url":"https://avatars.githubusercontent.com/u/12740104?v=3","gravatar_id":"","url":"https://api.github.com/users/jrhii","html_url":"https://github.com/jrhii","followers_url":"https://api.github.com/users/jrhii/followers","following_url":"https://api.github.com/users/jrhii/following{/other_user}","gists_url":"https://api.github.com/users/jrhii/gists{/gist_id}","starred_url":"https://api.github.com/users/jrhii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrhii/subscriptions","organizations_url":"https://api.github.com/users/jrhii/orgs","repos_url":"https://api.github.com/users/jrhii/repos","events_url":"https://api.github.com/users/jrhii/events{/privacy}","received_events_url":"https://api.github.com/users/jrhii/received_events","type":"User","site_admin":false},"assignees":[{"login":"jrhii","id":12740104,"avatar_url":"https://avatars.githubusercontent.com/u/12740104?v=3","gravatar_id":"","url":"https://api.github.com/users/jrhii","html_url":"https://github.com/jrhii","followers_url":"https://api.github.com/users/jrhii/followers","following_url":"https://api.github.com/users/jrhii/following{/other_user}","gists_url":"https://api.github.com/users/jrhii/gists{/gist_id}","starred_url":"https://api.github.com/users/jrhii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrhii/subscriptions","organizations_url":"https://api.github.com/users/jrhii/orgs","repos_url":"https://api.github.com/users/jrhii/repos","events_url":"https://api.github.com/users/jrhii/events{/privacy}","received_events_url":"https://api.github.com/users/jrhii/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/1/comments","statuses_url":"https://api.github.com/repos/jacobgardner/monopoly-server/statuses/c91e381239e0a50b764b389413955a5bb0c46d1d","head":{"label":"jacobgardner:master","ref":"master","sha":"c91e381239e0a50b764b389413955a5bb0c46d1d","user":{"login":"jacobgardner","id":245622,"avatar_url":"https://avatars.githubusercontent.com/u/245622?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobgardner","html_url":"https://github.com/jacobgardner","followers_url":"https://api.github.com/users/jacobgardner/followers","following_url":"https://api.github.com/users/jacobgardner/following{/other_user}","gists_url":"https://api.github.com/users/jacobgardner/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobgardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobgardner/subscriptions","organizations_url":"https://api.github.com/users/jacobgardner/orgs","repos_url":"https://api.github.com/users/jacobgardner/repos","events_url":"https://api.github.com/users/jacobgardner/events{/privacy}","received_events_url":"https://api.github.com/users/jacobgardner/received_events","type":"User","site_admin":false},"repo":{"id":64439341,"name":"monopoly-server","full_name":"jacobgardner/monopoly-server","owner":{"login":"jacobgardner","id":245622,"avatar_url":"https://avatars.githubusercontent.com/u/245622?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobgardner","html_url":"https://github.com/jacobgardner","followers_url":"https://api.github.com/users/jacobgardner/followers","following_url":"https://api.github.com/users/jacobgardner/following{/other_user}","gists_url":"https://api.github.com/users/jacobgardner/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobgardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobgardner/subscriptions","organizations_url":"https://api.github.com/users/jacobgardner/orgs","repos_url":"https://api.github.com/users/jacobgardner/repos","events_url":"https://api.github.com/users/jacobgardner/events{/privacy}","received_events_url":"https://api.github.com/users/jacobgardner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacobgardner/monopoly-server","description":"Jim's Monopoly Server","fork":false,"url":"https://api.github.com/repos/jacobgardner/monopoly-server","forks_url":"https://api.github.com/repos/jacobgardner/monopoly-server/forks","keys_url":"https://api.github.com/repos/jacobgardner/monopoly-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacobgardner/monopoly-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacobgardner/monopoly-server/teams","hooks_url":"https://api.github.com/repos/jacobgardner/monopoly-server/hooks","issue_events_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/events{/number}","events_url":"https://api.github.com/repos/jacobgardner/monopoly-server/events","assignees_url":"https://api.github.com/repos/jacobgardner/monopoly-server/assignees{/user}","branches_url":"https://api.github.com/repos/jacobgardner/monopoly-server/branches{/branch}","tags_url":"https://api.github.com/repos/jacobgardner/monopoly-server/tags","blobs_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacobgardner/monopoly-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jacobgardner/monopoly-server/languages","stargazers_url":"https://api.github.com/repos/jacobgardner/monopoly-server/stargazers","contributors_url":"https://api.github.com/repos/jacobgardner/monopoly-server/contributors","subscribers_url":"https://api.github.com/repos/jacobgardner/monopoly-server/subscribers","subscription_url":"https://api.github.com/repos/jacobgardner/monopoly-server/subscription","commits_url":"https://api.github.com/repos/jacobgardner/monopoly-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacobgardner/monopoly-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacobgardner/monopoly-server/contents/{+path}","compare_url":"https://api.github.com/repos/jacobgardner/monopoly-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacobgardner/monopoly-server/merges","archive_url":"https://api.github.com/repos/jacobgardner/monopoly-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacobgardner/monopoly-server/downloads","issues_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues{/number}","pulls_url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jacobgardner/monopoly-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jacobgardner/monopoly-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacobgardner/monopoly-server/labels{/name}","releases_url":"https://api.github.com/repos/jacobgardner/monopoly-server/releases{/id}","deployments_url":"https://api.github.com/repos/jacobgardner/monopoly-server/deployments","created_at":"2016-07-29T01:13:07Z","updated_at":"2016-07-29T01:41:12Z","pushed_at":"2016-09-04T06:17:53Z","git_url":"git://github.com/jacobgardner/monopoly-server.git","ssh_url":"git@github.com:jacobgardner/monopoly-server.git","clone_url":"https://github.com/jacobgardner/monopoly-server.git","svn_url":"https://github.com/jacobgardner/monopoly-server","homepage":null,"size":27,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"jacobgardner:develop","ref":"develop","sha":"3e307b3c0248ed96c1e4684d9b2bd6d4f3e93daa","user":{"login":"jacobgardner","id":245622,"avatar_url":"https://avatars.githubusercontent.com/u/245622?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobgardner","html_url":"https://github.com/jacobgardner","followers_url":"https://api.github.com/users/jacobgardner/followers","following_url":"https://api.github.com/users/jacobgardner/following{/other_user}","gists_url":"https://api.github.com/users/jacobgardner/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobgardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobgardner/subscriptions","organizations_url":"https://api.github.com/users/jacobgardner/orgs","repos_url":"https://api.github.com/users/jacobgardner/repos","events_url":"https://api.github.com/users/jacobgardner/events{/privacy}","received_events_url":"https://api.github.com/users/jacobgardner/received_events","type":"User","site_admin":false},"repo":{"id":64439341,"name":"monopoly-server","full_name":"jacobgardner/monopoly-server","owner":{"login":"jacobgardner","id":245622,"avatar_url":"https://avatars.githubusercontent.com/u/245622?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobgardner","html_url":"https://github.com/jacobgardner","followers_url":"https://api.github.com/users/jacobgardner/followers","following_url":"https://api.github.com/users/jacobgardner/following{/other_user}","gists_url":"https://api.github.com/users/jacobgardner/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobgardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobgardner/subscriptions","organizations_url":"https://api.github.com/users/jacobgardner/orgs","repos_url":"https://api.github.com/users/jacobgardner/repos","events_url":"https://api.github.com/users/jacobgardner/events{/privacy}","received_events_url":"https://api.github.com/users/jacobgardner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacobgardner/monopoly-server","description":"Jim's Monopoly Server","fork":false,"url":"https://api.github.com/repos/jacobgardner/monopoly-server","forks_url":"https://api.github.com/repos/jacobgardner/monopoly-server/forks","keys_url":"https://api.github.com/repos/jacobgardner/monopoly-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacobgardner/monopoly-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacobgardner/monopoly-server/teams","hooks_url":"https://api.github.com/repos/jacobgardner/monopoly-server/hooks","issue_events_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/events{/number}","events_url":"https://api.github.com/repos/jacobgardner/monopoly-server/events","assignees_url":"https://api.github.com/repos/jacobgardner/monopoly-server/assignees{/user}","branches_url":"https://api.github.com/repos/jacobgardner/monopoly-server/branches{/branch}","tags_url":"https://api.github.com/repos/jacobgardner/monopoly-server/tags","blobs_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacobgardner/monopoly-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jacobgardner/monopoly-server/languages","stargazers_url":"https://api.github.com/repos/jacobgardner/monopoly-server/stargazers","contributors_url":"https://api.github.com/repos/jacobgardner/monopoly-server/contributors","subscribers_url":"https://api.github.com/repos/jacobgardner/monopoly-server/subscribers","subscription_url":"https://api.github.com/repos/jacobgardner/monopoly-server/subscription","commits_url":"https://api.github.com/repos/jacobgardner/monopoly-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacobgardner/monopoly-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacobgardner/monopoly-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacobgardner/monopoly-server/contents/{+path}","compare_url":"https://api.github.com/repos/jacobgardner/monopoly-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacobgardner/monopoly-server/merges","archive_url":"https://api.github.com/repos/jacobgardner/monopoly-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacobgardner/monopoly-server/downloads","issues_url":"https://api.github.com/repos/jacobgardner/monopoly-server/issues{/number}","pulls_url":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jacobgardner/monopoly-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jacobgardner/monopoly-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacobgardner/monopoly-server/labels{/name}","releases_url":"https://api.github.com/repos/jacobgardner/monopoly-server/releases{/id}","deployments_url":"https://api.github.com/repos/jacobgardner/monopoly-server/deployments","created_at":"2016-07-29T01:13:07Z","updated_at":"2016-07-29T01:41:12Z","pushed_at":"2016-09-04T06:17:53Z","git_url":"git://github.com/jacobgardner/monopoly-server.git","ssh_url":"git@github.com:jacobgardner/monopoly-server.git","clone_url":"https://github.com/jacobgardner/monopoly-server.git","svn_url":"https://github.com/jacobgardner/monopoly-server","homepage":null,"size":27,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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/jacobgardner/monopoly-server/pulls/1"},"html":{"href":"https://github.com/jacobgardner/monopoly-server/pull/1"},"issue":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/1"},"comments":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/jacobgardner/monopoly-server/statuses/c91e381239e0a50b764b389413955a5bb0c46d1d"}}}}
{"actor":{"display_login":"jacobgardner"}}