HabitRPG / habitica

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

Quest Scrolls acting up: negative number of quest scrolls #2592

Closed Eiron closed 5 years ago

Eiron commented 10 years ago

I had what seemed to be "-1 scrolls" (actually one The Fiery Gryphon scroll), until I spent 4 gems each on Trapper Santa and Find the Cub. Now I have "1 scroll", which is actually one Trapper Santa and The Fiery Gryphon from before. The Find the Cub scroll never materialised. Any idea what is up?

edit by Alys 2019-03-23:

For the current status of this bug, see this comment and any comments after it: https://github.com/HabitRPG/habitica/issues/2592#issuecomment-475829848

Mihakuu commented 10 years ago

but I still dont receive a scroll on the production side. Gems transferred, no scroll.

deilann commented 10 years ago

Yes, you'll need to purchase another deer scroll. You had -1 deer scrolls, so now you have 0 deer scrolls.

On Tue, Apr 22, 2014 at 7:40 AM, Mihakuu notifications@github.com wrote:

but I still dont receive a scroll on the production side. Gems transferred, no scroll.

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-41047707 .

Mihakuu commented 10 years ago

Thats very odd @deilann but yes that worked thank you

deilann commented 10 years ago

The issue has something to do with stacked quest scrolls and the system taking away too many, reducing it to negative numbers. Which then means you have to buy multiple scrolls to get back up above 0 and... have them.

On Tue, Apr 22, 2014 at 7:42 AM, Mihakuu notifications@github.com wrote:

Thats very odd @deilann https://github.com/deilann but yes that worked thank you

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-41047995 .

Mihakuu commented 10 years ago

But I only had one of both of those scrolls

deilann commented 10 years ago

That is good to know. So sometimes the reduce scroll number operation gets duplicated even when there's only one scroll.

On Tue, Apr 22, 2014 at 7:45 AM, Mihakuu notifications@github.com wrote:

But I only had one of both of those scrolls

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-41048403 .

ghost commented 10 years ago

May I just shoot a suggestion about the workaround? I gave up programming in school when we had delphi 5 as a major framework and not mastered the skill. So I'm more than out-of-date in the question and simply can't analyze the code myself. Please ignore me if I say it wrong, but the users keep facing the issue, and alongside with searching for the cause can a quick fix be introduced? Something like a check: when a user buys an item with gems, see if "the-current-count-of this-item-possessed" is <0 make it 1, else just increase by one.

deilann commented 10 years ago

Sphinx, I actually suggested something similar a bit ago (if quantity < 0, quantity = 0, then as normal), but I wanted to make sure @lefnire's okay with a quick-fix that doesn't solve the problem.

On Thu, May 1, 2014 at 12:24 AM, Sphinx notifications@github.com wrote:

May I just shoot a suggestion about the workaround? I gave up programming in school when we had delphi 5 as a major framework and not mastered the skill. So I'm more than out-of-date in the question and simply can't analyze the code myself. Please ignore me if I say it wrong, but the users keep facing the issue, and alongside with searching for the cause can a quick fix be introduced? Something like a check: when a user buys an item with gems, see if "the-current-count-of this-item-possessed" is <0 make it 1, else just increase by one.

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-41887205 .

ghost commented 10 years ago

deilann, well I see. Quick fixes are meant to be temporary, but when there are lots of them, the code can really become such a mess... I wouldn't even think about something of the kind if only if it wasn't about "real money" and often happening - and at the same time seemingly easy to be patched (meaning a patch is something of one line, localized in the code and easily withdrawn when the SOLUTION is found).

deilann commented 10 years ago

@GitHubSphinx Actually, it only patches the issue sometimes. There's still the issue of when people have a stack of scrolls and they lose them.

deilann commented 10 years ago

I think I've figured this one out. I believe it's related to https://github.com/HabitRPG/habitrpg/issues/2657 -- whenever the system restarts the quest, it takes another scroll from the quest leader. Two things should fix it:

1) Remove the scroll from the quest leader upon invitation, not upon the quest starting. 2) Put in an error check for purchases -- if scroll quantity < 0, set it to 0 3) A possible fix for #2657 would also alleviate this -- add in error checking past invititation to check to see if a quest is active before starting a quest.

I believe all three of these together would solve this issue.

Any thoughts?

deilann commented 10 years ago

The only problem is I don't know what's triggering the restart quest bit, so I have no way of testing this. QA Master @SabreCat thoughts on that?

