Sign In Register

How can we help you today?

Start a new topic
Answered

Custom Tournaments

I am creating a feature where players can opt into a tournament and at the tournament start time a script will be scheduled to run which creates challenges between all the players signed up for the tournament. I am new to doing custom behavior outside of the built-in challenge and matching making framework.


1. How could I query the player collection in a script?

2. How could I create a custom collection to store players signed up for a tournament?

3. How should I create a script that I want to execute at a scheduled time? Module, or custom event?

4. How would I create challenges between a set of users from a script?


Best Answer

Hi Jaayden, 


1)First of all, we would always advise the mirroring of the System.Player collection for player related queries. This is because it is a system critical collection and any data manipulation outside of defined intractable data sets can cause severe instability. 

You can see how to do this here.


2) You would create a collection in the same way as the tutorial above. You would then create tournaments either  with just  events and cloud code, or through the use of our Dynamic forms. This would allow you to have an entry in the db for each tournament running. On that Tournament document, you would store things like the players participating in it, rewards if any, run-time, expiry time and it's state. The schema is down to you but that is where I would start. 


3) You may not need a scheduler in this case, it depends specifically on what you wish to do. Youc ould use it to clean up/ end tournaments that hit their expiry time. The award players etc. 


4) You could store a unique id with reference to the Tournament entry on the player. This could then be used as the MatchGroup to match players into tournament specific challenges. 


Does this somewhat answer your questions? 

Happy to assist further. 


Best Regards, Patrick. 


Answer

Hi Jaayden, 


1)First of all, we would always advise the mirroring of the System.Player collection for player related queries. This is because it is a system critical collection and any data manipulation outside of defined intractable data sets can cause severe instability. 

You can see how to do this here.


2) You would create a collection in the same way as the tutorial above. You would then create tournaments either  with just  events and cloud code, or through the use of our Dynamic forms. This would allow you to have an entry in the db for each tournament running. On that Tournament document, you would store things like the players participating in it, rewards if any, run-time, expiry time and it's state. The schema is down to you but that is where I would start. 


3) You may not need a scheduler in this case, it depends specifically on what you wish to do. Youc ould use it to clean up/ end tournaments that hit their expiry time. The award players etc. 


4) You could store a unique id with reference to the Tournament entry on the player. This could then be used as the MatchGroup to match players into tournament specific challenges. 


Does this somewhat answer your questions? 

Happy to assist further. 


Best Regards, Patrick. 

Thank you, This answers most of my question. One thing I would like to see if it is possible is to pre-create all the challenges between the players signed up for the tournament. So for example, if 4 players are involved then there would be 6 challenges created so that everyone plays each other once. As far as I can tell for CreateChallengeRequest, it is required to be run by a signed in user. Would it be be possible to insert directly into the challengeInstance collection?


Also, is the system/every day method the best way to schedule to execute code that is not meant to run in the context of a single user? Ideally, I want to run the script to pre-create the challenge once a week instead of every day.

Login to post a comment