/// <summary> /// Use scoresDb to generate collections based on grade. /// </summary> /// <param name="scoresDb"></param> /// <param name="seperators"></param> /// <param name="name"></param> /// <param name="collectionDb">Merge collections into existing collectionDb. Overwrites existing collections.</param> /// <returns></returns> public static CollectionDb GenerateCollectionDbByGrade(OsuDb osuDb, Mode gameMode, string prefix = "", CollectionDb collectionDb = null) { CollectionDb colDb = new CollectionDb(20190620); foreach (Beatmap beatmap in osuDb.GetBeatmaps()) { Grade grade = beatmap.getGrade(gameMode); string letter; switch (grade) { case Grade.Unplayed: continue; case Grade.XH: letter = "SS+"; break; case Grade.SH: letter = "S+"; break; case Grade.X: letter = "SS"; break; default: letter = grade.ToString(); break; } Collection col = colDb.GetCollectionByName(prefix + letter); if (col == null) { colDb.AddCollection(new Collection(prefix + letter)); } colDb.GetCollectionByName(prefix + letter).AddBeatmap(beatmap.MD5Beatmap); } if (collectionDb != null) { collectionDb.Merge(colDb, AddMode.Overwrite); colDb = collectionDb; } return(colDb); }
// generate collections by accuracy private static object RunGenColByAccAndReturnExitCode(GenColByAccOptions opts) { // if online: // check if osu!.db present // check if key and name present // if offline: // check if scores.db present // if online: // collect list of all maps with scores that are ranked, loved or approved // collect list of all maps in osu!.db where // Grade achieved in standard // Grade achieved in taiko // Grade achieved in CTB // Grade achieved in mania // are not unplayed // use api to get scores // can use ranked_score to see if all maps // if local: get scores from scores.db // if name specified: can use ranked_score to see if all maps CollectionDb colDb = null; if (opts.Online) { if (string.IsNullOrWhiteSpace(opts.Key)) { throw new ArgumentException("Key is empty."); } if (string.IsNullOrWhiteSpace(opts.Name)) { throw new ArgumentException("Name is empty."); } if (!File.Exists(Path.Combine(opts.OsuPath, "osu!.db"))) { throw new FileNotFoundException("Missing osu!.db in selected folder."); } throw new NotImplementedException(); } else { string scoresDbPath = Path.Combine(opts.OsuPath, "scores.db"); if (!File.Exists(scoresDbPath)) { throw new FileNotFoundException("Missing scores.db in selected folder."); } ScoresDb scoresDb = new ScoresDb(scoresDbPath); List <int> seperators = new List <int>(opts.Seperators); colDb = CollectionTools.GenerateCollectionDbByAccuracy(scoresDb, seperators, opts.Name, opts.Prefix); } if (opts.MergeWithExisting) { string existingPath = Path.Combine(opts.OsuPath, "collection.db"); if (!File.Exists(existingPath)) { Console.WriteLine("Missing collection.db in selected folder. Skipping merge operation"); } else { CollectionDb existing = new CollectionDb(existingPath); existing.Merge(colDb, AddMode.Overwrite); colDb = existing; } } colDb.WriteToFile(opts.OutputFile); return(0); }