{"action":"created","comment":{"url":"https://api.github.com/repos/Neamar/corporate/pulls/comments/36177641","id":36177641,"diff_hunk":"@@ -1,8 +1,127 @@\n # -*- coding: utf-8 -*-\n+from django.db.models import Max\n+\n from engine.tasks import ResolutionTask\n from engine_modules.market.models import CorporationMarket\n \n \n+class UpdateBubblesTask(ResolutionTask):\n+\t\"\"\"\n+\tUpdate the bubble value on the CorporationMarket objects\n+\t\"\"\"\n+\tRESOLUTION_ORDER = 500\n+\n+\tdef run(self, game):\n+\t\t# We can force the use of bubbles  using the force_bubbles flag\n+\n+\t\t# I do NOT remember why the test was \"not hasattr(game, 'force_bubbles')\", I left it here just in case\n+\t\t# but the check == False is necessary. TODO: check if 'hasattr' has meaning (-> can a game not have an attribute 'force_bubbles' ?)\n+\t\tif game.disable_side_effects and (not hasattr(game, 'force_bubbles') or not game.force_bubbles):\n+\t\t\treturn\n+\n+\t\tcorporation_markets = CorporationMarket.objects.filter(corporation__game=game, turn=game.current_turn).annotate(maxval=Max('value')).order_by('market__name', '-value')\n+\t\tmodifiers = {}\n+\t\tmarkets_blacklist = []\n+\t\tfor i in range(len(corporation_markets)):\n+\t\t\tcm = corporation_markets[i]\n+\t\t\tif cm.corporation not in modifiers.keys():\n+\t\t\t\tmodifiers[cm.corporation] = 0\n+\t\t\tif cm.market not in markets_blacklist:\n+\t\t\t\tif cm.value == 0:\n+\t\t\t\t\t# Negative bubble\n+\t\t\t\t\tcm.bubble_value = -1\n+\t\t\t\t\tcm.save()\n+\t\t\t\t\t# We have to propagate the modification to the corporation's assets_modifier\n+\t\t\t\t\tmodifiers[cm.corporation] += cm.bubble_value\n+\t\t\t\t# This 'elif' may appear innocuous, but by no means is it so: it signifies that a CorporationMarket with a value at 0 is NOT eligible\n+\t\t\t\t# to a dominaion bubble, even if other Corporations were to have even lower assets on this Market.\n+\t\t\t\t# This might seem redundant because Markets are not supposed to have negative values, but if taht changes (unlikely), this'll be ready.\n+\t\t\t\t# In any case, tha means '0' CANNOT be a superposed state for 'bubble_value', so we don't need 2 fields (for positive and negative bubbles)","path":"engine_modules/market/tasks.py","position":39,"original_position":39,"commit_id":"2ee68ae2b8dbf6cd8a172a299a545618f8dc9333","original_commit_id":"2ee68ae2b8dbf6cd8a172a299a545618f8dc9333","user":{"login":"Neamar","id":536844,"avatar_url":"https://avatars.githubusercontent.com/u/536844?v=3","gravatar_id":"","url":"https://api.github.com/users/Neamar","html_url":"https://github.com/Neamar","followers_url":"https://api.github.com/users/Neamar/followers","following_url":"https://api.github.com/users/Neamar/following{/other_user}","gists_url":"https://api.github.com/users/Neamar/gists{/gist_id}","starred_url":"https://api.github.com/users/Neamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neamar/subscriptions","organizations_url":"https://api.github.com/users/Neamar/orgs","repos_url":"https://api.github.com/users/Neamar/repos","events_url":"https://api.github.com/users/Neamar/events{/privacy}","received_events_url":"https://api.github.com/users/Neamar/received_events","type":"User","site_admin":false},"body":"tha => that ? it ?","created_at":"2015-08-04T11:19:58Z","updated_at":"2015-08-04T11:19:58Z","html_url":"https://github.com/Neamar/corporate/pull/197#discussion_r36177641","pull_request_url":"https://api.github.com/repos/Neamar/corporate/pulls/197","_links":{"self":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/comments/36177641"},"html":{"href":"https://github.com/Neamar/corporate/pull/197#discussion_r36177641"},"pull_request":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/197"}}},"pull_request":{"url":"https://api.github.com/repos/Neamar/corporate/pulls/197","id":41521688,"html_url":"https://github.com/Neamar/corporate/pull/197","diff_url":"https://github.com/Neamar/corporate/pull/197.diff","patch_url":"https://github.com/Neamar/corporate/pull/197.patch","issue_url":"https://api.github.com/repos/Neamar/corporate/issues/197","number":197,"state":"open","locked":false,"title":"Refactor bubbles","user":{"login":"your-mom-noob","id":4883483,"avatar_url":"https://avatars.githubusercontent.com/u/4883483?v=3","gravatar_id":"","url":"https://api.github.com/users/your-mom-noob","html_url":"https://github.com/your-mom-noob","followers_url":"https://api.github.com/users/your-mom-noob/followers","following_url":"https://api.github.com/users/your-mom-noob/following{/other_user}","gists_url":"https://api.github.com/users/your-mom-noob/gists{/gist_id}","starred_url":"https://api.github.com/users/your-mom-noob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/your-mom-noob/subscriptions","organizations_url":"https://api.github.com/users/your-mom-noob/orgs","repos_url":"https://api.github.com/users/your-mom-noob/repos","events_url":"https://api.github.com/users/your-mom-noob/events{/privacy}","received_events_url":"https://api.github.com/users/your-mom-noob/received_events","type":"User","site_admin":false},"body":"This should be ok, even though I couldn't exactly test the logs. (this wasn't the point of that branch, so good enough)","created_at":"2015-08-03T23:45:55Z","updated_at":"2015-08-04T11:19:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e3acd155ee3e7b3c6f29b9e3ef394b80a1d3a8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Neamar/corporate/pulls/197/commits","review_comments_url":"https://api.github.com/repos/Neamar/corporate/pulls/197/comments","review_comment_url":"https://api.github.com/repos/Neamar/corporate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Neamar/corporate/issues/197/comments","statuses_url":"https://api.github.com/repos/Neamar/corporate/statuses/2ee68ae2b8dbf6cd8a172a299a545618f8dc9333","head":{"label":"Neamar:refactor_bubbles","ref":"refactor_bubbles","sha":"2ee68ae2b8dbf6cd8a172a299a545618f8dc9333","user":{"login":"Neamar","id":536844,"avatar_url":"https://avatars.githubusercontent.com/u/536844?v=3","gravatar_id":"","url":"https://api.github.com/users/Neamar","html_url":"https://github.com/Neamar","followers_url":"https://api.github.com/users/Neamar/followers","following_url":"https://api.github.com/users/Neamar/following{/other_user}","gists_url":"https://api.github.com/users/Neamar/gists{/gist_id}","starred_url":"https://api.github.com/users/Neamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neamar/subscriptions","organizations_url":"https://api.github.com/users/Neamar/orgs","repos_url":"https://api.github.com/users/Neamar/repos","events_url":"https://api.github.com/users/Neamar/events{/privacy}","received_events_url":"https://api.github.com/users/Neamar/received_events","type":"User","site_admin":false},"repo":{"id":15422111,"name":"corporate","full_name":"Neamar/corporate","owner":{"login":"Neamar","id":536844,"avatar_url":"https://avatars.githubusercontent.com/u/536844?v=3","gravatar_id":"","url":"https://api.github.com/users/Neamar","html_url":"https://github.com/Neamar","followers_url":"https://api.github.com/users/Neamar/followers","following_url":"https://api.github.com/users/Neamar/following{/other_user}","gists_url":"https://api.github.com/users/Neamar/gists{/gist_id}","starred_url":"https://api.github.com/users/Neamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neamar/subscriptions","organizations_url":"https://api.github.com/users/Neamar/orgs","repos_url":"https://api.github.com/users/Neamar/repos","events_url":"https://api.github.com/users/Neamar/events{/privacy}","received_events_url":"https://api.github.com/users/Neamar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Neamar/corporate","description":"It's not a game, it's The Game.","fork":false,"url":"https://api.github.com/repos/Neamar/corporate","forks_url":"https://api.github.com/repos/Neamar/corporate/forks","keys_url":"https://api.github.com/repos/Neamar/corporate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Neamar/corporate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Neamar/corporate/teams","hooks_url":"https://api.github.com/repos/Neamar/corporate/hooks","issue_events_url":"https://api.github.com/repos/Neamar/corporate/issues/events{/number}","events_url":"https://api.github.com/repos/Neamar/corporate/events","assignees_url":"https://api.github.com/repos/Neamar/corporate/assignees{/user}","branches_url":"https://api.github.com/repos/Neamar/corporate/branches{/branch}","tags_url":"https://api.github.com/repos/Neamar/corporate/tags","blobs_url":"https://api.github.com/repos/Neamar/corporate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Neamar/corporate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Neamar/corporate/git/refs{/sha}","trees_url":"https://api.github.com/repos/Neamar/corporate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Neamar/corporate/statuses/{sha}","languages_url":"https://api.github.com/repos/Neamar/corporate/languages","stargazers_url":"https://api.github.com/repos/Neamar/corporate/stargazers","contributors_url":"https://api.github.com/repos/Neamar/corporate/contributors","subscribers_url":"https://api.github.com/repos/Neamar/corporate/subscribers","subscription_url":"https://api.github.com/repos/Neamar/corporate/subscription","commits_url":"https://api.github.com/repos/Neamar/corporate/commits{/sha}","git_commits_url":"https://api.github.com/repos/Neamar/corporate/git/commits{/sha}","comments_url":"https://api.github.com/repos/Neamar/corporate/comments{/number}","issue_comment_url":"https://api.github.com/repos/Neamar/corporate/issues/comments{/number}","contents_url":"https://api.github.com/repos/Neamar/corporate/contents/{+path}","compare_url":"https://api.github.com/repos/Neamar/corporate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Neamar/corporate/merges","archive_url":"https://api.github.com/repos/Neamar/corporate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Neamar/corporate/downloads","issues_url":"https://api.github.com/repos/Neamar/corporate/issues{/number}","pulls_url":"https://api.github.com/repos/Neamar/corporate/pulls{/number}","milestones_url":"https://api.github.com/repos/Neamar/corporate/milestones{/number}","notifications_url":"https://api.github.com/repos/Neamar/corporate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Neamar/corporate/labels{/name}","releases_url":"https://api.github.com/repos/Neamar/corporate/releases{/id}","created_at":"2013-12-24T16:57:52Z","updated_at":"2015-08-02T12:33:12Z","pushed_at":"2015-08-04T09:57:07Z","git_url":"git://github.com/Neamar/corporate.git","ssh_url":"git@github.com:Neamar/corporate.git","clone_url":"https://github.com/Neamar/corporate.git","svn_url":"https://github.com/Neamar/corporate","homepage":"http://corporategame.me","size":8993,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":17,"forks":1,"open_issues":17,"watchers":6,"default_branch":"master"}},"base":{"label":"Neamar:v2","ref":"v2","sha":"ca3c6f4891f619d8b34a09dca917475f384f6081","user":{"login":"Neamar","id":536844,"avatar_url":"https://avatars.githubusercontent.com/u/536844?v=3","gravatar_id":"","url":"https://api.github.com/users/Neamar","html_url":"https://github.com/Neamar","followers_url":"https://api.github.com/users/Neamar/followers","following_url":"https://api.github.com/users/Neamar/following{/other_user}","gists_url":"https://api.github.com/users/Neamar/gists{/gist_id}","starred_url":"https://api.github.com/users/Neamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neamar/subscriptions","organizations_url":"https://api.github.com/users/Neamar/orgs","repos_url":"https://api.github.com/users/Neamar/repos","events_url":"https://api.github.com/users/Neamar/events{/privacy}","received_events_url":"https://api.github.com/users/Neamar/received_events","type":"User","site_admin":false},"repo":{"id":15422111,"name":"corporate","full_name":"Neamar/corporate","owner":{"login":"Neamar","id":536844,"avatar_url":"https://avatars.githubusercontent.com/u/536844?v=3","gravatar_id":"","url":"https://api.github.com/users/Neamar","html_url":"https://github.com/Neamar","followers_url":"https://api.github.com/users/Neamar/followers","following_url":"https://api.github.com/users/Neamar/following{/other_user}","gists_url":"https://api.github.com/users/Neamar/gists{/gist_id}","starred_url":"https://api.github.com/users/Neamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neamar/subscriptions","organizations_url":"https://api.github.com/users/Neamar/orgs","repos_url":"https://api.github.com/users/Neamar/repos","events_url":"https://api.github.com/users/Neamar/events{/privacy}","received_events_url":"https://api.github.com/users/Neamar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Neamar/corporate","description":"It's not a game, it's The Game.","fork":false,"url":"https://api.github.com/repos/Neamar/corporate","forks_url":"https://api.github.com/repos/Neamar/corporate/forks","keys_url":"https://api.github.com/repos/Neamar/corporate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Neamar/corporate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Neamar/corporate/teams","hooks_url":"https://api.github.com/repos/Neamar/corporate/hooks","issue_events_url":"https://api.github.com/repos/Neamar/corporate/issues/events{/number}","events_url":"https://api.github.com/repos/Neamar/corporate/events","assignees_url":"https://api.github.com/repos/Neamar/corporate/assignees{/user}","branches_url":"https://api.github.com/repos/Neamar/corporate/branches{/branch}","tags_url":"https://api.github.com/repos/Neamar/corporate/tags","blobs_url":"https://api.github.com/repos/Neamar/corporate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Neamar/corporate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Neamar/corporate/git/refs{/sha}","trees_url":"https://api.github.com/repos/Neamar/corporate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Neamar/corporate/statuses/{sha}","languages_url":"https://api.github.com/repos/Neamar/corporate/languages","stargazers_url":"https://api.github.com/repos/Neamar/corporate/stargazers","contributors_url":"https://api.github.com/repos/Neamar/corporate/contributors","subscribers_url":"https://api.github.com/repos/Neamar/corporate/subscribers","subscription_url":"https://api.github.com/repos/Neamar/corporate/subscription","commits_url":"https://api.github.com/repos/Neamar/corporate/commits{/sha}","git_commits_url":"https://api.github.com/repos/Neamar/corporate/git/commits{/sha}","comments_url":"https://api.github.com/repos/Neamar/corporate/comments{/number}","issue_comment_url":"https://api.github.com/repos/Neamar/corporate/issues/comments{/number}","contents_url":"https://api.github.com/repos/Neamar/corporate/contents/{+path}","compare_url":"https://api.github.com/repos/Neamar/corporate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Neamar/corporate/merges","archive_url":"https://api.github.com/repos/Neamar/corporate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Neamar/corporate/downloads","issues_url":"https://api.github.com/repos/Neamar/corporate/issues{/number}","pulls_url":"https://api.github.com/repos/Neamar/corporate/pulls{/number}","milestones_url":"https://api.github.com/repos/Neamar/corporate/milestones{/number}","notifications_url":"https://api.github.com/repos/Neamar/corporate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Neamar/corporate/labels{/name}","releases_url":"https://api.github.com/repos/Neamar/corporate/releases{/id}","created_at":"2013-12-24T16:57:52Z","updated_at":"2015-08-02T12:33:12Z","pushed_at":"2015-08-04T09:57:07Z","git_url":"git://github.com/Neamar/corporate.git","ssh_url":"git@github.com:Neamar/corporate.git","clone_url":"https://github.com/Neamar/corporate.git","svn_url":"https://github.com/Neamar/corporate","homepage":"http://corporategame.me","size":8993,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":17,"forks":1,"open_issues":17,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/197"},"html":{"href":"https://github.com/Neamar/corporate/pull/197"},"issue":{"href":"https://api.github.com/repos/Neamar/corporate/issues/197"},"comments":{"href":"https://api.github.com/repos/Neamar/corporate/issues/197/comments"},"review_comments":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/197/comments"},"review_comment":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Neamar/corporate/pulls/197/commits"},"statuses":{"href":"https://api.github.com/repos/Neamar/corporate/statuses/2ee68ae2b8dbf6cd8a172a299a545618f8dc9333"}}}}