question

Gustavo Mesel Lobo Seixas avatar image
Gustavo Mesel Lobo Seixas asked

How to implement a Rotating Shop?

Hello. What would be the best approach to implement a rotating shop? What I want to do is, having all the items defined in the Catalog but only a few of them are in a particular Store at each period of time (and only items in this Store are purchasable from the game).

Manually, this is easy to do, as I can just edit the Store and include the items I want, but what if I want to automate the process? I thought about creating a ScheduledTask that run at each interval (e.g. weekly) and changed the items in the Store, but CloudScript doesn't have access to the Admin API, which is needed to edit store items.

I wonder if using Azure Functions would be the answer, since it has access to all APIs (running AzureFunction instead of a CloudScript), but I'm looking for an alternative without incurring the extra cost of Azure...

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

·
Rick Chen avatar image
Rick Chen answered

Currently there is no Server API to update the store, and indeed, the CloudScript cannot access the Admin API. It would be better to AzureFunction to Update the store.

A workaround without using AzureFunction could be:

  1. create multiple stores for each period of time you define.
  2. write a CloudScript that updates the current store id in title data using SetTitleData.
  3. write another CloudScript for client that retrieves the store items via GetStoreItems API with the current store id in title data via GetTitleData API.
  4. use scheduled Task to run the CloudScript in step 2 to change the current store id in different time period.

Or if you would like to have a Server API that can update the store, you can post a thread in Feature Request forum.

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.