Idea

Kevin avatar image
Kevin suggested

Economy v2 Add/Subtract operations should optionally return new balance

In Economy V2, when we submit a request to Add / Subtract Inventory Items, we get back a response containing transaction IDs. If we want to display the player's new balance in the game, we then need to submit a Get Inventory Items request.

It would be great if the Add / Subtract requests could optionally return the new balance of the given item without having to send a separate request. This could be controlled via a boolean flag on the request.

apisIn-Game Economy
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 Comment

·
kylemc@microsoft.com avatar image
kylemc@microsoft.com commented

We've talked about this idea a lot in the past. There are good reasons to do it and to not do it. I do understand the simplicity is nice, though. What do you think of the solution of calling GetInventoryItems with Filter set to "id eq '123' and stackid eq 'abc'"?

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

Kevin avatar image Kevin commented ·

@kylemc@microsoft.com It works but it's a bit inefficient having to send a second request to get the result of the first request.

With a boolean flag in the request, we could optionally specify that we want to get the balance back and avoid having to send a second request. If we don't need the new balance, we could set the flag to false to save a little bit of bandwidth

0 Likes 0 ·
kylemc@microsoft.com avatar image kylemc@microsoft.com Kevin commented ·

Could you explain the scenario a bit more? If you have 10 gold and then add 3 gold, are you expecting us to return "You have 13 gold"? Don't you already that information on the client?

0 Likes 0 ·
Kevin avatar image Kevin kylemc@microsoft.com commented ·

@kylemc@microsoft.com If it's a cross-platform game where the player can be logged in to the same account on multiple devices, is it safe to assume that the balance that the client is aware of is up to date? For example, Alice is logged in on her phone and tablet, and has 100 gold. She plays a level on her tablet and earns 10 gold, giving her a total of 110. Then she plays a level on her phone and earns 5 gold. She now has 115, but if the phone didn't get updated when she played on the tablet, it will show a balance of 105. Not a common scenario, but still worth considering.

The balance on the client may also be out of date if the player has received gold from a scheduled function or another player.

When I build a custom RESTful API, I always have API functions that change a balance return the new balance. This makes it easier to ensure data stays fresh without having to resort to polling.

0 Likes 0 ·
Show more comments
Kevin avatar image Kevin commented ·

Another disadvantage of having to send a separate request to get the new balance is that we then need additional client/server logic and error handling.

0 Likes 0 ·

Write a Comment

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

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.