ゲーム センター ベースのボード ゲームに取り組んでいます。あちこちでいくつかのバグや癖があり、すべてが実行されているようです。これらの癖の中で最も厄介なのは、終了した試合を表示するときに、表示しているプレイヤーが負けたと常に考えているように見えることです.
ゲームに勝つ動きで試合を終了するとき、私はこれを実行します:
// Act if the game is over because of that move
if ([board playerHasWon:activePlayer]) {
board.canMove = NO;
match = [CNFTurnBasedMatchHelper sharedInstance].currentMatch;
NSUInteger currentIndex = [match.participants indexOfObject:match.currentParticipant];
NSUInteger nextIndex = (currentIndex == 0 ? 1 : 0);
GKTurnBasedParticipant *nextParticipant = [match.participants objectAtIndex:nextIndex];
match.currentParticipant.matchOutcome = GKTurnBasedMatchOutcomeWon;
nextParticipant.matchOutcome = GKTurnBasedMatchOutcomeLost;
[match endMatchInTurnWithMatchData:[[board stringValue] dataUsingEncoding:NSUTF8StringEncoding] completionHandler:nil];
}
しかし、本当の問題は、その matchOutcome の取得にあるのではないかと思います。
試合をロードするとき、現在のプレイヤーのターンでない場合はこれを実行します。
if (match.status == GKTurnBasedMatchStatusEnded) {
// These lines get the board to show the winning line
[board playerHasWon:1];
[board playerHasWon:2];
board.canMove = NO;
if (match.currentParticipant.matchOutcome == GKTurnBasedMatchOutcomeWon) statusLabel.text = @"You won!";
else statusLabel.text = @"You lost!";
}