Sign In Register

How can we help you today?

Start a new topic
Answered

Creating Async Challenge Match

Hi, 

      I was trying creating an aync challenge where 

             1. Player A will create a challenge with Player B and finish his max attempts.

             2. to overcome ending game (bcz of step 1) , I auto accepted the opponent(B) at ChallegeIssuedMessage cloud code.

             


Now the problem I face is as I'm auto-accepting opponent request, Player A will still get WonMessage at endDate.


Currently only solution I see is to start a scheduler from cloud code at create challege request and trigger a module jst few minutes before end date. 


Is this the better way and only way to handle my case? (imagine 1000 create challges, system will have 1000 schedulers ).


If there is a callback jst before finding out win status of a challenge it would be handy so that i can allocate cash to the players accordingly and find out who won the match with some extra parameters.


Any little guidance will be of great help.



Best Answer

ok, From what I got is - you are saying me to remove the leaderboard from the challenge.

I raised a ticket on the turn events not getting updated on each turn and I got response that for "Non-turn based events, Specifying Leaderboard is a must in challenge setup. Else it won't update the turn count".


Could you please cross check once again and let me know?


Thanks,

Ayyappa.


Hi Ayyappa,


Are you storing your scores in the script data of your challenge?


You can also store scores in a leaderboard and then set a challenge to that leaderboard to reference those scores.

Otherwise your challenge will become a draw as your custom scriptdata is not being used.

If you use a leaderboard however, the challenge will take those results automatically once the time is up or the maxAttempts have been reached



Oisin.

Hi Oisin,

        I linked a leaderboard to the challenge. Im posting a event which will update the leaderboard.

Here i'm planning for an Async Challenge where Player A creates a challenge, finishes his maxAttempts and want to wait for Player B's actions.


Currently if If I don't Auto-Accept  Player B's invitation, The game is getting closed once Player A finishes his maxAttempts.

So after adding Auto-Accepting the invitation , now the problem arises when player B dont play the challenge at all. In this case Player A is getting won message which should be Draw or expired as opponent didn't play the game at all.


Thanks,

Ayyappa.


Hi Ayyappa,


There's an attribute called minPlayers which should ensure that the game doesn't begin (or end) without the specified number of players.
In our experience you'll need both players to begin the challenge.

If that doesn't help, please paste the request you're using to create the challenge so we can have a clearer understanding of your issue.

Thanks


Oisin.

Hi Oisin, Thanks for the reply.

I tried even with min-players expecting it won't end until the min player count is reached. But its not working as expected. However tried it again . Here is the response data.


ASYN_CHALLENGE - Linked to a leaderbord. and ASYNC_CHALLENGE_EVENT is the event linked to it.


Here once after issuing the challenge, with minPlayer = 2, the game got closed(Here drawn message) once just the first player reached his max attempts - Player 2 didn't even accept the invite yet.


