Domanda

I am working on a turn based game which uses game center. I do not save any match data locally. While the game goes on, one of the players ends the game and submit score for him self. When the other player launches the game, he gets all matches from the game center (including finished). My problem is, I can not determine for which game I had already submitted the score. For better understanding I list the steps of the scenerio.

  • Bob starts a match
  • Alice accepts the match
  • Alice plays & ends turn
  • Bob plays & ends turn
  • ...
  • ...
  • ...
  • Bob ends match & submits his score to leaderboard
  • Alice launches game and gets from game center 10 finished matches.

Now how do I know, for which matches did I submit the score. As far as I know I can not update the match data, after the match has finished. So I can not save any flag to match data anymore.

Do I something wrong and finish the match too early? Should all players have to wait other players submit their score?

Do I have to save match data locally?

I thought also using last turn date of the match and save locally "last score submit date".

Saving match data or date locally is bad for multiple devices.

È stato utile?

Soluzione 3

I have found a solution after NSSplendid had pointed me the context property. Every time I set the context property of the score timeIntervalSince1970 and I compare the last turn date of the match with it. Actually the GKScore has already the date property, but setting context worked for me better. Because of multiple matches and single player score reports.

Altri suggerimenti

Another thing to try: If you are using Game Center's leaderboards, you could check the context and playerID [1] properties. Then, when a client notices the game G has ended but is unsure if the score is already posted, first download the leaderboard scores for the local playerID from the leaderboard and check if the context is the same as for the just finished game G's matchID.

If not, post the score and leave the matchID as a hint in the context property of the score.

[1] https://developer.apple.com/library/mac/#documentation/GameKit/Reference/GKScore_Ref/Reference/Reference.html#//apple_ref/occ/instm/GKScore/reportScoreWithCompletionHandler:

Every GKTurnBasedMatch has a matchID property. Use this to uniquely identify the game and remember locally if the local user has submitted a score for it yet.

I'd suggest to sync the list of submitted scores via iCloud key-value store to avoid double scores in the high score if the user plays the game on one account but many devices.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top