HabitRPG / habitica

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

pinned off-season Magic Hatching Potions, Greeting Cards, Quest Bundles should not appear to be purchasable #9933

Open Alys opened 6 years ago

Alys commented 6 years ago

If you pin a Magic Hatching Potion to your Rewards list, when that potion is no longer available for purchase, the pinned item acts as if you can still purchase it. You can click on it, select the number to be bought, and then confirm the purchase. You see a message saying that you've bought the Potion(s).

However the Potions are not actually added to your Inventory and the Gems are not subtracted. This part is correct (outside the approved time for the Potions, you are not meant to be able to buy them).

The desired behaviour is something like one of these:

That behaviour should be automatic as soon as the approved time for the Potion has ended so the code should read that date from Habitica's config for the Potion.

Regardless of how this fix is implemented, the user should always be able to unpin the item when they choose to (or leave it pinned permanently if they prefer that).

Tressley commented 5 years ago

The user should still be able to view the details modal of the item, but the Buy Now button should be disabled with a small bit of text that the item is unavailable. Here's a screenshot:

image

Alys commented 5 years ago

This bug also occurs for pinned seasonal greeting cards as reported by @ravenlune (9272ab2c-4b66-4b74-aebd-799725885d1c):

"I believe the Valentine's Day event is over now, right? The Valentine's card is still pinned to my Rewards... on the website, I was able to successfully send it to a party member."

The fix should be the same as Tressley describes above. I'm about to edit this issue's title to include cards

somersjw commented 4 years ago

Hi, I'd like to try my hand at investigating this issue

Alys commented 4 years ago

@somersjw I'm sorry it's taken us so long to reply! I've marked this as in progress for you but if you've found something else to do in the meantime, tell us and we'll set it back to help wanted.

If you have any questions or run into trouble, post here and we'll try to reply faster!

shanaqui commented 4 years ago

@somersjw Hi there! Are you still interested in working on this? I'll mark this as help wanted again in about a week if we don't hear back. :)

shanaqui commented 4 years ago

@somersjw I'm marking this as help wanted again, but if you'd like to pick it back up, please just let us know!

qrdean commented 4 years ago

I can take a look at this.

Are seasonal items the only items that have an 'event' object?

Thanks.

Alys commented 4 years ago

@qrdean Thanks! I've marked this as in progress for you.

Are seasonal items the only items that have an 'event' object?

Not exactly. A git grep through the content for "event" (with a couple of normal greps to narrow it down to just content data) shows that there's a few others:

git grep event | grep content | grep -v /locales/ website/common/script/content/gear/sets/special/index.js:151: event: EVENTS.birthday, website/common/script/content/gear/sets/special/index.js:443: event: EVENTS.gaymerx, website/common/script/content/gear/sets/special/index.js:1607: event: EVENTS.nye, website/common/script/content/gear/sets/special/index.js:1946: event: EVENTS.gaymerx,

If that causes any problems for the solution you develop and you're not sure how to deal with it, post here (also post if you have any other questions).

qrdean commented 4 years ago

Thanks for that! Yeah I think that throws my original idea of just checking the event out the window.

I'm looking at exposing the value returned from the canBuy function that appears on some item structures. This will allow the front end to use the canBuy function that seasonal items and specialty items already have to tell us if that item is purchasable. The front end can then respond with a disabled button and text that tells the user that the item isn't available.

Is there a reason some items do not have this function on their structure? Is it assumed those items can be bought? Also, it looks like the default return value for canBuy() on Gear is false. So for all gear that does not have the canBuy function I would add it and allow the canOwn() function to verify it.

paglias commented 4 years ago

@Alys just to be sure, this is a client side only issue, right?

Alys commented 4 years ago

I'm not sure. I didn't get a chance to test through the API today but I'll try to tomorrow!

Alys commented 4 years ago

My testing will have to slip to tomorrow, sorry. I have an early start at work so I need to get to bed early. I'll have an early finish though so I'll definitely have time to test this bug with the API tomorrow.

Alys commented 4 years ago

@paglias I guess you can say it happens with the API as well, although that's not as significant a problem.

Steps I took to test the API's behaviour:

  1. Use a database command to add an unavailable potion to my pinnedItems array: { "path": "hatchingPotions.Fairy", "type": "hatchingPotions" }
  2. Pin an available potion (Golden).
  3. Confirm in my Rewards column that both are pinned and look purchasable.
  4. Use the /api/v3/user/in-app-rewards GET route to examine my pinned items.
  5. Observe that the returned data doesn't indicate that the Fairy potion can't be bought. Its data is the same as for the Golden potion, apart from cost and name/description. In particular, "locked":false implies that it can be bought.
    {"key":"Golden","text":"Golden Potion","notes":"Pour this on an egg, and it will hatch as a Golden pet.","class":"Pet_HatchingPotion_Golden","value":5,"locked":false,"currency":"gems","purchaseType":"hatchingPotions","path":"hatchingPotions.Golden","pinType":"hatchingPotions","isSuggested":false,"pinned":true},
    {"key":"Fairy", "text":"Fairy Potion", "notes":"Pour this on an egg, and it will hatch as a Fairy pet.", "class":"Pet_HatchingPotion_Fairy", "value":2,"locked":false,"currency":"gems","purchaseType":"hatchingPotions","path":"hatchingPotions.Fairy", "pinType":"hatchingPotions","isSuggested":false,"pinned":true},

I.e., if you use the API's route to show you your pinned items, it looks as if you can buy the off-season Hatching Potion, just as it does on the website. I don't know if we want to fix that? I guess we'd need to have a new parameter in the data for off-season potions to indicate that they can't be bought. Unless we can use the locked value for that.

paglias commented 4 years ago

I think having some sort of data in the API showing if an item can be bought or not would be very useful especially for the mobile apps and also to avoid having to calculate the availability on the various client sides. Not sure if locked is the best option here or would be confusing, we seem to have several properties that could be used including canBuy

shanaqui commented 4 years ago

@qrdean Hi! Are you still working on this issue? If not, or if we don't hear from you within seven days, I'll mark this as help wanted again. :)

shanaqui commented 4 years ago

I've set this back to "help wanted" since we didn't get a reply!

veeeeeee commented 4 years ago

Related to #9899 and likely will require close handling.

SabreCat commented 3 years ago

I think this has been addressed with recent Gala event code overhauls. @Alys does something remain to be addressed re this ticket?

Alys commented 3 years ago

I've just tested by pinning a Polka Dot Potion using a database command to update my pinnedItems array. It does look purchasable. Below are screenshots from my Rewards column.

image

image

image

image

Alys commented 3 years ago

Also occurs for pinned Quest Bundles so I've added them to the title.

(The countdown is wrong too but that's reported at https://github.com/HabitRPG/habitica/issues/13318)

image