Sign In Register

How can we help you today?

Start a new topic

HeartStone Tutorial challenge multiple players

Hi,

I've followed the HeartStone Tutorial and everything seems to work.
But I would like to match up more than 2 people, so in the MatchFoundMessage I need to fill up the request.usersToChallenge with a list of between 2 and 8 ids.
And I can't for the life of me figure out how to make that list. 
I have tried a bunch list declarations and for loops, but it keeps failing to send the challengeRequest.

I've got the feeling this shouldn't be to hard, so I'm probably missing something obvious :p

Thanks already


You'd need to create an array of match participant's id's (minus the id of the player creating the challenge). For example:


var participants = Spark.getData().participants;


if(Spark.getPlayer().getPlayerId() === participants[0].id){

    var usersToChallenge = [];

    for(var i=1, l=participants.length; i<l; ++i){

        usersToChallenge.push(participants[i].id);

    }

    ......

    ......

    ......

    request.usersToChallenge = usersToChallenge;

    request.Send();

}


Regards,

Vinnie

Awesome, that seems to do the trick!


Thanks a lot!

Login to post a comment