{"action":"created","issue":{"url":"https://api.github.com/repos/hybrasyl/server/issues/6","labels_url":"https://api.github.com/repos/hybrasyl/server/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/hybrasyl/server/issues/6/comments","events_url":"https://api.github.com/repos/hybrasyl/server/issues/6/events","html_url":"https://github.com/hybrasyl/server/pull/6","id":89227756,"number":6,"title":"Supporting negative weights","user":{"login":"luke-segars","id":313409,"avatar_url":"https://avatars.githubusercontent.com/u/313409?v=3","gravatar_id":"","url":"https://api.github.com/users/luke-segars","html_url":"https://github.com/luke-segars","followers_url":"https://api.github.com/users/luke-segars/followers","following_url":"https://api.github.com/users/luke-segars/following{/other_user}","gists_url":"https://api.github.com/users/luke-segars/gists{/gist_id}","starred_url":"https://api.github.com/users/luke-segars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luke-segars/subscriptions","organizations_url":"https://api.github.com/users/luke-segars/orgs","repos_url":"https://api.github.com/users/luke-segars/repos","events_url":"https://api.github.com/users/luke-segars/events{/privacy}","received_events_url":"https://api.github.com/users/luke-segars/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-18T08:07:03Z","updated_at":"2015-06-19T17:22:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hybrasyl/server/pulls/6","html_url":"https://github.com/hybrasyl/server/pull/6","diff_url":"https://github.com/hybrasyl/server/pull/6.diff","patch_url":"https://github.com/hybrasyl/server/pull/6.patch"},"body":"See bug at https://hybrasyl.atlassian.net/browse/SERVER-69.\r\n\r\nThis patch modifies how inventory weight is stored to support negative weights. Mark's diagnosis in the bug was correct; previously weight was being stored as an unsigned integer (meaning no negatives and it'd wrap around to a gigantic value if you tried).\r\n\r\nNot a lot of notable changes here, but one explicit design decision work mentioning. I separated Inventory.CurrentWeight into two different properties: CurrentWeight (the true weight of the inventory, which could be negative), and VisibleWeight (which is never less than zero, intended to be displayed to the client). This introduces potential for bugs down the road since there are two ways to access the weight, though IMO this is the \"right\" way to do it since it allows for properly accounting for circumstances where the user goes from a negative weight to a positive weight (properly discounting the negative weight). For example, if you pick up items in the following order with the following weights:\r\n\r\n[With single field] 1 + 1 - 2 - 2 + 1 = 1, since you effectively forget about everything < 0\r\n\r\n[With two fields] 1 + 1 - 2 - 2 + 1 = -1, though displayed to the client as zero\r\n\r\nI tested this by creating two items, one having positive weight and the other having negative. I've confirmed that items with negative weights can now be picked up, that they have the intended effect on the full inventory weight, and that picking up various sequences like the one shown above produce the proper values."},"comment":{"url":"https://api.github.com/repos/hybrasyl/server/issues/comments/113580816","html_url":"https://github.com/hybrasyl/server/pull/6#issuecomment-113580816","issue_url":"https://api.github.com/repos/hybrasyl/server/issues/6","id":113580816,"user":{"login":"luke-segars","id":313409,"avatar_url":"https://avatars.githubusercontent.com/u/313409?v=3","gravatar_id":"","url":"https://api.github.com/users/luke-segars","html_url":"https://github.com/luke-segars","followers_url":"https://api.github.com/users/luke-segars/followers","following_url":"https://api.github.com/users/luke-segars/following{/other_user}","gists_url":"https://api.github.com/users/luke-segars/gists{/gist_id}","starred_url":"https://api.github.com/users/luke-segars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luke-segars/subscriptions","organizations_url":"https://api.github.com/users/luke-segars/orgs","repos_url":"https://api.github.com/users/luke-segars/repos","events_url":"https://api.github.com/users/luke-segars/events{/privacy}","received_events_url":"https://api.github.com/users/luke-segars/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T17:22:31Z","updated_at":"2015-06-19T17:22:31Z","body":"Just noticing that I should probably make this change for equipment too (it's currently only done for inventory). Will try to revise this weekend."}}