Sign In Register

How can we help you today?

Start a new topic
Answered

Question related to Matchmaking in the Hearthstone Example

In the Matchmaking section of the Hearthstone Example, when a challenge is accepted we move to the Challenge Started Message stage. In your example, you mention that "To avoid duplication, we'll only allow the challenger to set up the challenge."


My question is that if we want to avoid duplication, why can't we use the Global Challenge Started Message for this script because that would execute once for both players? Using the User Challenge Started Message requires us to put a statement like "if(Spark.getPlayer().getPlayerId() === challengerId){"  and would also result in the script running twice essentially.


What is the best practice here? Is my understanding of the above situation correct?


Best Answer

Hi Faraz,


Your solution seems perfectly valid, we try to remain as agnostic to any particular processes/practices as possible, this allows our users to have full flexibility when it comes to individual implementations. I think the motivation for this implementation was to keep the tutorial as simple as possible.  My recommendation would be to test this out and see if it works for your case. 


Hope this helps,

 - Steve


Answer

Hi Faraz,


Your solution seems perfectly valid, we try to remain as agnostic to any particular processes/practices as possible, this allows our users to have full flexibility when it comes to individual implementations. I think the motivation for this implementation was to keep the tutorial as simple as possible.  My recommendation would be to test this out and see if it works for your case. 


Hope this helps,

 - Steve

Actually I do not believe the global Challenge Started message works for this. Correct me if i'm wrong, but I vaguely recall tryin this and running into issues. 


It was either an issue related to some other cloud scripts I depended on not getting triggered... 


Or it could have been an issue with some requests related to challenges seem to require being sent/executed from within a context in which there is a "current player" (and in global message scripts there is not one).


Sorry that is so vague.


I found that ultimately I needed to diverge from how the tutorial was setting up challenges "automatically" in cloud code and instead have the clients drive the challenge creation/invitation/accept process in response to the match found message.


Login to post a comment