{
 "@class": ".LogChallengeEventResponse",
 "scriptData": null
}
{
 "@class": ".ChallengeDrawnMessage",
 "messageId": "54c8def7e4b0efbc00cc7209",
 "notification": true,
 "summary": "No one won Challenge for best!.",
 "challenge": {
  "challengeId": "54c8dedde4b0efbc00cc71fa",
  "endDate": "2015-12-31T12:00Z",
  "challengeName": "Challenge for best!",
  "scriptData": {},
  "shortCode": "ASYNC_CHALLENGE",
  "challengeMessage": "challengeMessage",
  "currency1Wager": 0,
  "currency2Wager": 0,
  "currency3Wager": 0,
  "currency4Wager": 0,
  "currency5Wager": 0,
  "currency6Wager": 0,
  "startDate": null,
  "maxTurns": 2,
  "accepted": [
   {
    "name": "username111",
    "id": "54bed084e4b05b43c60aee50"
   }
  ],
  "challenged": [
   {
    "name": "username222",
    "id": "54bed09ce4b0ae27f8c8c06a"
   }
  ],
  "challenger": {
   "name": "username111",
   "id": "54bed084e4b05b43c60aee50"
  },
  "expiryDate": null,
  "turnCount": {
   "54bed084e4b05b43c60aee50": 2
  },
  "state": "COMPLETE"
 },
 "playerId": "54bed084e4b05b43c60aee50"
}
{
 "@class": ".LogChallengeEventRequest",
 "eventKey": "ASYNC_CHALLENGE_EVENT",
 "challengeInstanceId": "54c8dedde4b0efbc00cc71fa",
 "SCORE_PER_TURN_ATTRIBUTE": "200"
}
{
 "@class": ".LogChallengeEventResponse",
 "scriptData": null
}
{
 "@class": ".LogChallengeEventRequest",
 "eventKey": "ASYNC_CHALLENGE_EVENT",
 "challengeInstanceId": "54c8dedde4b0efbc00cc71fa",
 "SCORE_PER_TURN_ATTRIBUTE": "100"
}
{
 "@class": ".CreateChallengeResponse",
 "challengeInstanceId": "54c8dedde4b0efbc00cc71fa",
 "scriptData": null
}
{
 "@class": ".CreateChallengeRequest",
 "accessType": "PRIVATE",
 "challengeMessage": "challengeMessage",
 "challengeShortCode": "ASYNC_CHALLENGE",
 "currency1Wager": 0,
 "currency2Wager": 0,
 "currency3Wager": 0,
 "currency4Wager": 0,
 "currency5Wager": 0,
 "currency6Wager": 0,
 "endTime": "2015-12-31T12:00Z",
 "maxAttempts": 2,
 "maxPlayers": 2,
 "minPlayers": 2,
 "silent": false,
 "usersToChallenge": "54bed09ce4b0ae27f8c8c06a"
}
{
 "@class": ".AuthenticationResponse",
 "authToken": "40cb6e00-1d9a-4848-ac07-f7662a98dfbf",
 "displayName": "username111",
 "scriptData": null,
 "userId": "54bed084e4b05b43c60aee50"
}

{
 "@class": ".AuthenticationRequest",
 "password": "password",
 "userName": "userName111"
}

Hi Ayyappa,


Just a thought, is your challenge turn-based?


It needs to be turn-based if you want it to wait for other players.

Leaving it not turn-based will put the challenge into a running state immediately.

Thanks,

Oisin.

Hi Oisin,

              Its not turn-based. How ever If i keep it Turn-based current system won't let me play until all accepts the invitation, which is not acceptable for ASYNC challenge.


Just if min players requirement is considered in non-turn based games everything can be solved .Please suggest if any other way is possible.


"Get a score and challenge a friend i see it as a general use-case". Please correct me if I'm wrong.


Thanks,

Ayyappa.



Hi Oisin,

          Any update on this?


Thanks,

Ayyappa.

Hi Ayyappa,


The challenge doesn't need to be turn based but would still need to consume a "turn" event.

This would solve your issue of the turn ending before Player B has a chance to accept.

Player B accepts challenge then logs a challenge event to post the score.

On that cloud code it then calculates the winner.

You may have to use a scripted outcome instead of the leader-board to calculate this event.
If you do use a scripted outcome on the challenge you would have to check which player wins in the cloud code of the LogChallengeEvent.

Thanks.

Oisin.

Answer

ok, From what I got is - you are saying me to remove the leaderboard from the challenge.

I raised a ticket on the turn events not getting updated on each turn and I got response that for "Non-turn based events, Specifying Leaderboard is a must in challenge setup. Else it won't update the turn count".


Could you please cross check once again and let me know?


Thanks,

Ayyappa.

And Do you mean i can keep turn based and start playing without others accepting the game?

Hi Ayyappa,


I've written a guide on how to achieve a good asynchronous flow with GameSparks, you can find it here: https://support.gamesparks.net/discussions/topics/1000051583/page/last/#post_1000098212


It includes the events, challenge and Cloud Code required as well as a run through of a challenge between two players.


I know of at least one other game (Cute Evil Strange that has been released with a very similar system to this and a few that are being developed.


Shane

I was aware of similar approach though  but just wanted to confirm before  implementing as I felt there might be a straight way which I wasn't aware of.


However, the post is great and will be really helpful in regard to cloud code. Thanks a lot shane.

Login to post a comment