secretstaircase commented 10 years ago

I just had the spend gems / don't receive quest scroll problem, also on the Gryphon quest. Could I be refunded the gems, please? User ID: 471f47bc-52cc-4cbf-904c-6d4909e43866

deilann commented 10 years ago

UUID?

On Mon, May 5, 2014 at 8:42 AM, secretstaircase notifications@github.comwrote:

I just had the spend gems / don't receive quest scroll problem, also on the Gryphon quest. Could I be refunded the gems, please?

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42201821 .

secretstaircase commented 10 years ago

Huh, I thought I edited to add that. User ID: 471f47bc-52cc-4cbf-904c-6d4909e43866

deilann commented 10 years ago

Editing doesn't hit my inbox, sorry.

On Mon, May 5, 2014 at 12:34 PM, secretstaircase notifications@github.comwrote:

Huh, I thought I edited to add that. User ID: 471f47bc-52cc-4cbf-904c-6d4909e43866

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42228577 .

deilann commented 10 years ago

Refunded!

On Mon, May 5, 2014 at 12:34 PM, Ryan yandoryn@gmail.com wrote:

Editing doesn't hit my inbox, sorry.

On Mon, May 5, 2014 at 12:34 PM, secretstaircase <notifications@github.com

wrote:

Huh, I thought I edited to add that. User ID: 471f47bc-52cc-4cbf-904c-6d4909e43866

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42228577 .

Yuubou commented 10 years ago

@deilann I have been testing this a bit, and noted the following: My quest scroll count & displayed scroll icons decreased by one upon party invitation to the quest. My quest scroll count also decreased by one after defeating the quest.

This was true for both The Fiery Gryphon and Free Yourself of the Dragon's Influence.

So, I know I should be -1 The Fiery Gryphon & -1 Free Yourself of the Dragon's Influence. I tried buying a different scroll with my gems and was able to purchase it. Then I tried buying a Fiery Gryphon & it again took my gems and upped the scroll count but deposited no scroll. I haven't noticed scroll counts decreasing when other party members start the quest.

This all leads me to believe it has to do with the mechanisms involved with the fact that if you abandon a quest, you can use the scroll again - my guess is there's a line of code that if you defeat the quest, the scroll is taken (rather than telling it to return a scroll if the quest is abandoned). But there is probably a line somewhere if you re-start a quest, a scroll is taken.

Any way, my UUID is 7846c2cc-400d-4aff-b1ad-40ee3d68305c if you don't mind refunding 8 gems.

Thanks for looking into this!

lefnire commented 10 years ago

Note, @deilann's fix isn't live yet. We won't deploy it until we've solved the i18n fixes on beta

deilann commented 10 years ago

@Yuubou Not only is the fix not live, I am almost positive this is not what's going on, simply because if that were the case, it would always remove an extra scroll. But it only does sometimes.

The scroll isn't removed upon invitation; it's removed upon quest start. And aborting a quest refunds a scroll, I am almost positive because players often have to refresh to have it back in their inventory after losing it.

What probably happened is you had an extra questStart trigger -- we'll find out if that seems to be the case when my fix goes live.

Anyway, gems refunded.

On Mon, May 12, 2014 at 9:45 AM, Tyler Renelle notifications@github.comwrote:

Note, @deilann https://github.com/deilann's fix isn't live yet. We won't deploy it until we've solved the i18n fixes on beta

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42856739 .

ghost commented 10 years ago

I bought a Hedgehog Quest scroll the other night, and it took my gems, but gave me know scroll. I have noticed for a few days that I also had negative numbers of quest scrolls, but I didn't think anything of it. Could someone give me my gems back? And should we not try to buy scrolls until this is fixed? Or just come back here if it happens again? Thanks for all the hard work y'all do.

My UIUD is a92762ce-f8bc-411a-9452-245acccac9b9

deilann commented 10 years ago

Just come back here if it happens again. :) It's fixable by buying the scrolls.

Gems refunded!

On Mon, May 12, 2014 at 10:18 PM, cinnamingirl notifications@github.comwrote:

I bought a Hedgehog Quest scroll the other night, and it took my gems, but gave me know scroll. I have noticed for a few days that I also had negative numbers of quest scrolls, but I didn't think anything of it. Could someone give me my gems back? And should we not try to buy scrolls until this is fixed? Or just come back here if it happens again? Thanks for all the hard work y'all do.

