1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:07:29 +08:00
osu-lazer/osu.Game/Online/Multiplayer/RoomScore.cs

76 lines
2.2 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
2020-05-28 18:57:58 +08:00
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using osu.Game.Online.API;
2020-05-28 19:07:51 +08:00
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
2020-05-28 18:58:07 +08:00
using osu.Game.Users;
namespace osu.Game.Online.Multiplayer
{
public class RoomScore
{
[JsonProperty("id")]
public int ID { get; set; }
2020-05-28 18:58:07 +08:00
[JsonProperty("user")]
public User User { get; set; }
[JsonProperty("rank")]
[JsonConverter(typeof(StringEnumConverter))]
public ScoreRank Rank { get; set; }
[JsonProperty("total_score")]
public long TotalScore { get; set; }
[JsonProperty("accuracy")]
public double Accuracy { get; set; }
[JsonProperty("max_combo")]
public int MaxCombo { get; set; }
[JsonProperty("mods")]
public APIMod[] Mods { get; set; }
[JsonProperty("statistics")]
public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>();
[JsonProperty("passed")]
public bool Passed { get; set; }
[JsonProperty("ended_at")]
public DateTimeOffset EndedAt { get; set; }
public ScoreInfo CreateScoreInfo(PlaylistItem playlistItem)
{
2020-05-28 19:07:51 +08:00
var rulesetInstance = playlistItem.Ruleset.Value.CreateInstance();
var scoreInfo = new ScoreInfo
{
OnlineScoreID = ID,
TotalScore = TotalScore,
MaxCombo = MaxCombo,
Beatmap = playlistItem.Beatmap.Value,
BeatmapInfoID = playlistItem.BeatmapID,
Ruleset = playlistItem.Ruleset.Value,
RulesetID = playlistItem.RulesetID,
2020-05-28 19:07:54 +08:00
Statistics = Statistics,
2020-05-28 18:58:07 +08:00
User = User,
Accuracy = Accuracy,
Date = EndedAt,
Hash = string.Empty, // todo: temporary?
Rank = Rank,
2020-05-28 19:07:51 +08:00
Mods = Mods?.Select(m => m.ToMod(rulesetInstance)).ToArray() ?? Array.Empty<Mod>()
};
return scoreInfo;
}
}
}