Exemplo n.º 1
0
 public static void ReadScore(string file)
 {
     using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         var reader = new BinaryReader(fs);
         reader.ReadInt32(); //version
         int count = reader.ReadInt32();
         for (int i = 0; i < count; i++)
         {
             string songmd5    = reader.ReadString();
             int    scorecount = reader.ReadInt32();
             var    nscore     = new List <ScoreRecord>();
             for (int j = 0; j < scorecount; j++)
             {
                 var tscore = new ScoreRecord
                 {
                     Mode       = (Modes)reader.ReadByte(),
                     Version    = reader.ReadInt32(),
                     DiffHash   = reader.ReadString(),
                     Player     = reader.ReadString(),
                     ReplayHash = reader.ReadString(),
                     Hit300     = reader.ReadUInt16(),
                     Hit100     = reader.ReadUInt16(),
                     Hit50      = reader.ReadUInt16(),
                     Hit320     = reader.ReadUInt16(),
                     Hit200     = reader.ReadUInt16(),
                     Miss       = reader.ReadUInt16(),
                     Score      = reader.ReadInt32(),
                     MaxCombo   = reader.ReadUInt16(),
                     IsPerfect  = reader.ReadBoolean(),
                     Modint     = reader.ReadInt32()
                 };
                 reader.ReadString();//??? 均为空
                 // Debug.Assert(tmp == "");
                 tscore.Time = reader.ReadDateTime();
                 reader.ReadBytes();//??? 均为null
                 //  Debug.Assert(tmp1 == null);
                 if (tscore.Version >= 20140721)
                 {
                     reader.ReadInt64();//Online ID
                 }
                 else
                 {
                     reader.ReadInt32();
                 }
                 tscore.Totalhit = tscore.Hit300 + tscore.Hit100 + tscore.Hit50 + tscore.Miss;
                 nscore.Add(tscore);
             }
             nscore.Sort(Scorecompare);
             Core.Scores.Add(songmd5, nscore);
         }
     }
 }
Exemplo n.º 2
0
 private static int Scorecompare(ScoreRecord a, ScoreRecord b)
 {
     if (a.Score > b.Score)
     {
         return(1);
     }
     if (a.Score == b.Score)
     {
         return(0);
     }
     return(-1);
 }
Exemplo n.º 3
0
 private static int Scorecompare(ScoreRecord a, ScoreRecord b)
 {
     if (a.Score > b.Score)
     {
         return 1;
     }
     if (a.Score == b.Score)
     {
         return 0;
     }
     return -1;
 }
Exemplo n.º 4
0
 public static void ReadScore(string file)
 {
     using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         var reader = new BinaryReader(fs);
         reader.ReadInt32(); //version
         int count = reader.ReadInt32();
         for (int i = 0; i < count; i++)
         {
             string songmd5 = reader.ReadString();
             int scorecount = reader.ReadInt32();
             var nscore = new List<ScoreRecord>();
             for (int j = 0; j < scorecount; j++)
             {
                 var tscore = new ScoreRecord
                 {
                     Mode = (Modes)reader.ReadByte(),
                     Version = reader.ReadInt32(),
                     DiffHash = reader.ReadString(),
                     Player = reader.ReadString(),
                     ReplayHash = reader.ReadString(),
                     Hit300 = reader.ReadUInt16(),
                     Hit100 = reader.ReadUInt16(),
                     Hit50 = reader.ReadUInt16(),
                     Hit320 = reader.ReadUInt16(),
                     Hit200 = reader.ReadUInt16(),
                     Miss = reader.ReadUInt16(),
                     Score = reader.ReadInt32(),
                     MaxCombo = reader.ReadUInt16(),
                     IsPerfect = reader.ReadBoolean(),
                     Modint = reader.ReadInt32()
                 };
                 reader.ReadString();//??? 均为空
                 // Debug.Assert(tmp == "");
                 tscore.Time = reader.ReadDateTime();
                 reader.ReadBytes();//??? 均为null
                 //  Debug.Assert(tmp1 == null);
                 if (tscore.Version >= 20140721)
                 {
                     reader.ReadInt64();//Online ID
                 }
                 else
                 {
                     reader.ReadInt32();
                 }
                 tscore.Totalhit = tscore.Hit300 + tscore.Hit100 + tscore.Hit50 + tscore.Miss;
                 nscore.Add(tscore);
             }
             nscore.Sort(Scorecompare);
             Core.Scores.Add(songmd5, nscore);
         }
     }
 }
Exemplo n.º 5
0
 private static double Getacc(ScoreRecord 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;
     }
 }
Exemplo n.º 6
0
 public static void ReadScore(string file)
 {
     using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         var reader = new BinaryReader(fs);
         reader.ReadInt32(); //version
         int count = reader.ReadInt32();
         for (int i = 0; i < count; i++)
         {
             string songmd5 = reader.ReadString();
             int scorecount = reader.ReadInt32();
             var Nscore = new List<ScoreRecord>();
             for (int j = 0; j < scorecount; j++)
             {
                 var Tscore = new ScoreRecord();
                 Tscore.Mode = (Modes)reader.ReadByte();
                 reader.ReadInt32(); //version
                 reader.ReadString(); //set md5
                 Tscore.Player = reader.ReadString();
                 reader.ReadString(); //diff md5
                 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());
                 reader.ReadInt32();
                 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);
         }
     }
 }
Exemplo n.º 7
0
 public static Image Getrank(ScoreRecord 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;
     }
 }