Sign In Register

How can we help you today?

Start a new topic

LogChallengeEventRequest. What Am I missing? possibleBug?

I've been trying to fix this for hours now ...

I have a takeTurn event properly set (but dont mind the attributes for now), and a TurnBased challenge created with consumer takeTurn.

I've set to consume a turn on GlobalMessages, ChallengeStartedMessage

 

var challenge = Spark.getChallenge(Spark.data.challenge.challengeId);
var challengerId = challenge.getChallengerId();

challenge.consumeTurn(challengerId);

 If I send and acept challenge in TestHarness, then Turn is consumed , status changes to running and I can do a LogChallengeEvent takeTurn in Harness and properly see on Client that a turn has been consumed because I have ChallengeTurnTakenListeners and Handlers that are triggered everytime a turn is consumed (that gets challengeId just for debug ).


However... when I run :


new LogChallengeEventRequest_takeTurn()
            .SetChallengeInstanceId(challengeId)
            .Send((response) =>
        { 
            if (response.HasErrors)
            {
                Debug.Log(response.Errors);
                Debug.Log("ChallId: " + challengeId);
            }
            else
            {
                Debug.Log("TakeTurn_OK");
            }
        });

 

 

Yes I have custom SDK imported.


Even If I run :


new LogChallengeEventRequest().SetChallengeInstanceId(challengeId)
       .SetEventKey("takeTurn")
       .Send((response) =>
       {
           if (response.HasErrors)
           {
               Debug.Log(response.Errors);
           }
           else
           {
               Debug.Log("TakeTurn_OK");
               Debug.Log("cID:" + challengeId)
           }
       });

 

challengeId is correct because I use it in the same script on new AcceptChallengeRequest().SetChallengeInstanceId(challengeId)

Wich Works properly.

IT's not my cloudCode , because it Works in testHarness... and i don't see any problem with my code.

Is it possible that when I acceptChallengeRequest in Unity, GlobalMessages, ChallengeStartedMessage is not being triggered and then it's not my turn and gives me an error?

(Im gonna debug this quick, but i don't think that's it ...)


*Edit, When I run those calls in Unity, it returns and error

I've deleted challenge and event, players from database, challangeInstances and so on.
I can't reproduce the problem again.

Hi Flavio, 


The Global ChallengeStartedMessage will be triggered as long the starting conditions of the challenge were met after the other player accepted with the AcceptChallengeRequest. If the challenge has a maxPlayers setting of 2 and an autoStartJoinedChallengeOnMaxPlayers value set to true then the challenge should auto start and the ChallengeStartedMessage will be triggered when the second player accepts. What was the configuration you used when creating the challenge ? 


Regards,

Liam

Apparently I was not setting eventAttributes on Unity after setting eventKey, and that triggered the error because my cloudCode was waiting for a Spark.getData.attribute.

When I tested on Harness I've set the attributes manually, but on Unity code I was not declaring it.

Login to post a comment