/
Player.cs
62 lines (52 loc) · 1.79 KB
/
Player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using SteamQueryNet.Attributes;
using SteamQueryNet.Models.TheShip;
using System;
namespace SteamQueryNet.Models
{
public class Player
{
/// <summary>
/// Index of player chunk starting from 0.
/// </summary>
public byte Index { get; set; }
/// <summary>
/// Name of the player.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Player's score (usually "frags" or "kills".)
/// </summary>
public int Score { get; set; }
/// <summary>
/// Time (in seconds) player has been connected to the server.
/// </summary>
public float Duration { get; set; }
/// <summary>
/// Total time as Hours:Minutes:Seconds format.
/// </summary>
[NotParsable]
public string TotalDurationAsString
{
get
{
TimeSpan totalSpan = TimeSpan.FromSeconds(Duration);
string parsedHours = totalSpan.Hours >= 10
? totalSpan.Hours.ToString()
: $"0{totalSpan.Hours}";
string parsedMinutes = totalSpan.Minutes >= 10
? totalSpan.Minutes.ToString()
: $"0{totalSpan.Minutes}";
string parsedSeconds = totalSpan.Seconds >= 10
? totalSpan.Seconds.ToString()
: $"0{totalSpan.Seconds}";
return $"{parsedHours}:{parsedMinutes}:{parsedSeconds}";
}
}
/// <summary>
/// The Ship additional player info.
/// </summary>
/// Warning: this property information is not supported by SteamQueryNet yet.
[ParseCustom]
public ShipPlayerDetails ShipPlayerDetails { get; set; }
}
}