public static void SaveFile(string filePath, ReplayFile replay) { using (ReplayWriter beatmapWriter = new ReplayWriter(File.Open(filePath, FileMode.Create))) { beatmapWriter.Write(replay.Mode); beatmapWriter.Write(replay.Version); beatmapWriter.Write(replay.BeatmapHash); beatmapWriter.Write(replay.PlayerName); beatmapWriter.Write(replay.ReplayHash); beatmapWriter.Write(replay.Count300); beatmapWriter.Write(replay.Count100); beatmapWriter.Write(replay.Count50); beatmapWriter.Write(replay.CountGeki); beatmapWriter.Write(replay.CountKatu); beatmapWriter.Write(replay.CountMiss); beatmapWriter.Write(replay.Score); beatmapWriter.Write(replay.MaxCombo); beatmapWriter.Write(replay.FullCombo); beatmapWriter.Write(replay.UsedMods); beatmapWriter.Write(replay.PerformanceGraphData); beatmapWriter.Write(replay.ReplayDate); string[] list = Encoding.ASCII.GetString(SevenZipHelper.Decompress(replay.Replay)).Split(','); beatmapWriter.Write(replay.Replay); beatmapWriter.Write(replay.Long0); } }
public static ReplayFile ReadFile(string filePath) { ReplayFile replayFile = new ReplayFile(); using (_reader = new ReplayReader(File.Open(filePath, FileMode.Open))) { replayFile.Passed = true; replayFile.Mode = _reader.ReadByte(); replayFile.Version = _reader.ReadInt32(); replayFile.BeatmapHash = _reader.ReadString(); replayFile.PlayerName = _reader.ReadString(); replayFile.ReplayHash = _reader.ReadString(); replayFile.Count300 = _reader.ReadUInt16(); replayFile.Count100 = _reader.ReadUInt16(); replayFile.Count50 = _reader.ReadUInt16(); replayFile.CountGeki = _reader.ReadUInt16(); replayFile.CountKatu = _reader.ReadUInt16(); replayFile.CountMiss = _reader.ReadUInt16(); replayFile.Score = _reader.ReadInt32(); replayFile.MaxCombo = _reader.ReadUInt16(); replayFile.FullCombo = _reader.ReadBoolean(); replayFile.UsedMods = _reader.ReadInt32(); replayFile.PerformanceGraphData = _reader.ReadString(); replayFile.ReplayDate = _reader.ReadDateTime(); replayFile.Replay = _reader.ReadByteArray(); if (replayFile.Version >= 20140721) { replayFile.Long0 = _reader.ReadInt64(); } } return(replayFile); }
public static float GetAccuracy(ReplayFile rf) { switch (rf.Mode) { case 1: if (GetTotalHits(rf) <= 0) { return(0.0f); } return((rf.Count100 * 150 + rf.Count300 * 300) / (float)(GetTotalHits(rf) * 300)); case 2: if (GetTotalHits(rf) == 0) { return(1f); } return(GetHits(rf) / GetTotalHits(rf)); case 3: if (GetTotalHits(rf) == 0) { return(1f); } return((rf.Count50 * 50 + rf.Count100 * 100 + rf.CountKatu * 200 + (rf.Count300 + rf.CountGeki) * 300) / (float)(GetTotalHits(rf) * 300)); default: if (GetTotalHits(rf) <= 0) { return(0.0f); } return((rf.Count50 * 50 + rf.Count100 * 100 + rf.Count300 * 300) / (float)(GetTotalHits(rf) * 300)); } }
private static int GetTotalHits(ReplayFile rf) { switch (rf.Mode) { case 2: return(rf.Count50 + rf.Count100 + rf.Count300 + rf.CountMiss + rf.CountKatu); case 3: return(rf.Count50 + rf.Count100 + rf.Count300 + rf.CountMiss + rf.CountGeki + rf.CountKatu); default: return(rf.Count50 + rf.Count100 + rf.Count300 + rf.CountMiss); } }
public override string ToString() { Type type = GetType(); FieldInfo[] fields = type.GetFields(); PropertyInfo[] properties = type.GetProperties(); ReplayFile user = this; Dictionary <string, object> values = new Dictionary <string, object>(); Array.ForEach(fields, field => values.Add(field.Name, field.GetValue(user))); Action <PropertyInfo> action = property => { if (!property.CanRead) { return; } values.Add(property.Name, property.GetValue(user, null)); }; Array.ForEach(properties, action); return(string.Join(", ", values)); }
public static string GetReplayHash(ReplayFile replay) { return(OsuHelper.HashString(string.Format("{0}p{1}o{2}o{3}t{4}a{5}r{6}e{7}y{8}o{9}u{10}{11}{12}", replay.Count100 + replay.Count300, replay.Count50, replay.CountGeki, replay.CountKatu, replay.CountMiss, replay.BeatmapHash, replay.MaxCombo, replay.FullCombo, replay.PlayerName, replay.Score, replay.Ranking, replay.UsedMods, replay.Passed))); }
public static Rankings GetRanking(ReplayFile rf) { if (!rf.Passed) { return(Rankings.F); } bool flag1 = ContainsMods((Mods)rf.UsedMods, Mods.Hidden | Mods.Flashlight); bool flag2 = ContainsMods((Mods)rf.UsedMods, Mods.Hidden | Mods.Flashlight | Mods.FadeIn); float accuracy = GetAccuracy(rf); switch (rf.Mode) { case 1: float num1 = rf.Count300 / GetTotalHits(rf); float num2 = rf.Count50 / GetTotalHits(rf); if (num1 == 1.0) { return(flag1 ? Rankings.XH : Rankings.X); } if (num1 > 0.9 && num2 <= 0.01 && rf.CountMiss == 0) { return(flag1 ? Rankings.SH : Rankings.S); } if (num1 > 0.8 && rf.CountMiss == 0 || num1 > 0.9) { return(Rankings.A); } if (num1 > 0.7 && rf.CountMiss == 0 || num1 > 0.8) { return(Rankings.B); } return(num1 <= 0.6 ? Rankings.D : Rankings.C); case 2: if (accuracy == 1.0) { return(flag1 ? Rankings.XH : Rankings.X); } if (accuracy > 0.98) { return(flag1 ? Rankings.SH : Rankings.S); } if (accuracy > 0.94) { return(Rankings.A); } if (accuracy > 0.9) { return(Rankings.B); } return(accuracy <= 0.85 ? Rankings.D : Rankings.C); case 3: if (accuracy == 1.0) { return(flag2 ? Rankings.XH : Rankings.X); } if (accuracy > 0.95) { return(flag2 ? Rankings.SH : Rankings.S); } if (accuracy > 0.9) { return(Rankings.A); } if (accuracy > 0.8) { return(Rankings.B); } return(accuracy <= 0.7 ? Rankings.D : Rankings.C); default: float num3 = rf.Count50 / GetTotalHits(rf); if (accuracy == 1.0 && rf.FullCombo) { return(flag1 ? Rankings.XH : Rankings.X); } if (accuracy > 0.9 && num3 <= 0.01 && rf.FullCombo) { return(flag1 ? Rankings.SH : Rankings.S); } if (accuracy > 0.8 && rf.FullCombo || accuracy > 0.9) { return(Rankings.A); } if (accuracy > 0.7 && rf.FullCombo || accuracy > 0.8) { return(Rankings.B); } return(GetAccuracy(rf) <= 0.6 ? Rankings.D : Rankings.C); } }