question

wave-bitcn avatar image
wave-bitcn asked

Purchase item using two kind Virtual Currency

There is a item in my game, it needs gold and crystal to purchase it, how to do it?

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

Prices in the catalog and its stores are "or" pricing - so specifying a price in more than one virtual currency is saying that the item can be purchase for X of VC 1 or Y of VC 2. This is a common model for free-to-play games, as they have both "grind" and "hard" currencies. To purchase an item for X of VC 1 plus Y of VC 2, you would need to use Cloud Script for now. The same applies to purchasing items with other items. In general, the flow would be:

1. Check that the player has what it takes to make the purchase,

2. Grant the item(s)

3. Subtract or revoke the VCs/item(s).

That way, in the rare instance where the script fails before the end, you won't have a case where you subtract the VC/item(s) before granting the purchase (greatly preferable to the opposite).

We do plan to add a "crafting/alchemy" type system in future, in which you will be able to define one or more items/VCs as both inputs and outputs to "recipes", which you could then use as a more complex purchasing system. This hasn't been scheduled as yet though, so the Cloud Script would be the way to go for the moment.

7 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.

wave-bitcn avatar image wave-bitcn commented ·

1. Check that the player has what it takes to make the purchase,

2. Grant the item(s)

3. Subtract or revoke the VCs/item(s).

This is a database transaction, right? I am not good at it.

0 Likes 0 ·
brendan avatar image brendan wave-bitcn commented ·
0 Likes 0 ·
wave-bitcn avatar image wave-bitcn brendan commented ·

After a quick searching, it seems that the server API does not support transaction like SQL.I don't know whether the Cloud Script is secure to do this.

0 Likes 0 ·
Show more comments
Show more comments

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.