question

dzone avatar image
dzone asked

Unique\Random Shop Inventory

Is there a way to mimic the refresh feature found in various (mostly) mobile games that randomizes the items available to the player in the shop when called, while using PlayFab's Shops?

10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

Sure, there are two main ways I would recommend, depending on your requirements.

1. If the store is randomized at certain points (once a day, etc.) for all players, and all players should see the same set of items, you could create a process that you run in a local tool as a cron job (or similar) which replaces the store at that time. Note that players who are in the midst of a purchase could get an error return from their purchase flow due to the pricing they're trying to use for the item suddenly not being valid anymore, so it would be important to manage that case with clear messaging in your client.

2. If the idea is that it's a randomized list of items for an individual player, you could use Cloud Script to return a randomized list of items from the catalog based on any logic you need. You could optionally save it to the player's User Read Only Data, for later re-use without re-randomization. With this model, you'd need to make one additional choice: Since all prices listed in the catalog and stores are valid for all users currently, you would either need to be okay with hacked clients being able to make purchases using any price you've entered, or else not put any prices int the catalog/stores and use the grant item and subtract virtual currency Server API calls to accomplish the transactions.

10 |1200

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

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.