2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2019-01-05 05:52:00 +08:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users
|
|
|
|
|
{
|
2020-02-27 18:21:59 +08:00
|
|
|
|
public class User : IEquatable<User>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"id")]
|
|
|
|
|
public long Id = 1;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"join_date")]
|
|
|
|
|
public DateTimeOffset JoinDate;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"username")]
|
|
|
|
|
public string Username;
|
|
|
|
|
|
2019-08-02 00:14:07 +08:00
|
|
|
|
[JsonProperty(@"previous_usernames")]
|
|
|
|
|
public string[] PreviousUsernames;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"country")]
|
|
|
|
|
public Country Country;
|
|
|
|
|
|
2019-12-18 13:07:12 +08:00
|
|
|
|
public readonly Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-12-18 13:07:12 +08:00
|
|
|
|
public readonly Bindable<UserActivity> Activity = new Bindable<UserActivity>();
|
2019-05-06 02:07:55 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
//public Team Team;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"profile_colour")]
|
|
|
|
|
public string Colour;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"avatar_url")]
|
|
|
|
|
public string AvatarUrl;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"cover_url")]
|
|
|
|
|
public string CoverUrl
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => Cover?.Url;
|
|
|
|
|
set => Cover = new UserCover { Url = value };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"cover")]
|
|
|
|
|
public UserCover Cover;
|
|
|
|
|
|
|
|
|
|
public class UserCover
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"custom_url")]
|
|
|
|
|
public string CustomUrl;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"url")]
|
|
|
|
|
public string Url;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"id")]
|
|
|
|
|
public int? Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"is_admin")]
|
|
|
|
|
public bool IsAdmin;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"is_supporter")]
|
|
|
|
|
public bool IsSupporter;
|
|
|
|
|
|
2018-12-22 23:51:24 +08:00
|
|
|
|
[JsonProperty(@"support_level")]
|
|
|
|
|
public int SupportLevel;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"is_gmt")]
|
|
|
|
|
public bool IsGMT;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"is_qat")]
|
|
|
|
|
public bool IsQAT;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"is_bng")]
|
|
|
|
|
public bool IsBNG;
|
|
|
|
|
|
2019-09-27 14:22:25 +08:00
|
|
|
|
[JsonProperty(@"is_bot")]
|
|
|
|
|
public bool IsBot;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"is_active")]
|
|
|
|
|
public bool Active;
|
|
|
|
|
|
2019-06-19 00:13:21 +08:00
|
|
|
|
[JsonProperty(@"is_online")]
|
|
|
|
|
public bool IsOnline;
|
|
|
|
|
|
2018-12-22 23:51:24 +08:00
|
|
|
|
[JsonProperty(@"pm_friends_only")]
|
|
|
|
|
public bool PMFriendsOnly;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"interests")]
|
|
|
|
|
public string Interests;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"occupation")]
|
|
|
|
|
public string Occupation;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"title")]
|
|
|
|
|
public string Title;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"location")]
|
|
|
|
|
public string Location;
|
|
|
|
|
|
2018-08-26 11:31:33 +08:00
|
|
|
|
[JsonProperty(@"last_visit")]
|
2018-10-04 23:25:40 +08:00
|
|
|
|
public DateTimeOffset? LastVisit;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"twitter")]
|
|
|
|
|
public string Twitter;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"lastfm")]
|
|
|
|
|
public string Lastfm;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"skype")]
|
|
|
|
|
public string Skype;
|
|
|
|
|
|
2018-04-19 20:46:42 +08:00
|
|
|
|
[JsonProperty(@"discord")]
|
|
|
|
|
public string Discord;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"website")]
|
|
|
|
|
public string Website;
|
|
|
|
|
|
2018-04-19 20:46:42 +08:00
|
|
|
|
[JsonProperty(@"post_count")]
|
|
|
|
|
public int PostCount;
|
|
|
|
|
|
2018-12-22 23:51:24 +08:00
|
|
|
|
[JsonProperty(@"follower_count")]
|
2019-07-18 13:05:57 +08:00
|
|
|
|
public int FollowerCount;
|
2018-12-22 23:51:24 +08:00
|
|
|
|
|
2019-12-17 17:36:44 +08:00
|
|
|
|
[JsonProperty(@"favourite_beatmapset_count")]
|
|
|
|
|
public int FavouriteBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"graveyard_beatmapset_count")]
|
|
|
|
|
public int GraveyardBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"loved_beatmapset_count")]
|
|
|
|
|
public int LovedBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"ranked_and_approved_beatmapset_count")]
|
|
|
|
|
public int RankedAndApprovedBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"unranked_beatmapset_count")]
|
|
|
|
|
public int UnrankedBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"scores_first_count")]
|
|
|
|
|
public int ScoresFirstCount;
|
|
|
|
|
|
2019-01-05 05:52:00 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
private string[] playstyle
|
|
|
|
|
{
|
2019-11-12 18:26:42 +08:00
|
|
|
|
set => PlayStyles = value?.Select(str => Enum.Parse(typeof(PlayStyle), str, true)).Cast<PlayStyle>().ToArray();
|
2019-01-05 05:52:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PlayStyle[] PlayStyles;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"playmode")]
|
|
|
|
|
public string PlayMode;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"profile_order")]
|
|
|
|
|
public string[] ProfileOrder;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"kudosu")]
|
|
|
|
|
public KudosuCount Kudosu;
|
|
|
|
|
|
|
|
|
|
public class KudosuCount
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"total")]
|
|
|
|
|
public int Total;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"available")]
|
|
|
|
|
public int Available;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"statistics")]
|
|
|
|
|
public UserStatistics Statistics;
|
|
|
|
|
|
|
|
|
|
public class RankHistoryData
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"mode")]
|
|
|
|
|
public string Mode;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"data")]
|
|
|
|
|
public int[] Data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"rankHistory")]
|
2019-08-04 19:35:26 +08:00
|
|
|
|
private RankHistoryData rankHistory
|
|
|
|
|
{
|
|
|
|
|
set => Statistics.RankHistory = value;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-16 05:44:59 +08:00
|
|
|
|
[JsonProperty("badges")]
|
|
|
|
|
public Badge[] Badges;
|
|
|
|
|
|
2018-12-22 23:51:24 +08:00
|
|
|
|
[JsonProperty("user_achievements")]
|
|
|
|
|
public UserAchievement[] Achievements;
|
|
|
|
|
|
|
|
|
|
public class UserAchievement
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("achieved_at")]
|
|
|
|
|
public DateTimeOffset AchievedAt;
|
|
|
|
|
|
|
|
|
|
[JsonProperty("achievement_id")]
|
|
|
|
|
public int ID;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-07 21:21:47 +08:00
|
|
|
|
[JsonProperty("monthly_playcounts")]
|
|
|
|
|
public UserHistoryCount[] MonthlyPlaycounts;
|
|
|
|
|
|
|
|
|
|
[JsonProperty("replays_watched_counts")]
|
|
|
|
|
public UserHistoryCount[] ReplaysWatchedCounts;
|
|
|
|
|
|
|
|
|
|
public class UserHistoryCount
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("start_date")]
|
|
|
|
|
public DateTime Date;
|
|
|
|
|
|
|
|
|
|
[JsonProperty("count")]
|
|
|
|
|
public long Count;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public override string ToString() => Username;
|
2018-09-13 12:40:46 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A user instance for displaying locally created system messages.
|
|
|
|
|
/// </summary>
|
2018-09-13 13:03:21 +08:00
|
|
|
|
public static readonly User SYSTEM_USER = new User
|
2018-09-13 12:40:46 +08:00
|
|
|
|
{
|
|
|
|
|
Username = "system",
|
2019-08-08 16:10:06 +08:00
|
|
|
|
Colour = @"9c0101",
|
2018-09-13 12:40:46 +08:00
|
|
|
|
Id = 0
|
|
|
|
|
};
|
2019-01-05 05:52:00 +08:00
|
|
|
|
|
|
|
|
|
public enum PlayStyle
|
|
|
|
|
{
|
|
|
|
|
[Description("Keyboard")]
|
|
|
|
|
Keyboard,
|
2019-03-06 15:30:56 +08:00
|
|
|
|
|
2019-01-05 05:52:00 +08:00
|
|
|
|
[Description("Mouse")]
|
|
|
|
|
Mouse,
|
2019-03-06 15:30:56 +08:00
|
|
|
|
|
2019-01-05 05:52:00 +08:00
|
|
|
|
[Description("Tablet")]
|
|
|
|
|
Tablet,
|
2019-03-06 15:30:56 +08:00
|
|
|
|
|
2019-01-05 05:52:00 +08:00
|
|
|
|
[Description("Touch Screen")]
|
|
|
|
|
Touch,
|
|
|
|
|
}
|
2020-02-27 18:21:59 +08:00
|
|
|
|
|
|
|
|
|
public bool Equals(User other)
|
|
|
|
|
{
|
|
|
|
|
if (ReferenceEquals(null, other)) return false;
|
|
|
|
|
if (ReferenceEquals(this, other)) return true;
|
|
|
|
|
|
|
|
|
|
return Id == other.Id;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|