基于回合制的多人游戏无法在Google Play游戏服务中完成

时间:2014-07-08 14:58:56

标签: android google-play-services google-play-games

这曾经完美地运作,但目前游戏服务似乎无法处理TurnBasedMultiplayer.finishMatch()发出的请求,我的玩家无法完成他们的游戏。在游戏过程中(轮流)没有任何异常发生,但完成后会产生响应代码400.

可能会发生什么,我该怎么办?

logcat的:

W/GLSUser (  887): GoogleAccountDataService.getToken()
I/qtaguid ( 1173): Failed write_ctrl(u 180) res=-1 errno=22
I/qtaguid ( 1173): Untagging socket 180 failed errno=-22
W/NetworkManagementSocketTagger( 1173): untagSocket(180) failed with errno -22
E/Volley  ( 1188): [87] tm.a: Unexpected response code 400 for    https://www.googleapis.com/games/v1/turnbasedmatches/ChEKCQjrgfqCvgsQAhACGAAgARDruaLm9un3vyg/finish?language=de_DE
E/dwr     ( 1188): Failed to finish match: null
W/dwr     ( 1188): {"code":400,"errors":[{"message":"Invalid results. results","domain":"global","reason":"InvalidMatchResults"}]}
D/UPDATE_MATCH_RESULT(30627): Status{statusCode=unknown status code: 6504, resolution=null}

代码:

        ParticipantResult opponentResult = null;
        ParticipantResult creatorResult = null;
        if (mMatchData.opponentWonCounter > mMatchData.creatorWonCounter) {
            opponentResult = new ParticipantResult(getParticipantId(),
                    ParticipantResult.MATCH_RESULT_WIN, 1);
            creatorResult = new ParticipantResult(
                    mMatchData.creatorParticipantId,
                    ParticipantResult.MATCH_RESULT_LOSS, 2);
        } else if (mMatchData.opponentWonCounter < mMatchData.creatorWonCounter) {
            opponentResult = new ParticipantResult(getParticipantId(),
                    ParticipantResult.MATCH_RESULT_LOSS, 2);
            creatorResult = new ParticipantResult(
                    mMatchData.creatorParticipantId,
                    ParticipantResult.MATCH_RESULT_WIN, 1);
        } else {
            opponentResult = new ParticipantResult(getParticipantId(),
                    ParticipantResult.MATCH_RESULT_TIE, 1);
            creatorResult = new ParticipantResult(
                    mMatchData.creatorParticipantId,
                    ParticipantResult.MATCH_RESULT_TIE, 1);
        }

        Games.TurnBasedMultiplayer
                .finishMatch(getApiClient(), mMatch.getMatchId(), data,
                        creatorResult, opponentResult)
                .setResultCallback(
                        new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
                            @Override
                            public void onResult(
                                    TurnBasedMultiplayer.UpdateMatchResult result) {
                                Log.d("UPDATE_MATCH_RESULT", result
                                        .getStatus().toString());
                                dismissProgress();
                                completeMatch();
                            }
                        });

1 个答案:

答案 0 :(得分:0)

修改

我确认这是按预期工作的。此外,最后一轮的玩家可以完成比赛并发布最终结果。

我自己介绍了一个错误,很抱歉这个混乱。 (我有两个玩家设置。'创建者'无法完成比赛,而'对手'是。这是由参与者ID混淆和代码失明导致我无法识别问题引起的。)

旧回答:

进一步调查显示这些方法已停止工作:

finishMatch(GoogleApiClient apiClient, String matchId, byte[] matchData, ParticipantResult... results)

finishMatch(GoogleApiClient apiClient, String matchId, byte[] matchData, List<ParticipantResult> results)

虽然这个仍然完美无缺:

finishMatch(GoogleApiClient apiClient, String matchId)

我在此处提交了一份错误报告:https://code.google.com/p/play-games-platform/issues/list

编辑:Google承认:http://goo.gl/Ubqy9n

所以这是令人讨厌的解决方法: 1)多转一圈以更新比赛。 2)完成比赛。

        Games.TurnBasedMultiplayer
                .takeTurn(getApiClient(), mMatch.getMatchId(), data,
                        nextParticipantId)
                .setResultCallback(
                        new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
                            @Override
                            public void onResult(UpdateMatchResult result) {
                                mMatch = result.getMatch();
                                Games.TurnBasedMultiplayer
                                        .finishMatch(getApiClient(),
                                                mMatch.getMatchId())
                                        .setResultCallback(
                                                new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
                                                    @Override
                                                    public void onResult(
                                                            TurnBasedMultiplayer.UpdateMatchResult result) {
                                                        Log.d("UPDATE_MATCH_RESULT",
                                                                result.getStatus()
                                                                        .toString());
                                                        dismissProgress();
                                                        completeMatch();
                                                    }
                                                });
                            }
                        });