endTurnWithNext参与者未推进

endTurnWithNext参与者未推进

本文介绍了GameCenter:endTurnWithNext参与者未推进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在沙盒环境中,我无法将回合制比赛推进到下一个玩家.

In the sandbox environment, I'm having trouble advancing a turnbased match to the next player.

初始条件:

  • 分别在设备A和设备B上的播放器A和播放器B.
  • 两者都登录到沙箱
  • 两个玩家都可以看到彼此的GC状态消息
  • 玩家A创建一场比赛并邀请玩家B
  • 玩家A结束转弯

在终点转弯"功能中,我将执行以下操作:

In my "end turn" function I do the following:

    NSLog(@"size = %ld", updatedMatchData.length);

    //move the current player to the bottom of the list
    NSMutableArray *nextPlayers = (NSMutableArray *)theMatch.participants;
    NSLog(@"%@", [nextPlayers description]);

    GKTurnBasedParticipant *firstGuy = nextPlayers[0];
    [nextPlayers removeObjectAtIndex:0];
    [nextPlayers addObject:firstGuy];

    NSLog(@"------");
    NSLog(@"%@", [nextPlayers description]);

    //send the match to the servers
    //"theMatch" was recorded in turnBasedMatchmakerViewController:didFindMatch

    [theMatch endTurnWithNextParticipants:nextPlayers
                              turnTimeout:GKTurnTimeoutDefault
                                matchData:updatedMatchData
                        completionHandler:^(NSError *error)
    {
        if (error)
        {
            NSLog(@"WTF?");
        }
    }];

这将产生以下日志输出:

That produces the following log output:

size = 26926
(
"<GKTurnBasedParticipant 0x174018630 - playerID:G:1084583147 (local player) status:Active matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>",
"<GKTurnBasedParticipant 0x174018ba0 - playerID:G:12962188 status:Invited matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>"
)
------
(
"<GKTurnBasedParticipant 0x174018ba0 - playerID:G:12962188 status:Invited matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>",
"<GKTurnBasedParticipant 0x174018630 - playerID:G:1084583147 (local player) status:Active matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>"
)

但是,玩家B没有收到邀请或回合.玩家B的游戏中心应用未显示任何有效的游戏或回合.玩家A的游戏中心继续显示他 still 尚未完成转牌.每次我重新启动并重新执行测试时,玩家A都会折腾另一个未决回合.

However, player B does not receive an invite or a turn. Player B's game center app shows no active games or turns. Player A's game center continues to show that he still has a turn pending. Each time I restart and re-execute the test, Player A racks up yet another pending turn.

玩家A在转弯结束后立即射击玩家:receivedTurnEventForMatch:didBecomeActive,但didBecomeActive设置为NO.

Player A fires player:receivedTurnEventForMatch:didBecomeActive right after I end the turn, but didBecomeActive is set to NO.

因此,我将超时更改为30秒.玩家A结束转牌后30秒,玩家A触发didBecomeActive(否). PlayerB最终收到邀请提示.玩家B触发didBecomeActive,值为YES.

So then I changed the timeout to 30 seconds. 30 seconds after playerA ends the turn, playerA fires didBecomeActive (no). PlayerB finally receives an invite prompt. Player B fires didBecomeActive, with a value of YES.

为什么玩家A结束回合后我的回合不能立即前进到玩家B?为什么玩家A似乎又要转一圈(然后超时并转交给玩家B)?

Why does my turn not advance immediately to player B after player A ends the turn? Why does player A seem to have another turn (which then times out and passes over to player B)?

推荐答案

最终解决了这个问题.不要尝试编辑匹配对象.不要直接编辑matchData或匹配的任何其他组件.创建副本,对副本执行所有操作,然后重新提交副本.

Finally solved this. Do not attempt to edit the match object. Don't directly edit the matchData, or any other component of the match. Create a copy, do whatever you need to do to the copy and resubmit the copy.

我尝试对玩家进行排序产生了各种不稳定的结果,直到我创建了一个完全独立的参与者数组并对其进行了排序.然后按宣传的方式工作.

My attempt to sort the players produced all sorts of erratic results until I created a completely separate participants array and sorted that. Then it worked as advertised.

这篇关于GameCenter:endTurnWithNext参与者未推进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 06:32