question

Matt avatar image
Matt asked

Store Items with Incremental Prices

I'd like my users to be able to purchase an item for the first time, and any time after that I'd like it to be upgraded. I'd also like the cost to go up with each upgrade. Is that type of functionality built in, is there a logical way to simulate that without making an entry for every upgraded version of an item?

To Clarify:

User pays 100 gold to buy a weapon for the first time.

User pays 500 gold to upgrade that weapon from level 1 to 2.

User pays 2000 gold to upgrade that weapon from level 2 to level 3.

...and so on

Thanks for the help!

-Matt

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

The simplest way would be to have the item be stackable, with the size of the stack determining the level. Using your pricing above, level 1 would be a stack of 1, level 2 would be a stack of 6 (1 purchase at 100 gold + 5 purchases at 100 gold), etc. You would then present it to the user as the simple "level 2 for 500 gold", and under the covers use StartPurchase to buy 5 of that stackable item (https://community.playfab.com/questions/5014/purchasing-many-items-at-once-with-virtual-currenc.html).

One thing to note: Right now, using this to purchase large stacks of a stackable item is somewhat slow. We're working on an optimization which will speed this up considerably. That work is scheduled to be complete in October, so for the moment, I would recommend limiting these purchase stacks to 20 or so (by your progression, only up to level 3). Once the update is complete, you'll be able to go with much larger quantities of a stackable item in the purchase call.

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt avatar image Matt commented ·

Thanks for the quick replay, as well as that stackable example. That's a clever way of using a single entry, I could certainly adjust my numbers to work in that metric. I don't expect to offer a large number of upgrades (prices I haven't balanced yet though). I'm not worried about performance until well after October, so this is a great start for me.

Thanks Brendan!

PS - New to PlayFab, absolutely love it so far.

0 Likes 0 ·
Alberto Gomez avatar image Alberto Gomez commented ·

I know this is an old thread, so @Brendan is this still the best way to achieve incremental prices?

What if for example my lvl 1 item costs 10 gold and I want my level 2 item to cost 11 gold?

0 Likes 0 ·
brendan avatar image brendan Alberto Gomez commented ·

We don't have any plan to add a calculated-on-the-fly cost for items in the near term, so yes, you would need to use Cloud Script to grant the item and subtract the VC, currently.

0 Likes 0 ·
Alberto Gomez avatar image Alberto Gomez brendan commented ·

any tips on how to do this with Cloudscript? I have no experience with js

0 Likes 0 ·
Show more comments
Matt avatar image
Matt answered

In case there's anyone else looking to do something similar, I think I came up with another approach.

I'll have the items the player can purchase (and upgrade) be stackable with a cost of 0 in the database. Then I'll have a bunch of entries in a store in the database that don't give the player anything but cost various increments of my currency. I can use the stack count to be the level 1-to-1 and when the player purchases, I can just purchase multiple items: 1 being another stack level of the item and the rest being the sum of the cost.

The only downside is that I need to keep the prices separate (in PlayerData).

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

Actually, there's a problem with this. Any item with no prices at all cannot be purchased by the PurchaseItem call, so I'm assuming you literally mean that you have a VC price defined in the item, with that price being 0. If so, any hacked client could easily send a call to purchase an unlimited number of that item.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.