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

时间:2014-10-04 08:25:53

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

我使用的是基于回合制的多人游戏。 玩家1开始游戏,玩家2结束。但我总是遇到错误。

这是播放器2的代码:

String playerId = Games.Players.getCurrentPlayerId(getApiClient());
String myOponentId = mMatch.getParticipantId(playerId);

opponentResult = new ParticipantResult(myOponentId,
                    ParticipantResult.MATCH_RESULT_WIN, 1);
            creatorResult = new ParticipantResult(playerId,
                    ParticipantResult.MATCH_RESULT_LOSS, 2);

Games.TurnBasedMultiplayer.finishMatch(getApiClient(), mMatch.getMatchId(),mMatch.getData(), creatorResult,opponentResult )
                .setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
                    @Override
                    public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
                        processResult(result);
                    }
                });

日志:

E/Volley﹕ [2816] a.a: Unexpected response code 400 for https://www.googleapis.com/games/v1/turnbasedmatches/ChEKCQixqozpwBoQAhACGAAgARDEt9LOpreWivoB/finish?language=en_GB
E/cc﹕ Failed to finish match: null
W/cc﹕ {"code":400,"errors":[{"message":"Invalid participantId with value 108607338309210360902.","domain":"global","reason":"invalid"}]}

使用像示例中的finishMatch,SkeletonActivity.java正在运行,但不会产生胜利者:

Games.TurnBasedMultiplayer.finishMatch(getApiClient(), mMatch.getMatchId()

1 个答案:

答案 0 :(得分:0)

好吧,我搞砸了数字。必须设置参与者ID,这类似于p_1,而不是数字

myOponent参与者ID