{"action":"created","comment":{"url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/comments/173544201","pull_request_review_id":102760479,"id":173544201,"diff_hunk":"@@ -3,119 +3,343 @@\n   *           Copyright (c) 2018 Power-Command\n ***/\n \n-import { Prim } from 'sphere-runtime';\n+//cache colours so we only load them once\n+let black = Color.Black;\n+let emptyColor = Color.of('#202020');\n+let white = Color.White;\n+let damageColour = Color.DarkRed;\n+let transparent = Color.Transparent;\n+\n+// states for segments\n+const full = 0;\n+const damaged = 1;\n+const empty = 2;\n+\n+/* to-do:\n+1. implement a setter for capacity\n+\t- currently editing capacity after creating the bar will break it\n+\t- setter would need to\n+\t\ta) create new reserves if needed\n+\t\tb) edit this.fraction\n+\t\tc) edit this._capacity - all refs to this.capacity would change to that\n+2. refactor/centralise more of the maths\n+3. double check all colour references are correct\n+*/\n \n export default\n class HPGauge\n {\n-\tconstructor(capacity, sectorSize = 100, color = Color.White, maxSectors = 'auto')\n+\tconstructor(capacity, sectorSize = 100, color = white, maxSectors = 0)\n \t{\n-\t\tthis.borderColor = Color.Black.fadeTo(color.a);\n+\t\t// basic details\n \t\tthis.capacity = capacity;\n+\t\tthis.sectorSize = sectorSize; //hp in a full bar\n+\t\tthis.numReserves = Math.ceil(capacity / sectorSize) - 1;\n+\t\tthis.maxSectors = maxSectors; //note 0 is used for infinity\n+\t\tthis.reserves = [];\n+\n+\t\t//house keeping\n+\t\tthis.numCombosRunning = 0;\n+\t\tthis.newReading = capacity;\n+\t\tthis.oldReading = capacity;\n+\t\tlet remainder = capacity % sectorSize;\n+\t\tthis.fraction = remainder  === 0 ? 1 : remainder / sectorSize;\n+\t\tthis.fading = false;\n+\t\tthis.drawBackground = true;\n+\n+\t\t//stats on what is shown\n+\t\tthis._reading = 0; // the total HP remaining\n+\t\tthis.damage = 0;\n+\t\tthis._damageShown = 0; //total value of damage shown\n+\t\tthis._numReservesFilled = this.numReserves; //filled reserves\n+\t\tthis._numReservesDamaged = 0; //damaged i.e. draining away reserves\n+\t\tthis._numReservesEmpty = 0; //balancing figure but still necessary...\n+\n+\t\t//sizes\n+\t\tthis._x = 0;\n+\t\tthis._y = 0;\n+\t\tthis._height = 0;\n+\t\tthis._width = 0;\n+\t\tthis._slotYSize = 0;\n+\t\tthis._slotXSize = 0;\n+\n+\t\t// shaders\n+\t\tthis.shader = new Shader({ //shader for most things\n+\t\t\tfragmentFile: '#/shaders/image.frag.glsl',\n+\t\t\tvertexFile:   '#/shaders/image.vert.glsl',\n+\t\t});\n+\t\tthis.hpShader = this.shader.clone(); //hp bar shader used for colours (and fading) of hp bar\n+\t\tthis.backgroundShader = this.shader.clone(); // background shader for the faint background bar\n+\n+\t\t//timers\n \t\tthis.colorFadeDuration = 0;\n \t\tthis.colorFadeTimer = 0;\n-\t\tthis.damage = 0;\n-\t\tthis.damageColor = Color.DarkRed.fadeTo(color.a);\n-\t\tthis.damageFadeness = 1.0;\n \t\tthis.drainSpeed = 1.0;\n-\t\tthis.emptyColor = Color.of('#202020').fadeTo(color.a);\n+\t\tthis.drainTimer = 0;\n \t\tthis.fadeSpeed = 0.0;\n-\t\tthis.fadeness = 1.0;\n-\t\tthis.hpColor = color.clone();\n-\t\tthis.isVisible = true;\n-\t\tthis.maxSectors = maxSectors;\n-\t\tthis.newColor = color.clone();\n-\t\tthis.newReading = this.capacity;\n-\t\tthis.numCombosRunning = 0;\n-\t\tthis.oldColor = color.clone();\n-\t\tthis.oldReading = this.capacity;\n-\t\tthis.reading = this.capacity;\n-\t\tthis.sectorSize = sectorSize;\n+\t\tthis._fadeness = 1.0;\n+\t\tthis._damageFadeness = 1;\n+\n+\t\t//colour objects\n+\t\tthis._hpColor = null;\n+\t\tthis.newColor = null;\n+\t\tthis.oldColor = null;\n+\t\tthis.tintColor = {\n+\t\t\tr : color.r,\n+\t\t\tg : color.g,\n+\t\t\tb : color.b,\n+\t\t\ta : color.a\n+\t\t};//intentionally make a copy","path":"src/battleSystem/hpGauge.mjs","position":108,"original_position":108,"commit_id":"e2cb7469ebf28909657f3518576d210cd1dcf680","original_commit_id":"e2cb7469ebf28909657f3518576d210cd1dcf680","user":{"login":"rhuanjl","id":30090552,"avatar_url":"https://avatars3.githubusercontent.com/u/30090552?v=4","gravatar_id":"","url":"https://api.github.com/users/rhuanjl","html_url":"https://github.com/rhuanjl","followers_url":"https://api.github.com/users/rhuanjl/followers","following_url":"https://api.github.com/users/rhuanjl/following{/other_user}","gists_url":"https://api.github.com/users/rhuanjl/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuanjl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuanjl/subscriptions","organizations_url":"https://api.github.com/users/rhuanjl/orgs","repos_url":"https://api.github.com/users/rhuanjl/repos","events_url":"https://api.github.com/users/rhuanjl/events{/privacy}","received_events_url":"https://api.github.com/users/rhuanjl/received_events","type":"User","site_admin":false},"body":"Also allowed me to avoid a new Colour call each frame whilst tween'ing fades.","created_at":"2018-03-09T19:24:41Z","updated_at":"2018-03-09T19:24:41Z","html_url":"https://github.com/fatcerberus/spectacles-i/pull/4#discussion_r173544201","pull_request_url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/comments/173544201"},"html":{"href":"https://github.com/fatcerberus/spectacles-i/pull/4#discussion_r173544201"},"pull_request":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4"}},"in_reply_to_id":173366858},"pull_request":{"url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4","id":173617883,"html_url":"https://github.com/fatcerberus/spectacles-i/pull/4","diff_url":"https://github.com/fatcerberus/spectacles-i/pull/4.diff","patch_url":"https://github.com/fatcerberus/spectacles-i/pull/4.patch","issue_url":"https://api.github.com/repos/fatcerberus/spectacles-i/issues/4","number":4,"state":"open","locked":false,"title":"Refactor HPGauge, use v2 API for improved performance","user":{"login":"rhuanjl","id":30090552,"avatar_url":"https://avatars3.githubusercontent.com/u/30090552?v=4","gravatar_id":"","url":"https://api.github.com/users/rhuanjl","html_url":"https://github.com/rhuanjl","followers_url":"https://api.github.com/users/rhuanjl/followers","following_url":"https://api.github.com/users/rhuanjl/following{/other_user}","gists_url":"https://api.github.com/users/rhuanjl/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuanjl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuanjl/subscriptions","organizations_url":"https://api.github.com/users/rhuanjl/orgs","repos_url":"https://api.github.com/users/rhuanjl/repos","events_url":"https://api.github.com/users/rhuanjl/events{/privacy}","received_events_url":"https://api.github.com/users/rhuanjl/received_events","type":"User","site_admin":false},"body":"Hp bar rewrite to fix performance problems","created_at":"2018-03-08T01:03:33Z","updated_at":"2018-03-09T19:24:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46fe995427f3b30934eb0097ad14afd5af78918d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4/commits","review_comments_url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4/comments","review_comment_url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fatcerberus/spectacles-i/issues/4/comments","statuses_url":"https://api.github.com/repos/fatcerberus/spectacles-i/statuses/e2cb7469ebf28909657f3518576d210cd1dcf680","head":{"label":"rhuanjl:refactorHPBar","ref":"refactorHPBar","sha":"e2cb7469ebf28909657f3518576d210cd1dcf680","user":{"login":"rhuanjl","id":30090552,"avatar_url":"https://avatars3.githubusercontent.com/u/30090552?v=4","gravatar_id":"","url":"https://api.github.com/users/rhuanjl","html_url":"https://github.com/rhuanjl","followers_url":"https://api.github.com/users/rhuanjl/followers","following_url":"https://api.github.com/users/rhuanjl/following{/other_user}","gists_url":"https://api.github.com/users/rhuanjl/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuanjl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuanjl/subscriptions","organizations_url":"https://api.github.com/users/rhuanjl/orgs","repos_url":"https://api.github.com/users/rhuanjl/repos","events_url":"https://api.github.com/users/rhuanjl/events{/privacy}","received_events_url":"https://api.github.com/users/rhuanjl/received_events","type":"User","site_admin":false},"repo":{"id":109600356,"name":"spectacles-i","full_name":"rhuanjl/spectacles-i","owner":{"login":"rhuanjl","id":30090552,"avatar_url":"https://avatars3.githubusercontent.com/u/30090552?v=4","gravatar_id":"","url":"https://api.github.com/users/rhuanjl","html_url":"https://github.com/rhuanjl","followers_url":"https://api.github.com/users/rhuanjl/followers","following_url":"https://api.github.com/users/rhuanjl/following{/other_user}","gists_url":"https://api.github.com/users/rhuanjl/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuanjl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuanjl/subscriptions","organizations_url":"https://api.github.com/users/rhuanjl/orgs","repos_url":"https://api.github.com/users/rhuanjl/repos","events_url":"https://api.github.com/users/rhuanjl/events{/privacy}","received_events_url":"https://api.github.com/users/rhuanjl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rhuanjl/spectacles-i","description":"The first installment of the Spectacles Saga, which follows Scott Starcross in his quest through Lucida as he attempts to defeat the Primus.  Uses the Sphere engine!","fork":true,"url":"https://api.github.com/repos/rhuanjl/spectacles-i","forks_url":"https://api.github.com/repos/rhuanjl/spectacles-i/forks","keys_url":"https://api.github.com/repos/rhuanjl/spectacles-i/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rhuanjl/spectacles-i/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rhuanjl/spectacles-i/teams","hooks_url":"https://api.github.com/repos/rhuanjl/spectacles-i/hooks","issue_events_url":"https://api.github.com/repos/rhuanjl/spectacles-i/issues/events{/number}","events_url":"https://api.github.com/repos/rhuanjl/spectacles-i/events","assignees_url":"https://api.github.com/repos/rhuanjl/spectacles-i/assignees{/user}","branches_url":"https://api.github.com/repos/rhuanjl/spectacles-i/branches{/branch}","tags_url":"https://api.github.com/repos/rhuanjl/spectacles-i/tags","blobs_url":"https://api.github.com/repos/rhuanjl/spectacles-i/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rhuanjl/spectacles-i/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rhuanjl/spectacles-i/git/refs{/sha}","trees_url":"https://api.github.com/repos/rhuanjl/spectacles-i/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rhuanjl/spectacles-i/statuses/{sha}","languages_url":"https://api.github.com/repos/rhuanjl/spectacles-i/languages","stargazers_url":"https://api.github.com/repos/rhuanjl/spectacles-i/stargazers","contributors_url":"https://api.github.com/repos/rhuanjl/spectacles-i/contributors","subscribers_url":"https://api.github.com/repos/rhuanjl/spectacles-i/subscribers","subscription_url":"https://api.github.com/repos/rhuanjl/spectacles-i/subscription","commits_url":"https://api.github.com/repos/rhuanjl/spectacles-i/commits{/sha}","git_commits_url":"https://api.github.com/repos/rhuanjl/spectacles-i/git/commits{/sha}","comments_url":"https://api.github.com/repos/rhuanjl/spectacles-i/comments{/number}","issue_comment_url":"https://api.github.com/repos/rhuanjl/spectacles-i/issues/comments{/number}","contents_url":"https://api.github.com/repos/rhuanjl/spectacles-i/contents/{+path}","compare_url":"https://api.github.com/repos/rhuanjl/spectacles-i/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rhuanjl/spectacles-i/merges","archive_url":"https://api.github.com/repos/rhuanjl/spectacles-i/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rhuanjl/spectacles-i/downloads","issues_url":"https://api.github.com/repos/rhuanjl/spectacles-i/issues{/number}","pulls_url":"https://api.github.com/repos/rhuanjl/spectacles-i/pulls{/number}","milestones_url":"https://api.github.com/repos/rhuanjl/spectacles-i/milestones{/number}","notifications_url":"https://api.github.com/repos/rhuanjl/spectacles-i/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rhuanjl/spectacles-i/labels{/name}","releases_url":"https://api.github.com/repos/rhuanjl/spectacles-i/releases{/id}","deployments_url":"https://api.github.com/repos/rhuanjl/spectacles-i/deployments","created_at":"2017-11-05T17:26:36Z","updated_at":"2017-11-05T17:26:37Z","pushed_at":"2018-03-08T20:24:22Z","git_url":"git://github.com/rhuanjl/spectacles-i.git","ssh_url":"git@github.com:rhuanjl/spectacles-i.git","clone_url":"https://github.com/rhuanjl/spectacles-i.git","svn_url":"https://github.com/rhuanjl/spectacles-i","homepage":"","size":72933,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fatcerberus:master","ref":"master","sha":"07acf12a6484de409c4f80c47988d5b405d8efe5","user":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars2.githubusercontent.com/u/4097841?v=4","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"repo":{"id":9500447,"name":"spectacles-i","full_name":"fatcerberus/spectacles-i","owner":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars2.githubusercontent.com/u/4097841?v=4","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fatcerberus/spectacles-i","description":"The first installment of the Spectacles Saga, which follows Scott Starcross in his quest through Lucida as he attempts to defeat the Primus.  Uses the Sphere engine!","fork":false,"url":"https://api.github.com/repos/fatcerberus/spectacles-i","forks_url":"https://api.github.com/repos/fatcerberus/spectacles-i/forks","keys_url":"https://api.github.com/repos/fatcerberus/spectacles-i/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fatcerberus/spectacles-i/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fatcerberus/spectacles-i/teams","hooks_url":"https://api.github.com/repos/fatcerberus/spectacles-i/hooks","issue_events_url":"https://api.github.com/repos/fatcerberus/spectacles-i/issues/events{/number}","events_url":"https://api.github.com/repos/fatcerberus/spectacles-i/events","assignees_url":"https://api.github.com/repos/fatcerberus/spectacles-i/assignees{/user}","branches_url":"https://api.github.com/repos/fatcerberus/spectacles-i/branches{/branch}","tags_url":"https://api.github.com/repos/fatcerberus/spectacles-i/tags","blobs_url":"https://api.github.com/repos/fatcerberus/spectacles-i/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fatcerberus/spectacles-i/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fatcerberus/spectacles-i/git/refs{/sha}","trees_url":"https://api.github.com/repos/fatcerberus/spectacles-i/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fatcerberus/spectacles-i/statuses/{sha}","languages_url":"https://api.github.com/repos/fatcerberus/spectacles-i/languages","stargazers_url":"https://api.github.com/repos/fatcerberus/spectacles-i/stargazers","contributors_url":"https://api.github.com/repos/fatcerberus/spectacles-i/contributors","subscribers_url":"https://api.github.com/repos/fatcerberus/spectacles-i/subscribers","subscription_url":"https://api.github.com/repos/fatcerberus/spectacles-i/subscription","commits_url":"https://api.github.com/repos/fatcerberus/spectacles-i/commits{/sha}","git_commits_url":"https://api.github.com/repos/fatcerberus/spectacles-i/git/commits{/sha}","comments_url":"https://api.github.com/repos/fatcerberus/spectacles-i/comments{/number}","issue_comment_url":"https://api.github.com/repos/fatcerberus/spectacles-i/issues/comments{/number}","contents_url":"https://api.github.com/repos/fatcerberus/spectacles-i/contents/{+path}","compare_url":"https://api.github.com/repos/fatcerberus/spectacles-i/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fatcerberus/spectacles-i/merges","archive_url":"https://api.github.com/repos/fatcerberus/spectacles-i/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fatcerberus/spectacles-i/downloads","issues_url":"https://api.github.com/repos/fatcerberus/spectacles-i/issues{/number}","pulls_url":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls{/number}","milestones_url":"https://api.github.com/repos/fatcerberus/spectacles-i/milestones{/number}","notifications_url":"https://api.github.com/repos/fatcerberus/spectacles-i/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fatcerberus/spectacles-i/labels{/name}","releases_url":"https://api.github.com/repos/fatcerberus/spectacles-i/releases{/id}","deployments_url":"https://api.github.com/repos/fatcerberus/spectacles-i/deployments","created_at":"2013-04-17T15:05:50Z","updated_at":"2017-06-11T07:58:28Z","pushed_at":"2018-03-08T20:24:23Z","git_url":"git://github.com/fatcerberus/spectacles-i.git","ssh_url":"git@github.com:fatcerberus/spectacles-i.git","clone_url":"https://github.com/fatcerberus/spectacles-i.git","svn_url":"https://github.com/fatcerberus/spectacles-i","homepage":"","size":72924,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":2,"open_issues":3,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4"},"html":{"href":"https://github.com/fatcerberus/spectacles-i/pull/4"},"issue":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/issues/4"},"comments":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/fatcerberus/spectacles-i/statuses/e2cb7469ebf28909657f3518576d210cd1dcf680"}},"author_association":"NONE"}}
{"actor":{"display_login":"rhuanjl"}}