Sign In Register

How can we help you today?

Start a new topic
Answered

Accept challenge with wager if don't have enough currency

Hi,

I am implementing a "send currency" system through challenges:

  1. a player wants to send currency to another player, it creates a challenge with the appropriate wager
  2. received player sees the challenge and accepts or refuse it
  3. if he accepts, he automatically win it and takes the wager
  4. if he refuse, currency may or may not return to the sender (TBD)

if a player doesn't have enough currency to accept the challenge, what is the best approach to follow?

  • withdraw the challenge and manually transfer the money
  • temporarily add the currency to the player, accept and win the chalenge, then take the temp back
  • (untested) I can set the wager to 0 and accept the challenge without paying, then win the other player's wager
  • I can actually accept the challenge when I don't have the money
  • there is a magic switch to to the point above
  • something else totally different


Best Answer

Hi Mauro


A challenge must have started and be running in order to be won.

You could set the wager to 0 and save the money transfer value in the challenges script data.

If the player accepts they win.


In the user message, ChallengeWonMessage cloud code credit the user the money

var money = Spark.getData().challenge.scriptData("moneyTransfer")

Spark.getPlayer().credit1(money);


In the user message ChallengeLostMessage cloud code take away the money from the user.

var money = Spark.getData().challenge.scriptData("moneyTransfer")

Spark.getPlayer().debit1(money);


Would this work for you?


Regards

Katie


Hi Mauro,


Glad to hear you can make it work. If you have any further questions just let us know.


Thanks,

Liam

that should work. I was hoping I could use wagers to automate this and have a more atomic transaction. (i'm already doing everything with cloud code, so I already setup events for this)

(except the debit part, that should happen when player1 sends the challenge, so i will do this when I create it)

Answer

Hi Mauro


A challenge must have started and be running in order to be won.

You could set the wager to 0 and save the money transfer value in the challenges script data.

If the player accepts they win.


In the user message, ChallengeWonMessage cloud code credit the user the money

var money = Spark.getData().challenge.scriptData("moneyTransfer")

Spark.getPlayer().credit1(money);


In the user message ChallengeLostMessage cloud code take away the money from the user.

var money = Spark.getData().challenge.scriptData("moneyTransfer")

Spark.getPlayer().debit1(money);


Would this work for you?


Regards

Katie

ok then: can I win a challenge without starting it? the use case would be accepting a currency transfer as described in my first post (e.g. I have 100c, my friend sends me 1000c, I accept and win the challenge, I should have 1100c)

Hi Mauro,


Apologies I must have missed your reply. Players can wager different currencies. They must have enough to match the current wager set in the challenge. A player can join a challenge even if they don't have enough currency but they wont take part in it when it starts. The wager can't be modified after the challenge has been created. The amount won can't be changed but you could always use the ChallengeWonMessage Cloud Code to change how the wagered amount is handled manually at the end of a challenge if you wish. If you have any further questions just let us know.


Thanks,

Liam



Hi,

can someone explain how the wager in a challenge works specifically and what kinds of use cases are supported with it? particularly the points above...

Hi,

exactly this, I want to give the receiving player the option of accepting or refusing the currency.


what I miss is how exactly the wager system works:

- can players wager different amount/type of currency? 

- can a player accept a challenge if he doesn't have enough currency? (maybe with a flag set from cloud code or config?)

- can the wager be modified after a challenge is created and players have accepted? if so, what happens to the currency already spent?

- the amount won is always <wager>*<number of participants> or can it be set to a different value? (for example, if I want to "tax" games)


I couldn't fid any answer in the docs, except a tutorial on how to bet virtual goods

Hi Mauro,


Is there a reason you are using challenges to do this ? You could easily do this with a custom event and some SparkPlayer calls in Cloud Code. Do you want to give the receiving player the option of accepting or refusing the currency ? If so using challenges may be the best way to do this. Reason being if player A creates a challenge with a wager, the wager amount is held in the players reservedCurrency until the challenge completes (or the player accepts in your case). If you don't need this then doing it manually in Cloud Code should suffice. if you have any further questions just let me know.


Thanks,

Liam

Login to post a comment