{"action":"created","comment":{"url":"https://api.github.com/repos/lykoss/lykos/pulls/comments/108049485","pull_request_review_id":29060162,"id":108049485,"diff_hunk":"@@ -103,100 +100,88 @@ def on_del_player(evt, cli, var, nick, nickrole, nicktpls, death_triggers):\n             evt.params.del_player(cli, target, True, end_game=False, killer_role=nickrole, deadlist=evt.params.deadlist, original=evt.params.original, ismain=False)\n             evt.data[\"pl\"] = evt.params.refresh_pl(pl)\n \n-@event_listener(\"rename_player\")\n-def on_rename(evt, cli, var, prefix, nick):\n-    kvp = []\n-    for a,b in KILLS.items():\n-        if a == prefix:\n-            a = nick\n-        if b == prefix:\n-            b = nick\n-        kvp.append((a,b))\n-    KILLS.update(kvp)\n-    if prefix in KILLS:\n-        del KILLS[prefix]\n-    kvp = []\n-    for a,b in TARGETS.items():\n-        nl = set()\n-        for n in b:\n-            if n == prefix:\n-                n = nick\n-            nl.add(n)\n-        if a == prefix:\n-            a = nick\n-        kvp.append((a,nl))\n-    TARGETS.update(kvp)\n-    if prefix in TARGETS:\n-        del TARGETS[prefix]\n-\n @event_listener(\"night_acted\")\n def on_acted(evt, cli, var, nick, sender):\n-    if nick in KILLS:\n+    if users._get(nick) in KILLS: # FIXME\n         evt.data[\"acted\"] = True\n \n+@event_listener(\"swap_player\")\n+def on_swap(evt, var, old_user, user):\n+    if old_user in KILLS:\n+        KILLS[user] = KILLS.pop(old_user)\n+    if old_user in TARGETS:\n+        TARGETS[user] = TARGETS.pop(old_user)\n+\n+    for dullahan, target in KILLS.items():\n+        if target is old_user:\n+            KILLS[dullahan] = user\n+\n+    for dullahan, targets in TARGETS.items():\n+        if old_user in targets:\n+            targets.remove(old_user)\n+            targets.add(user)\n+\n @event_listener(\"get_special\")\n def on_get_special(evt, cli, var):\n     evt.data[\"special\"].update(var.ROLES[\"dullahan\"])\n \n @event_listener(\"transition_day\", priority=2)\n def on_transition_day(evt, cli, var):\n-    for k, d in list(KILLS.items()):\n-        evt.data[\"victims\"].append(d)\n-        evt.data[\"onlybywolves\"].discard(d)\n-        evt.data[\"killers\"][d].append(k)\n-        del KILLS[k]\n+    while KILLS:\n+        k, d = KILLS.popitem()\n+        evt.data[\"victims\"].append(d.nick)\n+        evt.data[\"onlybywolves\"].discard(d.nick)\n+        evt.data[\"killers\"][d.nick].append(k.nick)\n \n @event_listener(\"exchange_roles\")\n def on_exchange(evt, cli, var, actor, nick, actor_role, nick_role):\n-    if actor in KILLS:\n-        del KILLS[actor]\n-    if nick in KILLS:\n-        del KILLS[nick]\n-    if actor_role == \"dullahan\" and nick_role != \"dullahan\" and actor in TARGETS:\n-        TARGETS[nick] = TARGETS[actor] - {nick}\n-        del TARGETS[actor]\n-    elif nick_role == \"dullahan\" and actor_role != \"dullahan\" and nick in TARGETS:\n-        TARGETS[actor] = TARGETS[nick] - {actor}\n-        del TARGETS[nick]\n+    for k in set(KILLS):","path":"src/roles/dullahan.py","position":191,"original_position":191,"commit_id":"0744a523ea854a05ebc0b141eedb257bf72d2e73","original_commit_id":"0744a523ea854a05ebc0b141eedb257bf72d2e73","user":{"login":"Vgr255","id":4260395,"avatar_url":"https://avatars0.githubusercontent.com/u/4260395?v=3","gravatar_id":"","url":"https://api.github.com/users/Vgr255","html_url":"https://github.com/Vgr255","followers_url":"https://api.github.com/users/Vgr255/followers","following_url":"https://api.github.com/users/Vgr255/following{/other_user}","gists_url":"https://api.github.com/users/Vgr255/gists{/gist_id}","starred_url":"https://api.github.com/users/Vgr255/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vgr255/subscriptions","organizations_url":"https://api.github.com/users/Vgr255/orgs","repos_url":"https://api.github.com/users/Vgr255/repos","events_url":"https://api.github.com/users/Vgr255/events{/privacy}","received_events_url":"https://api.github.com/users/Vgr255/received_events","type":"User","site_admin":false},"body":"Except that's not actually possible - `KILLS` doesn't store nicks, it stores users. Therefore, we need to check for that. When that event is updated to use the new API, we won't need to do that anymore, but for now, we do. And nope, shoe-horning in a few `users._get` calls won't work - that function is O(n), and you'd probably call it several times.","created_at":"2017-03-26T01:18:13Z","updated_at":"2017-03-26T01:18:13Z","html_url":"https://github.com/lykoss/lykos/pull/292#discussion_r108049485","pull_request_url":"https://api.github.com/repos/lykoss/lykos/pulls/292","_links":{"self":{"href":"https://api.github.com/repos/lykoss/lykos/pulls/comments/108049485"},"html":{"href":"https://github.com/lykoss/lykos/pull/292#discussion_r108049485"},"pull_request":{"href":"https://api.github.com/repos/lykoss/lykos/pulls/292"}}},"pull_request":{"url":"https://api.github.com/repos/lykoss/lykos/pulls/292","id":112593895,"html_url":"https://github.com/lykoss/lykos/pull/292","diff_url":"https://github.com/lykoss/lykos/pull/292.diff","patch_url":"https://github.com/lykoss/lykos/pull/292.patch","issue_url":"https://api.github.com/repos/lykoss/lykos/issues/292","number":292,"state":"open","locked":false,"title":"Convert dullahan to use the new API","user":{"login":"Vgr255","id":4260395,"avatar_url":"https://avatars0.githubusercontent.com/u/4260395?v=3","gravatar_id":"","url":"https://api.github.com/users/Vgr255","html_url":"https://github.com/Vgr255","followers_url":"https://api.github.com/users/Vgr255/followers","following_url":"https://api.github.com/users/Vgr255/following{/other_user}","gists_url":"https://api.github.com/users/Vgr255/gists{/gist_id}","starred_url":"https://api.github.com/users/Vgr255/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vgr255/subscriptions","organizations_url":"https://api.github.com/users/Vgr255/orgs","repos_url":"https://api.github.com/users/Vgr255/repos","events_url":"https://api.github.com/users/Vgr255/events{/privacy}","received_events_url":"https://api.github.com/users/Vgr255/received_events","type":"User","site_admin":false},"body":"Tested thanks to @nyuszika7h, working as intended. This is the first iteration of converting roles to use the new API, more will follow!","created_at":"2017-03-25T17:05:41Z","updated_at":"2017-03-26T01:18:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8559249f74b790d1150285769d386288f1f05db","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/lykoss/lykos/pulls/292/commits","review_comments_url":"https://api.github.com/repos/lykoss/lykos/pulls/292/comments","review_comment_url":"https://api.github.com/repos/lykoss/lykos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lykoss/lykos/issues/292/comments","statuses_url":"https://api.github.com/repos/lykoss/lykos/statuses/0744a523ea854a05ebc0b141eedb257bf72d2e73","head":{"label":"lykoss:converted-dullahan","ref":"converted-dullahan","sha":"0744a523ea854a05ebc0b141eedb257bf72d2e73","user":{"login":"lykoss","id":6707035,"avatar_url":"https://avatars1.githubusercontent.com/u/6707035?v=3","gravatar_id":"","url":"https://api.github.com/users/lykoss","html_url":"https://github.com/lykoss","followers_url":"https://api.github.com/users/lykoss/followers","following_url":"https://api.github.com/users/lykoss/following{/other_user}","gists_url":"https://api.github.com/users/lykoss/gists{/gist_id}","starred_url":"https://api.github.com/users/lykoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lykoss/subscriptions","organizations_url":"https://api.github.com/users/lykoss/orgs","repos_url":"https://api.github.com/users/lykoss/repos","events_url":"https://api.github.com/users/lykoss/events{/privacy}","received_events_url":"https://api.github.com/users/lykoss/received_events","type":"Organization","site_admin":false},"repo":{"id":16919993,"name":"lykos","full_name":"lykoss/lykos","owner":{"login":"lykoss","id":6707035,"avatar_url":"https://avatars1.githubusercontent.com/u/6707035?v=3","gravatar_id":"","url":"https://api.github.com/users/lykoss","html_url":"https://github.com/lykoss","followers_url":"https://api.github.com/users/lykoss/followers","following_url":"https://api.github.com/users/lykoss/following{/other_user}","gists_url":"https://api.github.com/users/lykoss/gists{/gist_id}","starred_url":"https://api.github.com/users/lykoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lykoss/subscriptions","organizations_url":"https://api.github.com/users/lykoss/orgs","repos_url":"https://api.github.com/users/lykoss/repos","events_url":"https://api.github.com/users/lykoss/events{/privacy}","received_events_url":"https://api.github.com/users/lykoss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lykoss/lykos","description":"Werewolf, the popular detective/social party game (a theme of Mafia)","fork":false,"url":"https://api.github.com/repos/lykoss/lykos","forks_url":"https://api.github.com/repos/lykoss/lykos/forks","keys_url":"https://api.github.com/repos/lykoss/lykos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lykoss/lykos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lykoss/lykos/teams","hooks_url":"https://api.github.com/repos/lykoss/lykos/hooks","issue_events_url":"https://api.github.com/repos/lykoss/lykos/issues/events{/number}","events_url":"https://api.github.com/repos/lykoss/lykos/events","assignees_url":"https://api.github.com/repos/lykoss/lykos/assignees{/user}","branches_url":"https://api.github.com/repos/lykoss/lykos/branches{/branch}","tags_url":"https://api.github.com/repos/lykoss/lykos/tags","blobs_url":"https://api.github.com/repos/lykoss/lykos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lykoss/lykos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lykoss/lykos/git/refs{/sha}","trees_url":"https://api.github.com/repos/lykoss/lykos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lykoss/lykos/statuses/{sha}","languages_url":"https://api.github.com/repos/lykoss/lykos/languages","stargazers_url":"https://api.github.com/repos/lykoss/lykos/stargazers","contributors_url":"https://api.github.com/repos/lykoss/lykos/contributors","subscribers_url":"https://api.github.com/repos/lykoss/lykos/subscribers","subscription_url":"https://api.github.com/repos/lykoss/lykos/subscription","commits_url":"https://api.github.com/repos/lykoss/lykos/commits{/sha}","git_commits_url":"https://api.github.com/repos/lykoss/lykos/git/commits{/sha}","comments_url":"https://api.github.com/repos/lykoss/lykos/comments{/number}","issue_comment_url":"https://api.github.com/repos/lykoss/lykos/issues/comments{/number}","contents_url":"https://api.github.com/repos/lykoss/lykos/contents/{+path}","compare_url":"https://api.github.com/repos/lykoss/lykos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lykoss/lykos/merges","archive_url":"https://api.github.com/repos/lykoss/lykos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lykoss/lykos/downloads","issues_url":"https://api.github.com/repos/lykoss/lykos/issues{/number}","pulls_url":"https://api.github.com/repos/lykoss/lykos/pulls{/number}","milestones_url":"https://api.github.com/repos/lykoss/lykos/milestones{/number}","notifications_url":"https://api.github.com/repos/lykoss/lykos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lykoss/lykos/labels{/name}","releases_url":"https://api.github.com/repos/lykoss/lykos/releases{/id}","deployments_url":"https://api.github.com/repos/lykoss/lykos/deployments","created_at":"2014-02-17T17:02:57Z","updated_at":"2017-03-05T23:54:00Z","pushed_at":"2017-03-25T17:05:42Z","git_url":"git://github.com/lykoss/lykos.git","ssh_url":"git@github.com:lykoss/lykos.git","clone_url":"https://github.com/lykoss/lykos.git","svn_url":"https://github.com/lykoss/lykos","homepage":"https://werewolf.chat","size":7060,"stargazers_count":65,"watchers_count":65,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":33,"forks":42,"open_issues":33,"watchers":65,"default_branch":"stable"}},"base":{"label":"lykoss:master","ref":"master","sha":"322de008e7fed07c8fd0b97aea4c66dc01abae7d","user":{"login":"lykoss","id":6707035,"avatar_url":"https://avatars1.githubusercontent.com/u/6707035?v=3","gravatar_id":"","url":"https://api.github.com/users/lykoss","html_url":"https://github.com/lykoss","followers_url":"https://api.github.com/users/lykoss/followers","following_url":"https://api.github.com/users/lykoss/following{/other_user}","gists_url":"https://api.github.com/users/lykoss/gists{/gist_id}","starred_url":"https://api.github.com/users/lykoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lykoss/subscriptions","organizations_url":"https://api.github.com/users/lykoss/orgs","repos_url":"https://api.github.com/users/lykoss/repos","events_url":"https://api.github.com/users/lykoss/events{/privacy}","received_events_url":"https://api.github.com/users/lykoss/received_events","type":"Organization","site_admin":false},"repo":{"id":16919993,"name":"lykos","full_name":"lykoss/lykos","owner":{"login":"lykoss","id":6707035,"avatar_url":"https://avatars1.githubusercontent.com/u/6707035?v=3","gravatar_id":"","url":"https://api.github.com/users/lykoss","html_url":"https://github.com/lykoss","followers_url":"https://api.github.com/users/lykoss/followers","following_url":"https://api.github.com/users/lykoss/following{/other_user}","gists_url":"https://api.github.com/users/lykoss/gists{/gist_id}","starred_url":"https://api.github.com/users/lykoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lykoss/subscriptions","organizations_url":"https://api.github.com/users/lykoss/orgs","repos_url":"https://api.github.com/users/lykoss/repos","events_url":"https://api.github.com/users/lykoss/events{/privacy}","received_events_url":"https://api.github.com/users/lykoss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lykoss/lykos","description":"Werewolf, the popular detective/social party game (a theme of Mafia)","fork":false,"url":"https://api.github.com/repos/lykoss/lykos","forks_url":"https://api.github.com/repos/lykoss/lykos/forks","keys_url":"https://api.github.com/repos/lykoss/lykos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lykoss/lykos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lykoss/lykos/teams","hooks_url":"https://api.github.com/repos/lykoss/lykos/hooks","issue_events_url":"https://api.github.com/repos/lykoss/lykos/issues/events{/number}","events_url":"https://api.github.com/repos/lykoss/lykos/events","assignees_url":"https://api.github.com/repos/lykoss/lykos/assignees{/user}","branches_url":"https://api.github.com/repos/lykoss/lykos/branches{/branch}","tags_url":"https://api.github.com/repos/lykoss/lykos/tags","blobs_url":"https://api.github.com/repos/lykoss/lykos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lykoss/lykos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lykoss/lykos/git/refs{/sha}","trees_url":"https://api.github.com/repos/lykoss/lykos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lykoss/lykos/statuses/{sha}","languages_url":"https://api.github.com/repos/lykoss/lykos/languages","stargazers_url":"https://api.github.com/repos/lykoss/lykos/stargazers","contributors_url":"https://api.github.com/repos/lykoss/lykos/contributors","subscribers_url":"https://api.github.com/repos/lykoss/lykos/subscribers","subscription_url":"https://api.github.com/repos/lykoss/lykos/subscription","commits_url":"https://api.github.com/repos/lykoss/lykos/commits{/sha}","git_commits_url":"https://api.github.com/repos/lykoss/lykos/git/commits{/sha}","comments_url":"https://api.github.com/repos/lykoss/lykos/comments{/number}","issue_comment_url":"https://api.github.com/repos/lykoss/lykos/issues/comments{/number}","contents_url":"https://api.github.com/repos/lykoss/lykos/contents/{+path}","compare_url":"https://api.github.com/repos/lykoss/lykos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lykoss/lykos/merges","archive_url":"https://api.github.com/repos/lykoss/lykos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lykoss/lykos/downloads","issues_url":"https://api.github.com/repos/lykoss/lykos/issues{/number}","pulls_url":"https://api.github.com/repos/lykoss/lykos/pulls{/number}","milestones_url":"https://api.github.com/repos/lykoss/lykos/milestones{/number}","notifications_url":"https://api.github.com/repos/lykoss/lykos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lykoss/lykos/labels{/name}","releases_url":"https://api.github.com/repos/lykoss/lykos/releases{/id}","deployments_url":"https://api.github.com/repos/lykoss/lykos/deployments","created_at":"2014-02-17T17:02:57Z","updated_at":"2017-03-05T23:54:00Z","pushed_at":"2017-03-25T17:05:42Z","git_url":"git://github.com/lykoss/lykos.git","ssh_url":"git@github.com:lykoss/lykos.git","clone_url":"https://github.com/lykoss/lykos.git","svn_url":"https://github.com/lykoss/lykos","homepage":"https://werewolf.chat","size":7060,"stargazers_count":65,"watchers_count":65,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":33,"forks":42,"open_issues":33,"watchers":65,"default_branch":"stable"}},"_links":{"self":{"href":"https://api.github.com/repos/lykoss/lykos/pulls/292"},"html":{"href":"https://github.com/lykoss/lykos/pull/292"},"issue":{"href":"https://api.github.com/repos/lykoss/lykos/issues/292"},"comments":{"href":"https://api.github.com/repos/lykoss/lykos/issues/292/comments"},"review_comments":{"href":"https://api.github.com/repos/lykoss/lykos/pulls/292/comments"},"review_comment":{"href":"https://api.github.com/repos/lykoss/lykos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lykoss/lykos/pulls/292/commits"},"statuses":{"href":"https://api.github.com/repos/lykoss/lykos/statuses/0744a523ea854a05ebc0b141eedb257bf72d2e73"}}}}
{"actor":{"display_login":"Vgr255"}}