HabitRPG/habitrpg-shared — pull request #327 by brandonjreid (2014-10-01 23:35:25+00:00)
Title: Remove the right amount of gold and exp when unchecking a task

There are a lot of code changes for this, but a good portion of it is splitting calculateDelta() into two functions. The idea here is when a task is unchecked the gold and experience removed is different from the amount added. When we uncheck a task, we need to change the task back to its original value (which involves approximating what that original value was), then calculate the delta off of the original value. That delta can then be used for the exp and gold calculation.

I tested the approximation code for over 600,000 values between -47.27 and 21.27 and it always approximates the original value in 2 to 4 iterations, so this shouldn't affect anything speed wise. I can upload the python code i wrote to test it, if you would like.

This doesn't fix any issues with finding an item on an accidental click, but at least the numbers come out the same now.

This fixes issue HabitRPG/habitrpg#964 along with countless other ones that I won't mention here :)