{"action":"created","comment":{"url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/comments/181819728","pull_request_review_id":112510625,"id":181819728,"diff_hunk":"@@ -0,0 +1,140 @@\n+import Grid from './Grid'\n+\n+export default class TerrainGrid extends Grid {\n+  constructor(tilesWide, tilesHigh) {\n+    super(tilesWide, tilesHigh, 1)\n+    this.setTerrainProperties()\n+    this.reset()\n+  }\n+\n+  setTerrainProperties() {\n+    this.terrainProperties = {\n+      normal: {\n+        difficulty: 1,\n+        color: 0xFFFFFF,\n+      },\n+      crater: {\n+        difficulty: 3,\n+        color: 0xCECECE,\n+      },\n+      ridge: {\n+        difficulty: 2,\n+        color: 0xE5E5E5,\n+      },\n+      obstacle: {\n+        difficulty: 0,\n+        color: 0x000000,\n+      },\n+    }\n+  }\n+\n+  getTerrainProperties(type) {\n+    if (this.terrainProperties.hasOwnProperty(type)) {\n+      return {\n+        type: type,\n+        difficulty: this.terrainProperties[type].difficulty,\n+        color: this.terrainProperties[type].color,\n+      }\n+    }\n+    return {\n+      type: \"normal\",\n+      difficulty: this.terrainProperties.normal.difficulty,\n+      color: this.terrainProperties.normal.color,\n+    }\n+  }\n+\n+  reset() {\n+    this.initialValue = this.getTerrainProperties(\"normal\")\n+    super.reset()\n+    this.generateTerrain()\n+  }\n+\n+  generateTerrain() {\n+    // TODO: Simple randomizer for terrain features\n+    this.addTestCrater({x:17,y:17}, 4)\n+    this.addTestCrater({x:30,y:30}, 4)\n+    this.addTestCrater({x:30,y:4}, 4)\n+  }\n+\n+  addTestCrater(gridLocation, size) {\n+    // square crater\n+    for (let x = gridLocation.x - size; x <= gridLocation.x + size; x++) {\n+      for (let y = gridLocation.y - size; y <= gridLocation.y + size; y++) {\n+        if (!this.coordinateIsValid(x, y)) { continue }\n+        if (x == gridLocation.x - size || x == gridLocation.x + size ||\n+            y == gridLocation.y - size || y == gridLocation.y + size) {\n+          this.set(x, y, this.getTerrainProperties(\"ridge\"))\n+        } else if (x == gridLocation.x && y == gridLocation.y) {\n+          this.set(x, y, this.getTerrainProperties(\"obstacle\"))\n+        } else {\n+          this.set(x, y, this.getTerrainProperties(\"crater\"))\n+        }\n+      }\n+    }\n+  }\n+\n+  randomize(wallProbability = 0.1) {\n+    for (let i = 0; i < this.tilesWide; i++) {\n+      for (let j = 0; j < this.tilesHigh; j++) {\n+        let random = Math.random()\n+        if (random < wallProbability) {\n+          this.set(i, j, this.getTerrainProperties(\"obstacle\"))\n+        } else {\n+          this.set(i, j, this.getTerrainProperties(\"normal\"))\n+        }\n+      }\n+    }\n+  }\n+\n+  /*\n+   * Adds an obstacle onto the weights grid. Simply sets relevant values to 0.\n+   * Takes a position, a width, and a height.\n+   */\n+  addObstacle(gridLocation, gridWidth, gridHeight) {\n+    for (let x = gridLocation.x; x < gridLocation.x + gridWidth; x++) {\n+      for (let y = gridLocation.y; y < gridLocation.y + gridHeight; y++) {\n+        this.set(x, y, this.getTerrainProperties(\"obstacle\"))\n+      }\n+    }\n+  }\n+\n+  isAreaFree(gridLocation, gridWidth, gridHeight) {","path":"src/js/map/TerrainGrid.js","position":101,"original_position":101,"commit_id":"1f427eef39505ac069f92b262db31fcec8280cef","original_commit_id":"1f427eef39505ac069f92b262db31fcec8280cef","user":{"login":"itsamiga","id":27872518,"avatar_url":"https://avatars3.githubusercontent.com/u/27872518?v=4","gravatar_id":"","url":"https://api.github.com/users/itsamiga","html_url":"https://github.com/itsamiga","followers_url":"https://api.github.com/users/itsamiga/followers","following_url":"https://api.github.com/users/itsamiga/following{/other_user}","gists_url":"https://api.github.com/users/itsamiga/gists{/gist_id}","starred_url":"https://api.github.com/users/itsamiga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itsamiga/subscriptions","organizations_url":"https://api.github.com/users/itsamiga/orgs","repos_url":"https://api.github.com/users/itsamiga/repos","events_url":"https://api.github.com/users/itsamiga/events{/privacy}","received_events_url":"https://api.github.com/users/itsamiga/received_events","type":"User","site_admin":false},"body":"That's true, the main difference is that the version in TerrainGrid specifically checks difficultyAt(), rather than the at() method used in TowerGrid. Just because the two are constructed slightly differently.","created_at":"2018-04-16T17:16:14Z","updated_at":"2018-04-16T17:16:14Z","html_url":"https://github.com/danielmoniz/tower-defense/pull/61#discussion_r181819728","pull_request_url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/comments/181819728"},"html":{"href":"https://github.com/danielmoniz/tower-defense/pull/61#discussion_r181819728"},"pull_request":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61"}},"in_reply_to_id":181816515},"pull_request":{"url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61","id":170027321,"html_url":"https://github.com/danielmoniz/tower-defense/pull/61","diff_url":"https://github.com/danielmoniz/tower-defense/pull/61.diff","patch_url":"https://github.com/danielmoniz/tower-defense/pull/61.patch","issue_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues/61","number":61,"state":"open","locked":false,"title":"Pathlength binaryheap","user":{"login":"danielmoniz","id":969976,"avatar_url":"https://avatars3.githubusercontent.com/u/969976?v=4","gravatar_id":"","url":"https://api.github.com/users/danielmoniz","html_url":"https://github.com/danielmoniz","followers_url":"https://api.github.com/users/danielmoniz/followers","following_url":"https://api.github.com/users/danielmoniz/following{/other_user}","gists_url":"https://api.github.com/users/danielmoniz/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmoniz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmoniz/subscriptions","organizations_url":"https://api.github.com/users/danielmoniz/orgs","repos_url":"https://api.github.com/users/danielmoniz/repos","events_url":"https://api.github.com/users/danielmoniz/events{/privacy}","received_events_url":"https://api.github.com/users/danielmoniz/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-19T18:22:44Z","updated_at":"2018-04-16T17:16:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c753a31d988e24018ee026b728e04965d520112e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61/commits","review_comments_url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61/comments","review_comment_url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues/61/comments","statuses_url":"https://api.github.com/repos/danielmoniz/tower-defense/statuses/1f427eef39505ac069f92b262db31fcec8280cef","head":{"label":"danielmoniz:pathlength-binaryheap","ref":"pathlength-binaryheap","sha":"1f427eef39505ac069f92b262db31fcec8280cef","user":{"login":"danielmoniz","id":969976,"avatar_url":"https://avatars3.githubusercontent.com/u/969976?v=4","gravatar_id":"","url":"https://api.github.com/users/danielmoniz","html_url":"https://github.com/danielmoniz","followers_url":"https://api.github.com/users/danielmoniz/followers","following_url":"https://api.github.com/users/danielmoniz/following{/other_user}","gists_url":"https://api.github.com/users/danielmoniz/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmoniz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmoniz/subscriptions","organizations_url":"https://api.github.com/users/danielmoniz/orgs","repos_url":"https://api.github.com/users/danielmoniz/repos","events_url":"https://api.github.com/users/danielmoniz/events{/privacy}","received_events_url":"https://api.github.com/users/danielmoniz/received_events","type":"User","site_admin":false},"repo":{"id":110996391,"name":"tower-defense","full_name":"danielmoniz/tower-defense","owner":{"login":"danielmoniz","id":969976,"avatar_url":"https://avatars3.githubusercontent.com/u/969976?v=4","gravatar_id":"","url":"https://api.github.com/users/danielmoniz","html_url":"https://github.com/danielmoniz","followers_url":"https://api.github.com/users/danielmoniz/followers","following_url":"https://api.github.com/users/danielmoniz/following{/other_user}","gists_url":"https://api.github.com/users/danielmoniz/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmoniz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmoniz/subscriptions","organizations_url":"https://api.github.com/users/danielmoniz/orgs","repos_url":"https://api.github.com/users/danielmoniz/repos","events_url":"https://api.github.com/users/danielmoniz/events{/privacy}","received_events_url":"https://api.github.com/users/danielmoniz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielmoniz/tower-defense","description":null,"fork":false,"url":"https://api.github.com/repos/danielmoniz/tower-defense","forks_url":"https://api.github.com/repos/danielmoniz/tower-defense/forks","keys_url":"https://api.github.com/repos/danielmoniz/tower-defense/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielmoniz/tower-defense/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielmoniz/tower-defense/teams","hooks_url":"https://api.github.com/repos/danielmoniz/tower-defense/hooks","issue_events_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues/events{/number}","events_url":"https://api.github.com/repos/danielmoniz/tower-defense/events","assignees_url":"https://api.github.com/repos/danielmoniz/tower-defense/assignees{/user}","branches_url":"https://api.github.com/repos/danielmoniz/tower-defense/branches{/branch}","tags_url":"https://api.github.com/repos/danielmoniz/tower-defense/tags","blobs_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielmoniz/tower-defense/statuses/{sha}","languages_url":"https://api.github.com/repos/danielmoniz/tower-defense/languages","stargazers_url":"https://api.github.com/repos/danielmoniz/tower-defense/stargazers","contributors_url":"https://api.github.com/repos/danielmoniz/tower-defense/contributors","subscribers_url":"https://api.github.com/repos/danielmoniz/tower-defense/subscribers","subscription_url":"https://api.github.com/repos/danielmoniz/tower-defense/subscription","commits_url":"https://api.github.com/repos/danielmoniz/tower-defense/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielmoniz/tower-defense/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielmoniz/tower-defense/contents/{+path}","compare_url":"https://api.github.com/repos/danielmoniz/tower-defense/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielmoniz/tower-defense/merges","archive_url":"https://api.github.com/repos/danielmoniz/tower-defense/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielmoniz/tower-defense/downloads","issues_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues{/number}","pulls_url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls{/number}","milestones_url":"https://api.github.com/repos/danielmoniz/tower-defense/milestones{/number}","notifications_url":"https://api.github.com/repos/danielmoniz/tower-defense/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielmoniz/tower-defense/labels{/name}","releases_url":"https://api.github.com/repos/danielmoniz/tower-defense/releases{/id}","deployments_url":"https://api.github.com/repos/danielmoniz/tower-defense/deployments","created_at":"2017-11-16T16:39:12Z","updated_at":"2018-04-04T12:45:36Z","pushed_at":"2018-04-11T20:43:46Z","git_url":"git://github.com/danielmoniz/tower-defense.git","ssh_url":"git@github.com:danielmoniz/tower-defense.git","clone_url":"https://github.com/danielmoniz/tower-defense.git","svn_url":"https://github.com/danielmoniz/tower-defense","homepage":null,"size":1166,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":24,"license":null,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"base":{"label":"danielmoniz:master","ref":"master","sha":"acf5237f807659d09e057fc5df6dc4f652e7b26d","user":{"login":"danielmoniz","id":969976,"avatar_url":"https://avatars3.githubusercontent.com/u/969976?v=4","gravatar_id":"","url":"https://api.github.com/users/danielmoniz","html_url":"https://github.com/danielmoniz","followers_url":"https://api.github.com/users/danielmoniz/followers","following_url":"https://api.github.com/users/danielmoniz/following{/other_user}","gists_url":"https://api.github.com/users/danielmoniz/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmoniz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmoniz/subscriptions","organizations_url":"https://api.github.com/users/danielmoniz/orgs","repos_url":"https://api.github.com/users/danielmoniz/repos","events_url":"https://api.github.com/users/danielmoniz/events{/privacy}","received_events_url":"https://api.github.com/users/danielmoniz/received_events","type":"User","site_admin":false},"repo":{"id":110996391,"name":"tower-defense","full_name":"danielmoniz/tower-defense","owner":{"login":"danielmoniz","id":969976,"avatar_url":"https://avatars3.githubusercontent.com/u/969976?v=4","gravatar_id":"","url":"https://api.github.com/users/danielmoniz","html_url":"https://github.com/danielmoniz","followers_url":"https://api.github.com/users/danielmoniz/followers","following_url":"https://api.github.com/users/danielmoniz/following{/other_user}","gists_url":"https://api.github.com/users/danielmoniz/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmoniz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmoniz/subscriptions","organizations_url":"https://api.github.com/users/danielmoniz/orgs","repos_url":"https://api.github.com/users/danielmoniz/repos","events_url":"https://api.github.com/users/danielmoniz/events{/privacy}","received_events_url":"https://api.github.com/users/danielmoniz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielmoniz/tower-defense","description":null,"fork":false,"url":"https://api.github.com/repos/danielmoniz/tower-defense","forks_url":"https://api.github.com/repos/danielmoniz/tower-defense/forks","keys_url":"https://api.github.com/repos/danielmoniz/tower-defense/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielmoniz/tower-defense/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielmoniz/tower-defense/teams","hooks_url":"https://api.github.com/repos/danielmoniz/tower-defense/hooks","issue_events_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues/events{/number}","events_url":"https://api.github.com/repos/danielmoniz/tower-defense/events","assignees_url":"https://api.github.com/repos/danielmoniz/tower-defense/assignees{/user}","branches_url":"https://api.github.com/repos/danielmoniz/tower-defense/branches{/branch}","tags_url":"https://api.github.com/repos/danielmoniz/tower-defense/tags","blobs_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielmoniz/tower-defense/statuses/{sha}","languages_url":"https://api.github.com/repos/danielmoniz/tower-defense/languages","stargazers_url":"https://api.github.com/repos/danielmoniz/tower-defense/stargazers","contributors_url":"https://api.github.com/repos/danielmoniz/tower-defense/contributors","subscribers_url":"https://api.github.com/repos/danielmoniz/tower-defense/subscribers","subscription_url":"https://api.github.com/repos/danielmoniz/tower-defense/subscription","commits_url":"https://api.github.com/repos/danielmoniz/tower-defense/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielmoniz/tower-defense/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielmoniz/tower-defense/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielmoniz/tower-defense/contents/{+path}","compare_url":"https://api.github.com/repos/danielmoniz/tower-defense/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielmoniz/tower-defense/merges","archive_url":"https://api.github.com/repos/danielmoniz/tower-defense/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielmoniz/tower-defense/downloads","issues_url":"https://api.github.com/repos/danielmoniz/tower-defense/issues{/number}","pulls_url":"https://api.github.com/repos/danielmoniz/tower-defense/pulls{/number}","milestones_url":"https://api.github.com/repos/danielmoniz/tower-defense/milestones{/number}","notifications_url":"https://api.github.com/repos/danielmoniz/tower-defense/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielmoniz/tower-defense/labels{/name}","releases_url":"https://api.github.com/repos/danielmoniz/tower-defense/releases{/id}","deployments_url":"https://api.github.com/repos/danielmoniz/tower-defense/deployments","created_at":"2017-11-16T16:39:12Z","updated_at":"2018-04-04T12:45:36Z","pushed_at":"2018-04-11T20:43:46Z","git_url":"git://github.com/danielmoniz/tower-defense.git","ssh_url":"git@github.com:danielmoniz/tower-defense.git","clone_url":"https://github.com/danielmoniz/tower-defense.git","svn_url":"https://github.com/danielmoniz/tower-defense","homepage":null,"size":1166,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":24,"license":null,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61"},"html":{"href":"https://github.com/danielmoniz/tower-defense/pull/61"},"issue":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/issues/61"},"comments":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/issues/61/comments"},"review_comments":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61/comments"},"review_comment":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/pulls/61/commits"},"statuses":{"href":"https://api.github.com/repos/danielmoniz/tower-defense/statuses/1f427eef39505ac069f92b262db31fcec8280cef"}},"author_association":"OWNER"}}
{"actor":{"display_login":"itsamiga"}}