My UIUD is a92762ce-f8bc-411a-9452-245acccac9b9

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42918036 .

ghost commented 10 years ago

Thanks so much. ^_^

On Tue, May 13, 2014 at 1:22 AM, deilann notifications@github.com wrote:

Just come back here if it happens again. :) It's fixable by buying the scrolls.

Gems refunded!

On Mon, May 12, 2014 at 10:18 PM, cinnamingirl notifications@github.comwrote:

I bought a Hedgehog Quest scroll the other night, and it took my gems, but gave me know scroll. I have noticed for a few days that I also had negative numbers of quest scrolls, but I didn't think anything of it. Could someone give me my gems back? And should we not try to buy scrolls until this is fixed? Or just come back here if it happens again? Thanks for all the hard work y'all do.

My UIUD is a92762ce-f8bc-411a-9452-245acccac9b9

— Reply to this email directly or view it on GitHub< https://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42918036> .

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42918237 .

Siobhain


Siobhain Rivera siobhain.rivera@gmail.com MLS Candidate, Digital Libraries Indiana University

Website: www.siobhain.rivera.com Twitter: @SioTheLibrarian https://twitter.com/SioTheLibrarian Tumblr: www.siothelibrarian.tumblr.com

chornsby commented 10 years ago

It happened again. >.< Shortly after starting the hedgehog quest one of my party members was sent the quest invitation again and accepted it. This lead to the boss going back to full health and my quest scrolls counter saying 0 despite having the vice scroll in my inventory.

User ID: db393d59-b0cc-41ee-998d-e1b7888a6eea

From reading the thread, this might help locate the problem. If the scroll is removed on quest start but we've had a spurious restart without abandoning the quest then that could explain why there are now -1 hedgehog scrolls in my inventory?

deilann commented 10 years ago

Yes, I believe that is the issue and there is a fix on the way. It will be pushed to the site once i18n stuff is cleared up.

Something is causing questStart to run again without the quest leader to run another invite. I don't know what it is, but I've added a clause into questStart to check and make sure a quest isn't running before it does anything. I'm hoping this fixes the problem, even if we're not positive why questStart is being retriggered -- or in your case, why your party member was sent another quest invitation and then triggered questStart.

I've refunded you 4 gems. :) Repurchasing the Hedgebeast scroll should patch you up.

On Tue, May 13, 2014 at 2:04 AM, Charlie Hornsby notifications@github.comwrote:

It happened again. >.< Shortly after starting the hedgehog quest one of my party members was sent the quest invitation again and accepted it. This lead to the boss going back to full health and my quest scrolls counter saying 0 despite having the vice scroll in my inventory.

User ID: db393d59-b0cc-41ee-998d-e1b7888a6eea

From reading the thread, this might help locate the problem. If the scroll is removed on quest start but we've had a spurious restart without abandoning the quest then that could explain why there are now -1 hedgehog scrolls in my inventory?

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-42932550 .

chornsby commented 10 years ago

Thanks a lot! Sounds like a very sensible fix -- hopefully it'll solve the bug!

Memry commented 10 years ago

I had the same problem with the purchase. Tried to purchase Spirit of Spring and did not receive it. Thanks, deilann for steering me here!

My user ID is e495bd8b-f2f1-48e8-8f5f-9a52710999cf

deilann commented 10 years ago

Np I'll refund you ASAP On May 13, 2014 9:27 PM, "Memry" notifications@github.com wrote:

I had the same problem with the purchase. Tried to purchase Spirit of Spring and did not receive it. Thanks, deilann for steering me here!

My user ID is e495bd8b-f2f1-48e8-8f5f-9a52710999cf

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-43041004 .

deilann commented 10 years ago

Refunded! Lemme know if repurchasing doesn't patch you up. :)

On Tue, May 13, 2014 at 9:37 PM, Ryan yandoryn@gmail.com wrote:

Np I'll refund you ASAP On May 13, 2014 9:27 PM, "Memry" notifications@github.com wrote:

I had the same problem with the purchase. Tried to purchase Spirit of Spring and did not receive it. Thanks, deilann for steering me here!

My user ID is e495bd8b-f2f1-48e8-8f5f-9a52710999cf

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-43041004 .

Eiron commented 10 years ago

I am now missing the Trapper Santa and the Find the Cub quest scrolls (which have disappeared without my using them), and have "(5)" scrolls which are actually 6, as I have two of the Egg Hunt.

deilann commented 10 years ago

