Exemple #1
0
 public static string CreateCollectionName(ApiScore score, string username, string collectionNameFormat)
 {
     try
     {
         return(String.Format(collectionNameFormat, username,
                              modParser.GetModsFromEnum(score.EnabledMods, true)));
     }
     catch (FormatException ex)
     {
         return("Invalid format!");
     }
 }
Exemple #2
0
 /// <summary>
 /// Generate the replay data from api calls
 /// </summary>
 /// <param name="score">score object for general properties</param>
 /// <param name="replay">replay object for the compressed replay data</param>
 /// <param name="readData">uncomress and read the compressed replay data</param>
 public Replay(ApiScore score, ApiReplay replay, bool readData = true) : this()
 {
     score.CloneTo(this);
     ReplayData = Convert.FromBase64String(replay.Content);
     if (readData)
     {
         ReadData();
     }
     FileFormat  = 0;  //?
     BeatmapHash = ""; // use api-call for this
     ReplayHash  = ""; //?
 }
Exemple #3
0
 /// <summary>
 /// Generate the replay data from api calls
 /// </summary>
 /// <param name="score">score object for general properties</param>
 /// <param name="replay">replay object for the compressed replay data</param>
 /// <param name="readData">uncomress and read the compressed replay data</param>
 public Replay(ApiScore score, ApiReplay replay, bool readData = true) : this()
 {
     score.CloneTo(this);
     ReplayData = Convert.FromBase64String(replay.Content.Replace("\\/", "/")); // doesn't work yet
     if (readData)
     {
         ReadData();
     }
     FileFormat  = 0;  //?
     BeatmapHash = ""; // use api-call for this
     //LifebarFrames aren't available
     ReplayHash = "";  //?
 }
Exemple #4
0
        private IList <ApiScore> GetUserScoresResult(string url)
        {
            try
            {
                var jsonResponse = _client.DownloadString(url);

                if (jsonResponse == "Please provide a valid API key.")
                {
                    throw new Exception("Invalid osu!Api key");
                }
                if (jsonResponse.Trim(' ') == string.Empty)
                {
                    return(null);
                }
                var json   = JArray.Parse(jsonResponse);
                var scores = new List <ApiScore>();
                foreach (var kvPair in json)
                {
                    var score = new ApiScore
                    {
                        BeatmapId   = kvPair.Value <int>("beatmap_id"),
                        Score       = kvPair.Value <int>("score"),
                        Count300    = kvPair.Value <int>("count300"),
                        Count100    = kvPair.Value <int>("count100"),
                        Count50     = kvPair.Value <int>("count50"),
                        Countmiss   = kvPair.Value <int>("countmiss"),
                        Maxcombo    = kvPair.Value <int>("maxcombo"),
                        Countkatu   = kvPair.Value <int>("countkatu"),
                        Countgeki   = kvPair.Value <int>("countgeki"),
                        Perfect     = kvPair.Value <int>("perfect"),
                        EnabledMods = kvPair.Value <int>("enabled_mods"),
                        UserId      = kvPair.Value <int>("user_id"),
                        Date        = kvPair.Value <DateTime>("date"),
                        Rank        = kvPair.Value <string>("rank"),
                        Pp          = kvPair.Value <double>("pp")
                    };
                    scores.Add(score);
                }
                return(scores);
            }
            catch
            {
                return(null);
            }
        }
 public string CreateCollectionName(ApiScore score, string username, string collectionNameFormat)
 {
     return(UserTopGenerator.CreateCollectionName(score, username, collectionNameFormat));
 }