Beispiel #1
0
        static bool RemoveOldHighScoreFromLeaderboard(LocalLeaderboardsModel instance, string leaderboardId, string playerName, int score, LocalLeaderboardsModel.LeaderboardType type)
        {
            List <LocalLeaderboardsModel.ScoreData> allTimeScores = instance.GetScores(leaderboardId, type);

            if (allTimeScores == null)
            {
                return(true);
            }
            foreach (LocalLeaderboardsModel.ScoreData data in allTimeScores)
            {
                if (data._playerName != playerName)
                {
                    continue;
                }
                if (data._score < score)
                {
                    allTimeScores.Remove(data);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        static bool Prefix(ref LocalLeaderboardsModel __instance, string leaderboardId, string playerName, int score, bool fullCombo)
        {
            List <LocalLeaderboardsModel.ScoreData> allTimeScores = __instance.GetScores(leaderboardId, LocalLeaderboardsModel.LeaderboardType.AllTime);

            if (!RemoveOldHighScoreFromLeaderboard(__instance, leaderboardId, playerName, score, LocalLeaderboardsModel.LeaderboardType.AllTime))
            {
                return(false);
            }
            if (!RemoveOldHighScoreFromLeaderboard(__instance, leaderboardId, playerName, score, LocalLeaderboardsModel.LeaderboardType.Daily))
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Check whether the level has been successfully completed in party mode.
        /// All duplicate custom beatmaps are treated as completed if any of the duplicates have been completed at least once.
        /// </summary>
        /// <param name="levelID">The level ID of the beatmap.</param>
        /// <param name="difficulties">A list of difficulties to check for level completion (optional).</param>
        /// <param name="playerName">The name of the player on the local leaderboards (optional).</param>
        /// <returns>True if the player(s) has/have completed the beatmap at least once, otherwise false.</returns>
        public bool HasCompletedLevel(string levelID, IEnumerable <BeatmapDifficulty> difficulties = null, string playerName = null)
        {
            levelID = BeatmapDetailsLoader.GetSimplifiedLevelID(levelID);

            if (difficulties == null || difficulties.Count() == 0)
            {
                difficulties = AllDifficulties;
            }

            // get any level duplicates
            List <string> duplicateLevelIDs = GetActualLevelIDs(levelID);

            StringBuilder sb = new StringBuilder();

            foreach (var levID in duplicateLevelIDs)
            {
                foreach (var characteristic in AllCharacteristicStrings)
                {
                    foreach (var difficulty in difficulties)
                    {
                        sb.Clear();
                        sb.Append(levID);
                        sb.Append(characteristic);
                        sb.Append(difficulty.ToString());
                        string leaderboardID = sb.ToString();
                        var    scores        = _localLeaderboardsModel.GetScores(leaderboardID, LocalLeaderboardsModel.LeaderboardType.AllTime);

                        if (scores != null && (playerName == null || scores.Any(x => x._playerName == playerName)))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }