예제 #1
0
        // ----------------------------------------------------------------------------------------------------------------
        // Determines if the @param scoreStr, and timeStr is a players new high score.
        // All parameters must have been extracted from a players score data (Name-Diff-Score-Time).
        // @timeStr will be in the form of either HH:MM:SS or MM:SS
        public static bool newHighTimeScore(string scoreStr, string timeStr, string difStr)
        {
            int score   = Convert.ToInt32(scoreStr);
            int minutes = 0;
            int seconds = 0;

            // Counts the number of special characters in timeStr,
            // In this case we are counting the number of ":"
            // There will be two if timeStr is in the format of HH:MM:SS
            // Otherwise there will be only one MM:SS
            int count = GlobalApp.findNumberOfCharacters(":", timeStr);

            // What we are determining is if the timeStr has 2 ":";
            // if it does have 2 ":", the format of timeStr is HH:MM:SS
            if (count < 2)
            {
                // First part of the string
                minutes = Convert.ToInt32(GlobalApp.splitString(timeStr, 0, ':'));

                // Second part of the string
                seconds = Convert.ToInt32(GlobalApp.splitString(timeStr, 1, ':'));

                localPosition  = determinePosition(false, score, 0, minutes, seconds);
                onlinePosition = determinePosition(true, score, 0, minutes, seconds);
            }
            else
            {
                // First part of the string
                int hours = Convert.ToInt32(GlobalApp.splitString(timeStr, 0, ':'));

                // Second part of the string
                minutes = Convert.ToInt32(GlobalApp.splitString(timeStr, 1, ':'));

                // Third part of the string
                seconds = Convert.ToInt32(GlobalApp.splitString(timeStr, 2, ':'));

                localPosition  = determinePosition(false, score, hours, minutes, seconds);
                onlinePosition = determinePosition(true, score, hours, minutes, seconds);
            }
            return(localPosition <= MAXNUMBEROFLOCALSCORES || onlinePosition <= MAXNUMBEROFONLINESCORES);
        }