public static double getacc(Score S) { switch (S.mode) { case modes.Osu: return (S.hit300 * 6 + S.hit100 * 2 + S.hit50) / (double)((S.hit300 + S.hit100 + S.hit50 + S.miss) * 6); case modes.Taiko: return (S.hit300 * 2 + S.hit100) / (double)((S.hit300 + S.hit100 + S.miss) * 2); case modes.CTB: return (S.hit300 + S.hit100 + S.hit50) / (double)(S.hit300 + S.hit100 + S.hit50 + S.hit200 + S.miss); case modes.Mania: return (S.hit300 * 6 + S.hit320 * 6 + S.hit200 * 4 + S.hit100 * 2 + S.hit50) / (double)((S.hit300 + S.hit320 + S.hit200 + S.hit100 + S.hit50 + S.miss) * 6); default: return 0; } }
public static void ReadScore(string file) { using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) { BinaryReader reader = new BinaryReader(fs); int version = reader.ReadInt32(); int count = reader.ReadInt32(); int stash = 0; string stashs = ""; for (int i = 0; i < count; i++) { string songmd5 = reader.ReadString(); int scorecount = reader.ReadInt32(); List<Score> Nscore = new List<Score>(); for (int j = 0; j < scorecount; j++) { Score Tscore = new Score(); Tscore.mode = (modes)reader.ReadByte(); stash = reader.ReadInt32(); stashs = reader.ReadString(); Tscore.player = reader.ReadString(); stashs = reader.ReadString(); Tscore.hit300 = reader.ReadInt16(); Tscore.hit100 = reader.ReadInt16(); Tscore.hit50 = reader.ReadInt16(); Tscore.hit320 = reader.ReadInt16(); Tscore.hit200 = reader.ReadInt16(); Tscore.miss = reader.ReadInt16(); Tscore.score = reader.ReadInt32(); Tscore.maxCombo = reader.ReadInt16(); reader.ReadBoolean();//isperfect Tscore.mod = modconverter(reader.ReadUInt32() + reader.ReadByte() << 32); Tscore.time = new DateTime(reader.ReadInt64()); stash = reader.ReadInt32(); stash = reader.ReadInt32(); Tscore.acc = getacc(Tscore); Tscore.totalhit = Tscore.hit300 + Tscore.hit100 + Tscore.hit50 + Tscore.miss; Nscore.Add(Tscore); } Nscore.Sort(Scorecompare); Core.Scores.Add(songmd5, Nscore); } } }
private static int Scorecompare(Score a, Score b) { if (a.score > b.score) { return 1; } else if (a.score == b.score) { return 0; } else return -1; }
public static Image getrank(Score S) { switch (S.mode) { case modes.Osu: if (S.acc == 1) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.XH; } else { return Resources.X; } } if ((S.hit300) / (double)S.totalhit > 0.9 && S.hit50 / (double)S.totalhit < 0.01 && S.miss == 0) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.SH; } else { return Resources.S; } } if (((S.hit300) / (double)S.totalhit > 0.9) || ((S.hit300) / (double)S.totalhit > 0.8 && S.miss == 0)) { return Resources.A; } if (((S.hit300) / (double)S.totalhit > 0.8) || ((S.hit300) / (double)S.totalhit > 0.7 && S.miss == 0)) { return Resources.B; } if ((S.hit300) / (double)S.totalhit > 0.6) { return Resources.C; } return Resources.D; case modes.Taiko: if (S.acc == 1) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.XH; } else { return Resources.X; } } if ((S.hit300) / (double)S.totalhit > 0.9 && S.hit50 / (double)S.totalhit < 0.01 && S.miss == 0) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.SH; } else { return Resources.S; } } if (((S.hit300) / (double)S.totalhit > 0.9) || ((S.hit300) / (double)S.totalhit > 0.8 && S.miss == 0)) { return Resources.A; } if (((S.hit300) / (double)S.totalhit > 0.8) || ((S.hit300) / (double)S.totalhit > 0.7 && S.miss == 0)) { return Resources.B; } if ((S.hit300) / (double)S.totalhit > 0.6) { return Resources.C; } return Resources.D; case modes.CTB: if (S.acc == 1) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.XH; } else { return Resources.X; } } if (S.acc >= 0.9801) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.SH; } else { return Resources.S; } } if (S.acc >= 0.9401) { return Resources.A; } if (S.acc >= 0.9001) { return Resources.B; } if (S.acc >= 0.8501) { return Resources.C; } return Resources.D; case modes.Mania: if (S.acc == 1) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.XH; } else { return Resources.X; } } if (S.acc > 0.95) { if (S.mod.Contains("HD") || S.mod.Contains("FL")) { return Resources.SH; } else { return Resources.S; } } if (S.acc > 0.90) { return Resources.A; } if (S.acc > 0.80) { return Resources.B; } if (S.acc > 0.70) { return Resources.C; } return Resources.D; default: return Resources.D; } }