簡體   English   中英

通過endMatchInTurnWithMatchData:scores方法發送分數時,排行榜未顯示所有更新的分數

[英]Leaderboards not showing all updated scores when sending scores via endMatchInTurnWithMatchData:scores method

我想為游戲實施ELO評分系統。 這意味着在結束游戲后,我必須根據他們的實際得分來計算獲勝者的增加,而減少獲勝者的減少。

我的排行榜類型為“最近的分數”,以僅查看最近發送的分數。 我使用loadScoresWithCompletionHandler加載得分,然后進行計算(現在僅添加不同的值),然后使用endMatchInTurnWithMatchData:scores:achievements:completionHandler:結束比賽並更新得分。

GKTurnBasedParticipant* player1 = [match.participants firstObject];
    GKTurnBasedParticipant* player2 = [match.participants lastObject];
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] initWithPlayerIDs:@[player1.playerID, player2.playerID]];
    leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
    leaderboardRequest.identifier = LEADERBOARD_ELO_RATING_ID;

[leaderboardRequest loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
        if(error){
            NSLog(@"%@", error);
            return;
        }
        GKScore *player1Score = [scores firstObject];
        GKScore *player2Score = [scores lastObject];

        float score1 = ((float)player1Score.value) / 1000.0f;
        float score2 = ((float)player2Score.value) / 1000.0f;

        // calculation of new score
        score1 +=10;
        score2 +=1;

        GKScore *player1NewScore = [[GKScore alloc] initWithLeaderboardIdentifier:LEADERBOARD_ELO_RATING_ID forPlayer:player1Score.playerID];
        GKScore *player2NewScore = [[GKScore alloc] initWithLeaderboardIdentifier:LEADERBOARD_ELO_RATING_ID forPlayer:player2Score.playerID];

        player1NewScore.value = (int64_t)(score1 * 1000.0f);
        player2NewScore.value = (int64_t)(score2 * 1000.0f);

        [match endMatchInTurnWithMatchData:[game.board matchData]
                                    scores:@[player1NewScore, player2NewScore]
                              achievements:@[]
                         completionHandler:^(NSError *error) {
                             if(error){// todo handle error
                             }
                         }];
    }];

獲取分數並上傳新分數效果很好,但是當我去查看排行榜時(使用GKGameCenterViewController或GameCenter應用),我只能看到本地玩家(結束比賽並發送最終數據的參與者)的更新分數。 但是,如果我通過loadScoresWithCompletionHandler方法發出請求-我可以看到兩個玩家的得分都已更新-但是在LeaderboardController中僅顯示本地玩家的得分。

例:

Match started:
Player A - 10 pts
Player B - 10 pts
Match ended (Player A sent these scores using method endMatchInTurnWithMatchData:scores:achievements:completionHandler:):
Player A - 15 pts
Player B - 8 pts
Match ended - loadScoresWithCompletionHandler result shows scores:
Player A - 15 pts
Player B - 8 pts
Match ended - GKGameCenterViewController or GameCenter app shows scores:
Player A - 15 pts
Player B - 10 pts

為什么會這樣,我做錯什么了嗎? 是因為使用了Game Center沙箱嗎? 否則,我應該如何通過endMatchInTurnWithMatchData:scores:achievements:completionHandler:准確地更新兩個球員的得分?

我發現,可能只是因為使用了Game Center Sandbox。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM