{"action":"created","comment":{"url":"https://api.github.com/repos/ivansalazar/qwircl/pulls/comments/184890368","pull_request_review_id":116173712,"id":184890368,"diff_hunk":"@@ -33,34 +51,108 @@\n   ; nothing yet\n   state)\n \n-(defn to-position [event]\n-  ; x is easy, but for y we need to take the header\n-  ; into account\n-  (let [x (int (/ (:x event) size))\n-        r (:y event)]\n-    (if (<= r header)\n-      {:in :hand :coordinates [x]}\n-      {:in :grid :coordinates [x (int (/ (- r header) size))]}))) \n+(defn inside-dimensions? [xp yp {:keys [x y w h]}]\n+  (and \n+   (<= x xp (+ x w))\n+   (<= y yp (+ y h))))\n+\n+(defn get-clicked [x y]\n+  (first (filter #(inside-dimensions? x y (% dimensions)) [:hand :grid :submit :undo])))\n+\n+(defn translate-hand [xp hand]\n+  (let [x (int (/ (- xp (first header-translation)) size))]\n+    (when (and (<= 0 x) (< x (count hand)))\n+      [x])))\n+\n+(defn translate-grid [x y]\n+  [(int (/ x size)) (int (/ (- y header) size))])\n+\n+(defn translate-event [state {:keys [x y]}]\n+  (condp = (get-clicked x y)\n+    :hand (when-let [h (translate-hand x (get-in state [:my :hand]))] \n+            {:action :hand-clicked :clicked h})\n+    :grid {:action :grid-clicked :clicked (translate-grid x y)}\n+    :submit {:action :submit}\n+    :undo {:action :undo}\n+    {:x x :y y}))","path":"src/qwircl/core.cljs","position":91,"original_position":91,"commit_id":"e8e6abccd66c197314316d3983fba3ae0fe32d54","original_commit_id":"e8e6abccd66c197314316d3983fba3ae0fe32d54","user":{"login":"tclamb","id":1987615,"avatar_url":"https://avatars3.githubusercontent.com/u/1987615?v=4","gravatar_id":"","url":"https://api.github.com/users/tclamb","html_url":"https://github.com/tclamb","followers_url":"https://api.github.com/users/tclamb/followers","following_url":"https://api.github.com/users/tclamb/following{/other_user}","gists_url":"https://api.github.com/users/tclamb/gists{/gist_id}","starred_url":"https://api.github.com/users/tclamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tclamb/subscriptions","organizations_url":"https://api.github.com/users/tclamb/orgs","repos_url":"https://api.github.com/users/tclamb/repos","events_url":"https://api.github.com/users/tclamb/events{/privacy}","received_events_url":"https://api.github.com/users/tclamb/received_events","type":"User","site_admin":false},"body":"Similarly, all of these could be `merge`d into the event. I think I'd prefer namespaces keywords (e.g. `::action ::hand-clicked ::tile-index x`). I kinda like not throwing away information.","created_at":"2018-04-29T18:02:28Z","updated_at":"2018-04-29T18:31:49Z","html_url":"https://github.com/ivansalazar/qwircl/pull/5#discussion_r184890368","pull_request_url":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ivansalazar/qwircl/pulls/comments/184890368"},"html":{"href":"https://github.com/ivansalazar/qwircl/pull/5#discussion_r184890368"},"pull_request":{"href":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5"}},"in_reply_to_id":184890300},"pull_request":{"url":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5","id":183916858,"html_url":"https://github.com/ivansalazar/qwircl/pull/5","diff_url":"https://github.com/ivansalazar/qwircl/pull/5.diff","patch_url":"https://github.com/ivansalazar/qwircl/pull/5.patch","issue_url":"https://api.github.com/repos/ivansalazar/qwircl/issues/5","number":5,"state":"open","locked":false,"title":"Automaton for turn mechanics","user":{"login":"ivansalazar","id":73122,"avatar_url":"https://avatars3.githubusercontent.com/u/73122?v=4","gravatar_id":"","url":"https://api.github.com/users/ivansalazar","html_url":"https://github.com/ivansalazar","followers_url":"https://api.github.com/users/ivansalazar/followers","following_url":"https://api.github.com/users/ivansalazar/following{/other_user}","gists_url":"https://api.github.com/users/ivansalazar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivansalazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivansalazar/subscriptions","organizations_url":"https://api.github.com/users/ivansalazar/orgs","repos_url":"https://api.github.com/users/ivansalazar/repos","events_url":"https://api.github.com/users/ivansalazar/events{/privacy}","received_events_url":"https://api.github.com/users/ivansalazar/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-25T03:30:02Z","updated_at":"2018-04-29T18:31:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e92d7d799e05f19539a68719b330e2e79349f0a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5/commits","review_comments_url":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5/comments","review_comment_url":"https://api.github.com/repos/ivansalazar/qwircl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ivansalazar/qwircl/issues/5/comments","statuses_url":"https://api.github.com/repos/ivansalazar/qwircl/statuses/e8e6abccd66c197314316d3983fba3ae0fe32d54","head":{"label":"ivansalazar:automaton","ref":"automaton","sha":"e8e6abccd66c197314316d3983fba3ae0fe32d54","user":{"login":"ivansalazar","id":73122,"avatar_url":"https://avatars3.githubusercontent.com/u/73122?v=4","gravatar_id":"","url":"https://api.github.com/users/ivansalazar","html_url":"https://github.com/ivansalazar","followers_url":"https://api.github.com/users/ivansalazar/followers","following_url":"https://api.github.com/users/ivansalazar/following{/other_user}","gists_url":"https://api.github.com/users/ivansalazar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivansalazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivansalazar/subscriptions","organizations_url":"https://api.github.com/users/ivansalazar/orgs","repos_url":"https://api.github.com/users/ivansalazar/repos","events_url":"https://api.github.com/users/ivansalazar/events{/privacy}","received_events_url":"https://api.github.com/users/ivansalazar/received_events","type":"User","site_admin":false},"repo":{"id":126913715,"name":"qwircl","full_name":"ivansalazar/qwircl","owner":{"login":"ivansalazar","id":73122,"avatar_url":"https://avatars3.githubusercontent.com/u/73122?v=4","gravatar_id":"","url":"https://api.github.com/users/ivansalazar","html_url":"https://github.com/ivansalazar","followers_url":"https://api.github.com/users/ivansalazar/followers","following_url":"https://api.github.com/users/ivansalazar/following{/other_user}","gists_url":"https://api.github.com/users/ivansalazar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivansalazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivansalazar/subscriptions","organizations_url":"https://api.github.com/users/ivansalazar/orgs","repos_url":"https://api.github.com/users/ivansalazar/repos","events_url":"https://api.github.com/users/ivansalazar/events{/privacy}","received_events_url":"https://api.github.com/users/ivansalazar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ivansalazar/qwircl","description":"Implementation of a popular puzzle board game","fork":false,"url":"https://api.github.com/repos/ivansalazar/qwircl","forks_url":"https://api.github.com/repos/ivansalazar/qwircl/forks","keys_url":"https://api.github.com/repos/ivansalazar/qwircl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ivansalazar/qwircl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ivansalazar/qwircl/teams","hooks_url":"https://api.github.com/repos/ivansalazar/qwircl/hooks","issue_events_url":"https://api.github.com/repos/ivansalazar/qwircl/issues/events{/number}","events_url":"https://api.github.com/repos/ivansalazar/qwircl/events","assignees_url":"https://api.github.com/repos/ivansalazar/qwircl/assignees{/user}","branches_url":"https://api.github.com/repos/ivansalazar/qwircl/branches{/branch}","tags_url":"https://api.github.com/repos/ivansalazar/qwircl/tags","blobs_url":"https://api.github.com/repos/ivansalazar/qwircl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ivansalazar/qwircl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ivansalazar/qwircl/git/refs{/sha}","trees_url":"https://api.github.com/repos/ivansalazar/qwircl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ivansalazar/qwircl/statuses/{sha}","languages_url":"https://api.github.com/repos/ivansalazar/qwircl/languages","stargazers_url":"https://api.github.com/repos/ivansalazar/qwircl/stargazers","contributors_url":"https://api.github.com/repos/ivansalazar/qwircl/contributors","subscribers_url":"https://api.github.com/repos/ivansalazar/qwircl/subscribers","subscription_url":"https://api.github.com/repos/ivansalazar/qwircl/subscription","commits_url":"https://api.github.com/repos/ivansalazar/qwircl/commits{/sha}","git_commits_url":"https://api.github.com/repos/ivansalazar/qwircl/git/commits{/sha}","comments_url":"https://api.github.com/repos/ivansalazar/qwircl/comments{/number}","issue_comment_url":"https://api.github.com/repos/ivansalazar/qwircl/issues/comments{/number}","contents_url":"https://api.github.com/repos/ivansalazar/qwircl/contents/{+path}","compare_url":"https://api.github.com/repos/ivansalazar/qwircl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ivansalazar/qwircl/merges","archive_url":"https://api.github.com/repos/ivansalazar/qwircl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ivansalazar/qwircl/downloads","issues_url":"https://api.github.com/repos/ivansalazar/qwircl/issues{/number}","pulls_url":"https://api.github.com/repos/ivansalazar/qwircl/pulls{/number}","milestones_url":"https://api.github.com/repos/ivansalazar/qwircl/milestones{/number}","notifications_url":"https://api.github.com/repos/ivansalazar/qwircl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ivansalazar/qwircl/labels{/name}","releases_url":"https://api.github.com/repos/ivansalazar/qwircl/releases{/id}","deployments_url":"https://api.github.com/repos/ivansalazar/qwircl/deployments","created_at":"2018-03-27T01:56:22Z","updated_at":"2018-04-12T17:48:48Z","pushed_at":"2018-04-28T03:48:23Z","git_url":"git://github.com/ivansalazar/qwircl.git","ssh_url":"git@github.com:ivansalazar/qwircl.git","clone_url":"https://github.com/ivansalazar/qwircl.git","svn_url":"https://github.com/ivansalazar/qwircl","homepage":null,"size":30,"stargazers_count":0,"watchers_count":0,"language":"Clojure","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":1,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ivansalazar:master","ref":"master","sha":"79539ea4c8b734aa1d3fd240e57de9aedfcf4149","user":{"login":"ivansalazar","id":73122,"avatar_url":"https://avatars3.githubusercontent.com/u/73122?v=4","gravatar_id":"","url":"https://api.github.com/users/ivansalazar","html_url":"https://github.com/ivansalazar","followers_url":"https://api.github.com/users/ivansalazar/followers","following_url":"https://api.github.com/users/ivansalazar/following{/other_user}","gists_url":"https://api.github.com/users/ivansalazar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivansalazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivansalazar/subscriptions","organizations_url":"https://api.github.com/users/ivansalazar/orgs","repos_url":"https://api.github.com/users/ivansalazar/repos","events_url":"https://api.github.com/users/ivansalazar/events{/privacy}","received_events_url":"https://api.github.com/users/ivansalazar/received_events","type":"User","site_admin":false},"repo":{"id":126913715,"name":"qwircl","full_name":"ivansalazar/qwircl","owner":{"login":"ivansalazar","id":73122,"avatar_url":"https://avatars3.githubusercontent.com/u/73122?v=4","gravatar_id":"","url":"https://api.github.com/users/ivansalazar","html_url":"https://github.com/ivansalazar","followers_url":"https://api.github.com/users/ivansalazar/followers","following_url":"https://api.github.com/users/ivansalazar/following{/other_user}","gists_url":"https://api.github.com/users/ivansalazar/gists{/gist_id}","starred_url":"https://api.github.com/users/ivansalazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivansalazar/subscriptions","organizations_url":"https://api.github.com/users/ivansalazar/orgs","repos_url":"https://api.github.com/users/ivansalazar/repos","events_url":"https://api.github.com/users/ivansalazar/events{/privacy}","received_events_url":"https://api.github.com/users/ivansalazar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ivansalazar/qwircl","description":"Implementation of a popular puzzle board game","fork":false,"url":"https://api.github.com/repos/ivansalazar/qwircl","forks_url":"https://api.github.com/repos/ivansalazar/qwircl/forks","keys_url":"https://api.github.com/repos/ivansalazar/qwircl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ivansalazar/qwircl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ivansalazar/qwircl/teams","hooks_url":"https://api.github.com/repos/ivansalazar/qwircl/hooks","issue_events_url":"https://api.github.com/repos/ivansalazar/qwircl/issues/events{/number}","events_url":"https://api.github.com/repos/ivansalazar/qwircl/events","assignees_url":"https://api.github.com/repos/ivansalazar/qwircl/assignees{/user}","branches_url":"https://api.github.com/repos/ivansalazar/qwircl/branches{/branch}","tags_url":"https://api.github.com/repos/ivansalazar/qwircl/tags","blobs_url":"https://api.github.com/repos/ivansalazar/qwircl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ivansalazar/qwircl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ivansalazar/qwircl/git/refs{/sha}","trees_url":"https://api.github.com/repos/ivansalazar/qwircl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ivansalazar/qwircl/statuses/{sha}","languages_url":"https://api.github.com/repos/ivansalazar/qwircl/languages","stargazers_url":"https://api.github.com/repos/ivansalazar/qwircl/stargazers","contributors_url":"https://api.github.com/repos/ivansalazar/qwircl/contributors","subscribers_url":"https://api.github.com/repos/ivansalazar/qwircl/subscribers","subscription_url":"https://api.github.com/repos/ivansalazar/qwircl/subscription","commits_url":"https://api.github.com/repos/ivansalazar/qwircl/commits{/sha}","git_commits_url":"https://api.github.com/repos/ivansalazar/qwircl/git/commits{/sha}","comments_url":"https://api.github.com/repos/ivansalazar/qwircl/comments{/number}","issue_comment_url":"https://api.github.com/repos/ivansalazar/qwircl/issues/comments{/number}","contents_url":"https://api.github.com/repos/ivansalazar/qwircl/contents/{+path}","compare_url":"https://api.github.com/repos/ivansalazar/qwircl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ivansalazar/qwircl/merges","archive_url":"https://api.github.com/repos/ivansalazar/qwircl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ivansalazar/qwircl/downloads","issues_url":"https://api.github.com/repos/ivansalazar/qwircl/issues{/number}","pulls_url":"https://api.github.com/repos/ivansalazar/qwircl/pulls{/number}","milestones_url":"https://api.github.com/repos/ivansalazar/qwircl/milestones{/number}","notifications_url":"https://api.github.com/repos/ivansalazar/qwircl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ivansalazar/qwircl/labels{/name}","releases_url":"https://api.github.com/repos/ivansalazar/qwircl/releases{/id}","deployments_url":"https://api.github.com/repos/ivansalazar/qwircl/deployments","created_at":"2018-03-27T01:56:22Z","updated_at":"2018-04-12T17:48:48Z","pushed_at":"2018-04-28T03:48:23Z","git_url":"git://github.com/ivansalazar/qwircl.git","ssh_url":"git@github.com:ivansalazar/qwircl.git","clone_url":"https://github.com/ivansalazar/qwircl.git","svn_url":"https://github.com/ivansalazar/qwircl","homepage":null,"size":30,"stargazers_count":0,"watchers_count":0,"language":"Clojure","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":1,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5"},"html":{"href":"https://github.com/ivansalazar/qwircl/pull/5"},"issue":{"href":"https://api.github.com/repos/ivansalazar/qwircl/issues/5"},"comments":{"href":"https://api.github.com/repos/ivansalazar/qwircl/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/ivansalazar/qwircl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ivansalazar/qwircl/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/ivansalazar/qwircl/statuses/e8e6abccd66c197314316d3983fba3ae0fe32d54"}},"author_association":"OWNER"}}
{"actor":{"display_login":"tclamb"}}