Design/Pattern/Architecture help needed
I'm developing a game.
In that game every user have a lot of data stored in database on the server. Such as "Gold Currency", "Ruby Currency", "Unlocked Avatars", "Quests Progress", "Rank", "Level", "Collectable Towers Level and Amount" etc.
There is ingame shop, for example. In which you can buy things like some amount of collectable towers in exchange for ingame currency.
Every action (such as buying something from shop) is done via REST request to backend server. And in order to synchronize data between client and backend, we create response models for each request, that would contain every possible data that could've changed during that request and apply the deltas.
Pseudocode example of button in the ingame shop:
As seen in the example, this code assumes, that the only thing you can buy in shop is tower and shows the tower acquired animation itself, which is not something I'm ok with. Additionally, it also assumes that we spent some currency at the process. By the way,
So the problems with this:
In that game every user have a lot of data stored in database on the server. Such as "Gold Currency", "Ruby Currency", "Unlocked Avatars", "Quests Progress", "Rank", "Level", "Collectable Towers Level and Amount" etc.
There is ingame shop, for example. In which you can buy things like some amount of collectable towers in exchange for ingame currency.
Every action (such as buying something from shop) is done via REST request to backend server. And in order to synchronize data between client and backend, we create response models for each request, that would contain every possible data that could've changed during that request and apply the deltas.
Pseudocode example of button in the ingame shop:
As seen in the example, this code assumes, that the only thing you can buy in shop is tower and shows the tower acquired animation itself, which is not something I'm ok with. Additionally, it also assumes that we spent some currency at the process. By the way,
response.currencyDelta in the example is something likeSo the problems with this:
- OnClick button code triggers "tower acquired animation" itself
- We can only use
as price for buying in shop. What if I want to take something else from the player that is not consideredCurrency
type or not to take anything at allCurrency - We can only buy tower. And I would need to add more code here and in response model to support any other type of item sold in shop