Sign In Register

How can we help you today?

Start a new topic

ChallengeWonMessage trigger two times

Hi

I have followed up Hearthstone example in multiplayer tutorial section and change the code a little bit to fit my games . unfortunately the message : 'ChallengeWonMessage' triggers two time . I even use the debugger to better undestand what's happening but everything is fine right before calling 'WonChalleng' function. After calling this , The loser get one message but the winner get two WonMessage after each other and then the message 'ChallengeTurnTakenMessage' is triggered.

can anybody explain what would be wrong with the sample or my code.

Thanks for your answers.


Hi Aboozar,


Can you give me the messageId of the message that shows up twice please. Is it the same message ? Is this in the Test Harness or on the client side ? If you can let us know the name of your game that would be great.


Thanks,

Liam



Hi Liam.

Thanks for your reply.

1.Can you give me the messageId of the message that shows up twice please

 The messageId of each ChallengeWonMessage is different . The problem is that i got two ChallengeWonMessage/ChallengeLostMessage after each other or after TurnTakenMesage for each participated user(in our case 2 user) in Test Harness .


2.Is this in the Test Harness or on the client side?

No,It's on Test Harness.


3.If you can let us know the name of your game that would be great?

Our game name is 'Oojoolat Land'.


I change HeartStone example a little . After Challenge Started . I have just one event named 'action_endTurn' that has a cloud code. It just save player score and then call 

 

chal.consumeTurn(pId);

 

after that ChallengeTurnTakenMessage is triggered and determine the winner and loser or match Draw by calling chal.winChallenge(winnerID) or chal.drawChallenge().


After ChallengeTurnTakenMessage I got Two Different ChallengeWonMessage/ChallengeLostMessage for each user in Test Harness .


Your help would be greatly appreciated.

Thanks again.

Still no idea??

I am also getting an event triggered twice (from Test Harness) - 


The line at the end 

instantWinnerList.insert(instantWinDetails);

is executed twice.


Thanks.

====================================================================================================
var myBool = true;

var instantWinnerList = Spark.runtimeCollection("InstantWin");

var playerID = Spark.getPlayer().getPlayerId();

var dispName = Spark.getPlayer().getDisplayName();

var image = Spark.getPlayer().getScriptData("FBPIC");

var request = new SparkRequests.AccountDetailsRequest();
var response = request.Send();

if(response.location.city){
var loc = response.location.city; 
}else{
 var loc = response.location.country;    
}

var dynamicTotal = Spark.getProperties().getProperty("WINCOUNT");
var prizeAmount = dynamicTotal['PRIZE'];
var batch = dynamicTotal['BATCH'];

var instantWinDetails = {
	"playerID": playerID,
	"displayName": dispName,
	"location": loc,
	"image": image,
	"prizeAmount": prizeAmount,
	"timeOfWin":Date(),
	"batch":batch,
	"batch_ID": batch.toString() + "_" + playerID.toString()
}; 

if(myBool){
instantWinnerList.insert(instantWinDetails);
myBool = false;
}

 

Login to post a comment