-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
38 lines (30 loc) · 1.36 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
namespace liveorlive_server {
// Internal server representation of player data
public class Player(string username, bool inGame = false, bool isSpectator = false) {
public const int DEFAULT_LIVES = 5;
// TODO random amount of items per round
public const int ITEM_COUNT = 4;
public string username = username;
public bool inGame = inGame;
public bool isSpectator = isSpectator;
public int lives = DEFAULT_LIVES;
public List<Item> items = new(ITEM_COUNT);
public bool isSkipped = false;
public readonly long joinTime = (long)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
public void SetItems(List<Item> items) {
this.items = items;
}
public override bool Equals(object? obj) {
return obj is Player other && this.Equals(other);
}
public bool Equals(Player player) {
return this.username == player.username;
}
public override string ToString() {
return $"Player {{ username = \"{this.username}\", lives = {this.lives}, inGame = {this.inGame}, isSpectator = {this.isSpectator}, isSkipped = {this.isSkipped}, items = [{string.Join(", ", this.items)}] }}";
}
public override int GetHashCode() {
throw new NotImplementedException();
}
}
}