question

David Breiter avatar image
David Breiter asked

How to Handle Turnbased Multiplayer Correctly?

Hello Guys, i am currently struggling in finding the right concept for my turn based multiplayer project.

I am trying to achieve a similar concept to the game "Bike Race" in which players can record their run on a track and send it to their opponent. In the core its a turn based game like chess e.g. but with the difference that runs are recorded and need to be stored. That's why I am currently using Groups to store the runs in group files and the group entity object to keep track of turns and so on. With this concept it is very easy to handle invites.

Problem i am having is, what if players play a few rounds and therefore have for example 3 runs uploaded to the group but then they never log in to the game ever again. That would mean that none of the players that created the group will login to delete the group and the data will just lay there for ever.

What I want to achieve would be a similar concept to chess.com where you can give your rooms/groups an expiration date. Meaning I am starting a game and when I am not responding for 30 days/14 Days/7 days / 1 Day , the group will be deleted automatically. On Deletion I want to trigger a cloud script to grant items to the player that was winning at that state.

I am currently looking into room creation with photon but I am not finding anything about persistent rooms and server scripts that will automatically execute after x-Time without any player having to trigger them after room creation.

If anyone can help me or has an idea of how to approach this problem it would be great.

Colleagues said to me they would just leave these rooms and manually delete them after a few months if these groups/rooms would not disappear cause of inactivity by some players. that solution seems to be the last way and not very elegant .

cheers

multiplayer
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Breiter avatar image David Breiter commented ·

i am just finding out there is something called scheduled tasks. maybe with that I am able to execute the deletion of a certain group at a certain time

0 Likes 0 ·

1 Answer

·
Simon Cui avatar image
Simon Cui answered

You can use “Segmentation” to create a targeted group that filter those users who hasn’t logged for a certain period. Then you can add a function of “Entered Segment” to execute CloudScript which can delete the group that related to this player. For example, you may write CloudScript function like this:

 handlers.DeleteUnusedGroup = function(args, context){
     var result = server.GetUserAccountInfo({PlayFabId: currentPlayerId});
     var titlePlayerEntityKey = result.UserInfo.TitleInfo.TitlePlayerAccount;
     var groupResults = entity.ListMembership({
         Entity: titlePlayerEntityKey
     });
     var groupId = groupResults.Groups[0].Group.Id;
     var deleteResult = entity.DeleteGroup({
         "Group":{
             "Id":groupId
         }
     });
 }
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.