1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 12:07:27 +08:00
osu-lazer/osu.Game/Rulesets/Scoring/Score.cs

99 lines
2.6 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-11-29 14:41:48 +08:00
2017-03-15 13:06:05 +08:00
using System;
using System.Collections.Generic;
2017-03-15 13:06:05 +08:00
using Newtonsoft.Json;
2017-03-04 18:02:36 +08:00
using osu.Game.Database;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Mods;
using osu.Game.Users;
using System.IO;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Replays;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Scoring
2016-11-29 14:41:48 +08:00
{
public class Score
{
2017-03-15 13:06:05 +08:00
[JsonProperty(@"rank")]
2017-03-14 05:34:43 +08:00
public ScoreRank Rank { get; set; }
2017-03-15 13:06:05 +08:00
[JsonProperty(@"score")]
2016-11-29 22:59:56 +08:00
public double TotalScore { get; set; }
public double Accuracy { get; set; }
2017-01-10 16:01:53 +08:00
public double Health { get; set; }
2017-03-15 13:06:05 +08:00
[JsonProperty(@"maxcombo")]
2017-03-10 15:05:05 +08:00
public int MaxCombo { get; set; }
public int Combo { get; set; }
2017-03-14 05:34:43 +08:00
public Mod[] Mods { get; set; }
private User user;
public User User
{
get
{
return user ?? new User
{
Username = LegacyUsername,
Id = LegacyUserID
};
}
set
{
user = value;
}
}
2017-03-15 13:06:05 +08:00
[JsonProperty(@"replay_data")]
public Replay Replay;
2017-03-15 13:06:05 +08:00
2017-03-04 18:02:36 +08:00
public BeatmapInfo Beatmap;
2017-03-15 13:06:05 +08:00
[JsonProperty(@"score_id")]
public long OnlineScoreID;
[JsonProperty(@"username")]
public string LegacyUsername;
2017-03-15 13:06:05 +08:00
[JsonProperty(@"user_id")]
public long LegacyUserID;
2017-03-15 13:06:05 +08:00
[JsonProperty(@"date")]
public DateTime Date;
/// <summary>
/// Creates a replay which is read from a stream.
/// </summary>
/// <param name="reader">The stream reader.</param>
/// <returns>The replay.</returns>
public virtual Replay CreateReplay(StreamReader reader)
{
var frames = new List<ReplayFrame>();
float lastTime = 0;
foreach (var l in reader.ReadToEnd().Split(','))
{
var split = l.Split('|');
if (split.Length < 4 || float.Parse(split[0]) < 0) continue;
lastTime += float.Parse(split[0]);
frames.Add(new ReplayFrame(
lastTime,
float.Parse(split[1]),
384 - float.Parse(split[2]),
(ReplayButtonState)int.Parse(split[3])
));
}
return new Replay { Frames = frames };
}
2017-04-19 14:40:10 +08:00
public virtual IEnumerable<ScoreStatistic> Statistics => new ScoreStatistic[] { };
2016-11-29 14:41:48 +08:00
}
}