Sign In Register

How can we help you today?

Start a new topic

Saving and Loading Data - Player Inventory and Item Management?

I am making a card game like Clash Royal.

Applying the server for the first time is not easy. 

In the tutorial, i've seen how to create a list of items, as well as creating inventory for the player and adding items.

But how do I change the properties of an item that the player has?

For example, in my game, if a user collects 5 cards of A, A level 1 is raised.

How should the player have this information?

When creating a card list, do I need to create an item that displays the number of cards and level in the card's properties?

For example, should I make it like this?


   shortCode :”A_1”






If so, how can the player later change the player's information when the level changes by collecting 5 "A_1" cards?

1 Comment

 Hey There,

So when you save a card to the player's inventory collection you should be able to reference it by the playerID and card shortCode. So you can use the runtime.update method something like this...

Spark.runtimeCollection("playerCards").update({ "playerId" : playerId, "shortCode" : "A" }, { $set : { "lv" : 1  } });

So if your level was "A" before, you can find the card in your player's inventory and use the $set to set a single field on it to whatever you want.

Does that help?

Login to post a comment