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

问题描述 投票:0回答:1

我正在使用基于回合的多人游戏。 玩家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"}]}

像示例SkeletonActivity.java中那样使用finishMatch可以正常工作,但是不会产生赢家:

Games.TurnBasedMultiplayer.finishMatch(getApiClient(), mMatch.getMatchId()
android google-play-services google-play-games
1个回答
0
投票

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

myOponentParticipantId

© www.soinside.com 2019 - 2024. All rights reserved.