Sign In Register

How can we help you today?

Start a new topic
Answered

Not-clearly-turn-based games that require players to stay online...

Note that I explicitly avoiding using the terms 'realtime' and 'turnbased' since part of this question is what exactly gamesparks means by these config options. To be perfectly clear as to what i'm trying to implement, i made a list!


Features needed:

1. To play a game, both players need to actually be online for the full duration of the game.

2. Leaving before the game ends is a disconnect, and the outcome is not the same as a simple win/loss.

3. During a game players need to send 'move' packets back and forth. This doesn't happen continuously, but it is not in a well defined 'your turn, my turn' order either. 

4. A 'move' packet will contain an int representing a choice made between several options, a string/enum/code indicating the game-step this move applies to, and possible a crc of the game state.

5. There needs to be <1 sec delay between a player sending a move packet and the other player receiving it, or the game will progress way too slowly to be fun.


My progress so far...


I'm not very clear at all what exactly the 'turn based' toggle button in the services configuration web portal means... but i currently have it set as NOT turn based. 


I am using Challenges not matching. Hosting/Joining of public challenges is working. 


So then, here's the questions:


Though it looks like hosting a challenge, joining it yourself, then closing the game, doesn't automatically close the challenge. Does the 'realtime' toggle affect this behavior? If not whats the correct way to deal with this?


Also, what is the best way to transmit / receive these 'move' packets? I was going to use LogChallengeEventRequest but then I'm not sure how to receive it. If it comes through as a message that I just have to hook into a delegate/event for, I haven't found where that is, yet.


Thanks



Best Answer

Hi James,


Apologies for the slow reply, you could attach store the move data in a collection or you can use the scriptData of the challenge instance itself to store move data between moves.

 

//if you were passing the challengeID in as an attribute from an event you'd use this (you may retrieve this a different way)
var challengeID = Spark.getData().challengeID;

//load the challenge
var challenge = Spark.getChallenge(challengeID);

//example of the data you could store
var setData = challenge.setScriptData("Player_01_Score, 50)

//example of how to retrieve this data
var getData = challenge.getScriptData("Player_01_Score")


Let me know if that suits your needs, if you have any further questions just let me know. 


Thanks,

Liam



Hi James,


No the Realtime toggle isn't used for this, it's to do with our Real Time services which are currently on trial. Can you give us a little more info on the game you are working on ? It sounds like a turn based challenge may work for this. You could use the SparkChallenge calls to determine the outcome of challenges depending on certain player actions. You can read more about SparkChallenge here. For example you could set the challenge as a draw or assign a winner in Cloud Code if the other player leaves during a game. What exactly will the move packets contain ? Once we know we should be able to point you in the right direction. 


Thanks,

Liam

Yea, I figured out how to send a custom challenge event to 'draw' a match. I didn't realize at first that writing cloud code was going to be required, but it is, since there isn't a 'set challenge state' or 'i lost' or 'i won' event built into the api.


As said before:

"4. A 'move' packet will contain an int representing a choice made between several options, a string/enum/code indicating the game-step this move applies to, and possible a crc of the game state."

Answer

Hi James,


Apologies for the slow reply, you could attach store the move data in a collection or you can use the scriptData of the challenge instance itself to store move data between moves.

 

//if you were passing the challengeID in as an attribute from an event you'd use this (you may retrieve this a different way)
var challengeID = Spark.getData().challengeID;

//load the challenge
var challenge = Spark.getChallenge(challengeID);

//example of the data you could store
var setData = challenge.setScriptData("Player_01_Score, 50)

//example of how to retrieve this data
var getData = challenge.getScriptData("Player_01_Score")


Let me know if that suits your needs, if you have any further questions just let me know. 


Thanks,

Liam


Login to post a comment