Hello,
I've recently discovered PlayFab and am super excited by all the features available! In regards to using CloudScripts to run game logic, I had a question about best/ideal practices.
Let's say the player wants to upgrade their weapon. I imagine I would have a few CloudScript functions: initiateUpgrade, canUpgrade, payForUpgrade, etc. When the user clicks the "Upgrade" button, I run initiateUpgrade, which deducts player items and currencies, changes the read-only data to account for the new weapon, etc. I could then return the new state of the data from the CloudScript and use it to drive UI on the client.
My questions:
1) When running logic like this, is it best to wait for the CloudScript to return and parse the return values in order to drive UI on the client? My concern is that if the player is buying or upgrading a lot of things, this introduces micro bursts of 1-2 seconds (however long the cloud call takes) after each action.
2) Is it better instead to fire off the CloudScript call, then reflect changes in the UI right away, and finally after the CloudScript returns, update the UI if the data differs. This seems most responsive, but then I would be duplicating some logic between the CloudScript and client.
Similarly, if I want to highlight buttons or show potential costs of an item in the UI, I would still need to do some logic on the client to see if the user could afford an upgrade, etc. The same logic I've written in the CloudScripts.
The best solution I've come up with so far would be to store even more read-only data for the player. For example, the item would have a kvp "canUpgrade : true" that is set in a CloudScript, and the UI would simply be driven by that. I wonder if this is taking the idea of a "thin client" too far? It also doesn't answer whether or not I should be waiting for the CloudScripts to return, or still operating on local data and updating it if it gets out of sync.
Any feedback is appreciated =)
- Joe