Sign In Register

How can we help you today?

Start a new topic

Common goal challenge

Hi,

I am trying to create a "common goal challenge", the idea is:

1) all players partecipate to a challenge with a common goal (for example win X matches)

2) players are awarded when some milestones are reached (for example 50% of the goal) and receive the biggest award if they reach the goal before the expiration of the challenge

3) don't care which players have played and how much they have contributed to the common goal, because all the awards are equal and there isn't a common leaderboard


My first option was to create a Team, a Team Leaderboard and a Team Achievement, but than I realised it would be too complex, provided that a single team will play and I don't need a real leaderboard.

Maybe I could just create a Challenge and update a custom runtime with the single score, any other idea about this?

 

Thanks,

Riccardo

1 Comment

Hi Riccardo,


I would advise:


-Creating a common goal collection/table. 

-Every entry in that collection/table will be a unique goal.

-Every entry will have a unique ID that players reference.

-Player's use that ID to input or contribute towards that goal. Any contribution will be added to that collection/table entry.

-When players contribute, you can add the unique ID of the goal to their private data. Private data is useful here because that means you can run a convenient bulk job to compare your list of goals and not grow the player's script data which is returned in a lot of responses and messages which clogs your bandwidth.
-When you create the goal you can set a timestamp on when it's created and the timestamp you want it to finish.

-On the every hour or every day (Instead of checking every minute, you can still do that if you want) system scripts you can check when check current time against the creation stamp. If the goal has exceeded its lifetime.

-If the goal has exceeded its life time you can run a bulk job on every player seeing if they contributed towards that goal and award them appropriately. What's great about bulk jobs is that they are the most efficient way of executing a function on every player. So for example, your script would be:



var idOfGoal = "someUniqueID" //Or Spark.getData().idOfGoal //depends how you get the ID in
var listOfGoalsOBJ = Spark.getPlayer().getPrivateData("listOfGoals") //which is a JSON object
if(listOfGoalsOBJ[idOfGoal] != null){

//Do something to award player

}


Your goal entry might look something like this:


{"type":"Quest",
"creationTimeStamp":1524844033,
"endTimeStamp":1524848000,
"monstersKilled":500000}

If you're using the runtime collections system and not the game data service your ID will be part of the document. You can use the auto generated object ID or make your own:

{"_id":{"$oid":"5ae1e1598e5b622b888e251d"},
"type":"Quest",
"creationTimeStamp":1524844033,
"endTimeStamp":1524848000,
"monstersKilled":500000}

or

{"_id":{"$oid":"5ae1e1598e5b622b888e251d"},
"name":"might quest of eternity",
"type":"Quest",
"creationTimeStamp":1524844033,
"endTimeStamp":1524848000,
"monstersKilled":500000}



Of course this is only a few pointers, the customisation is up to you.


Hope this helps or gets you closer,

Cheers,

Omar


Login to post a comment