question

joerg-miethe avatar image
joerg-miethe asked

How to change inGameCurrency

Hello everyone,

first thanx for Your great Tools and great support :-)

Last game I've only used Your leaderboards, so everything else is quite new to me and in the past I've developed board- and cardgames expect me to be a bad coder :-).

Id: 36FDD Language: JavaScript

Background === if(inHurry){skip}

/*

I'm develooping a game idle game, in which you've got a farm and grow food and breed animals.

For better understanding think of racing horses. Grow better food and your horses get faster. Compete in races to gather points. Reproduce with other fast horses to get even faster children...

There's although a quite complex economy involved. I've got 5 nation with 5 ingame currency to make trading and expansion more of a challenge. Everthing works well untill I installed PlayFab :-)

*/

My code works if I allow cient side adding and subtracting currency, but the more I get used to your system, so less I will.

/*

I've got different prizes for items, depending on how smart our horse is. So I've Adapt my code so you purchase for a minimum prize plus buy some extra selfconsuming item if Your horse is dump. So I include Your system I got a new problem ...

*/

I'll grant a new player 50.000 Coins by PlayFab. But if the player wants to start in the desert he needs 50.000 Peppercoins and if it's the Icepol he needs 50.000 IceCoins...

So i grant the Player 50.000 GlobalCoins and allow him client side to change to actuell currency. I've looked around quite a lot but didn't find out how to do this :-(

Unimportend Question:

/*

I've desiged the game for easy storage and light data use... My Farms consist of an array of about a 1.000 integer including:

- Landscape (You can dig, tunnel, fertilizeand so on

- Plants ( knowing wich bee visited the flowers (breeding)

- Farmhouse (no Idle Game without construction)

*/

is there any possible to store a Json in a couple like:

{ Farm : JSON1,

Hive : JSON2,

Plant : JSON3 }

In my uneducated eyes a Json is at least only a formatted String...

Thax again

Jörg

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

·
Citrus Yan avatar image
Citrus Yan answered

>>So i grant the Player 50.000 GlobalCoins and allow him client side to change to…

You can use CloudScript for this, it allows client code to request execution of any custom server-side logic you implement. In your case, the server logic would be:

  1. Verify the client’s request is valid or not, for instance, whether he/she is a new player or not, the GlobalCoin amount is sufficient or not.
  2. If the request is valid, proceed, else return corresponding error message back to client-side.
  3. Add corresponding IceCoin/PepperCoin for the player using the server AddUserVirtualCurrency API and subtract the GlobalCoins using the server SubtractUserVirtualCurrency API.

Please read the docs on CloudScript to learn more about how to implement the feature.

>>is there any possible to store a Json in a couple like..

Sure, you can store JSON like this.

10 |1200

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

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.