HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
12k stars 4.09k forks source link

buying rewards / items with gold costs a little more than listed (or notification is inaccurate) #4113

Closed Mousekiro closed 8 years ago

Mousekiro commented 10 years ago

I got around to buying myself the Witchy outfit today. I noticed that all the items in it seemed to cost a little more than the listed price -- for instance, the item that cost 160 gold gave me the message that I'd lost 161.76. This wasn't a case of an earlier gold cost being rolled into one refresh of the site, as every witchy item (all bought one after the other) did the same thing. The Health Potion, however, did not, and nor did one of my custom rewards when I experimented with buying it -- they stayed at their proper prices. Unfortunately, since I've now bought all the witchy items, there's no way I can try to replicate further.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Alys commented 10 years ago

@Mousekiro : We can allow you to test again, if you're willing to. If you tell me your API User ID, I can adjust those items so that you lose them and need to buy them again. You can use Settings -> Site -> Fix Character Values to give yourself the gold required (unfortunately I can't do that for you). I would very much like to see what happens, if you don't mind helping us by going through this test.

deilann commented 10 years ago

This happened to me with the valentines. Can't look up the ticket, but may be related. On Oct 5, 2014 2:27 PM, "Alice Harris" notifications@github.com wrote:

@Mousekiro https://github.com/Mousekiro : We can allow you to test again, if you're willing to. If you tell me your API User ID https://habitrpg.com/#/options/settings/api, I can adjust those items so that you lose them and need to buy them again. You can use Settings -> Site -> Fix Character Values to give yourself the gold required (unfortunately I can't do that for you). I would very much like to see what happens, if you don't mind helping us by going through this test.

— Reply to this email directly or view it on GitHub https://github.com/HabitRPG/habitrpg/issues/4113#issuecomment-57953029.

Alys commented 10 years ago

The ticket deilann was referring to is https://github.com/HabitRPG/habitrpg/issues/2862 "Valentines Cost more than 10 GP"

ShilohT commented 10 years ago

I just bought my monthly gems and it kept saying "+1 gem" and "- 20 gold 27 silver" for each one. It was not actually taking extra silver though. I tried refreshing once and this persisted. I also tested buying other items (spooky sparkles, equipment, custom rewards) afterwards and those displayed/took their normal listed amounts. I'm happy to help with any further testing, but I did buy all my gems already. (User ID: dec337ba-84e8-4336-a754-4bda0c8c9e5b )

Alys commented 10 years ago

Interesting that for @ShilohT it was displaying the incorrect amount but charging the correct amount. @Mousekiro did you notice the same thing?

Perhaps there's something glitchy with this code: https://github.com/HabitRPG/habitrpg/blob/develop/public/js/controllers/notificationCtrl.js#L27

    $rootScope.$watch('user.stats.gp', function(after, before) {
      if (after == before) return;
      if (User.user.stats.lvl == 0) return;
      var money = after - before;
      var bonus = User.user._tmp.streakBonus;
      Notification.gp(money, bonus || 0);

https://github.com/HabitRPG/habitrpg/blob/develop/public/js/services/notificationServices.js#L58

      gp: function(val, bonus) {
        notify(sign(val) + " " + coins(val - bonus), 'gp');
      },

https://github.com/HabitRPG/habitrpg/blob/develop/public/js/services/notificationServices.js#L25

    function coins(money) {
      var absolute, gold, silver;
      absolute = Math.abs(money);
      gold = Math.floor(absolute);
      silver = Math.floor((absolute - gold) * 100);
      if (gold && silver > 0) {
        return "" + gold + " <span class='notification-icon shop_gold'></span> " + silver + " <span class='notification-icon shop_silver'></span>";

      } else if (gold > 0) {
        return "" + gold + " <span class='notification-icon shop_gold'></span>";
      } else if (silver > 0) {
        return "" + silver + " <span class='notification-icon shop_silver'></span>";
      }
    };
Alys commented 10 years ago

Maybe User.user._tmp.streakBonus isn't being cleared under some circumstances?? Although buying gear immediately after ticking off a Daily with a streak didn't produce this bug in the half-dozen tests I just did.

ShilohT commented 10 years ago

I just experienced this again with Spooky Sparkles. It claimed to be subtracting 15 gold, 20 silver, but again, was only taking the proper amount. It did not fix itself on refresh/sync, but it was fixed after checking off another task.

My sequence of events was: checked off a task with a 56->57 streak, cast Backstab on that task (which crit and gained me a level), bought a main hand Hook Sword (did not notice if this purchase bugged or not), checked off another task with a 11->12 streak (triggering the level up), allocated my new stat point to INT, read new messages in one of my guilds, bought some spooky sparkles and noticed the bug, checked off a task, bought spooky sparkles with correct display.

Alys commented 9 years ago

From @peregra in https://github.com/HabitRPG/habitrpg/issues/5883 :

When I purchase a reward (Enchanted Armoire, health potion) the correct amount of gold is pulled from my account, but the popup notification reports an inaccurate price.

For the Enchanted Armoire the popup shows that I am charged 103 gold 42 silver. The rewards column price shows a cost of 100 gold as expected. I have verified that only 100 gold is pulled from my account.

For the health potion the popup shows that I am charged 28 gold 42 silver. The rewards column price shows a cost of 25 gold as expected. I have verified that only 25 gold is pulled from my account.

So while I am not actually being charged extra, the notification is inaccurate.

Alys commented 8 years ago

Habitica's code has recently undergone large changes, which means that the code that caused these bugs probably does not exist any more. I'm closing this, but if you notice the same problem happening again, please open a new issue.