When you say disappeared without using them do you mean you never once activated a Trapper Santa or Find the Cub scroll? That does not fit the pattern at all... I don't think anyone has ever reported losing a scroll they've never used. On May 14, 2014 7:39 AM, "Eiron Page" notifications@github.com wrote:

I am now missing the Trapper Santa and the Find the Cub quest scrolls (which have disappeared without my using them), and have "(5)" scrolls which are actually 6, as I have two of the Egg Hunt.

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/2592#issuecomment-43088823 .

deilann commented 10 years ago

This https://github.com/HabitRPG/habitrpg-shared/pull/204 and this https://github.com/HabitRPG/habitrpg/commit/9a4e8d38b46d02475ca97121b5d77a777f8d1f92 should fix this and patch it over nice self healing for already negative scroll amounts being repurchased.

Please lemme know gaiz, if you continue to have this problem.

Eiron commented 10 years ago

My mistake. Trapper Santa is there. But yes, the Find the Cub scroll remains dead and gone (both were exhausted as one). No option exists to repurchase that one as yet.

deilann commented 10 years ago

Yeah, I can't fix that. But just to confirm: you are confirming that you had 2 Find the Cub scrolls, you activated one, and it nommed 2? Because that's what this bug is thought to be doing.

@lefnire can you refund Eiron? UUID: 4182cdea-64db-4db4-9713-dc587d86c662 needs 1 Find the Cub scroll

Bujungo commented 10 years ago

I finished the first part of the Vice quest and attempted to start the second and now the scroll is gone and I'm not in the quest.

Alys commented 5 years ago

I'm reopening this because I suspect the bug happened to another player (NookaBean, 77468ba2-c08a-4c12-9cb8-70c6a7ee437c) based on a recent post in the Report a Bug guild in which they bought a scroll but did not receive it. I've confirmed that the workaround for the bug (https://github.com/HabitRPG/habitica/pull/10953) works if you're buying a quest scroll with Gold but not with Gems. The code change from that PR was put into website/common/script/ops/buy/buyQuest.js and it would need to be copied to website/common/script/ops/buy/buyQuestGem.js. https://github.com/HabitRPG/habitica/blob/a2261e35919a0396d2e74ea70f209b68ebc004c6/website/common/script/ops/buy/buyQuest.js#L68-L69

However it might be better to try to apply the workaround to the super class's purchase() function (see code snippet below) so that it's run for every kind of purchase, although that would be tricky since each subclass handles the decision about where in the user document the current number of owned items can be found. Perhaps there could be a new inheritable function that could do the checking just before executeChanges() is run? Possibly it could be optional so that it wouldn't have to be added to all purchase/item types yet (i.e., the super class would not throw an error if the function wasn't implemented).

https://github.com/HabitRPG/habitica/blob/a2261e35919a0396d2e74ea70f209b68ebc004c6/website/common/script/ops/buy/abstractBuyOperation.js#L91-L98

It might also be worth renaming website/common/script/ops/buy/buyQuest.js to website/common/script/ops/buy/buyQuestGold.js to help with future additions since it's easy to forget that there's two ways to buy quests.

FYI for anyone curious, here's one example of how the negative quest scrolls bug can occur: https://github.com/HabitRPG/habitica/issues/10974 Ideally all causes would be fixed to remove the bug entirely, but that's a lot more work than adding the workaround described above.

Alys commented 5 years ago

We've had another report of a failed quest scroll purchase that was probably due to this.

I've confirmed the bug still exists -- I gave myself -1 of a gem-purchasable scroll, then bought the scroll, and ended up with 0 scrolls, so the fix that was done for gold-purchasable quests definitely still needs to be applied to gem quests. I'm raising this to a high priority since it's taking gems from players.

cheng-shiqi commented 5 years ago

@Alys Can I take this one? And thanks a lot for the information and suggestions above, giving huge help in looking into such a long issue!

Alys commented 5 years ago

@cheng-shiqi Yes, please do, thank you! Post here if you have questions.

Good to hear my comments helped, thanks. :)

cheng-shiqi commented 5 years ago

@Alys Just submmitted the PR for this issue, sorry for the delay. I copied the resetting code in #10953 to website/common/script/ops/buy/buyQuestGem.js and renamed website/common/script/ops/buy/buyQuest.js, as you suggested. But I didn't extract the workaround in #10953 as a new function and pull it up to the super class, cause I haven't figured out a proper solution yet.