【发布时间】:2014-10-04 08:25:53
【问题描述】:
我正在使用基于回合的多人游戏。 玩家 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