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
use types::{Level, Player, Position, Score};

/// Leaderboard data, part of the [`ScoreBoard`] packet.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreBoardData {
	pub id: Player,
	pub score: Score,
	pub level: Level,
}

/// Low-res player positions, part of the
/// [`ScoreBoard`] packet.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreBoardRanking {
	pub id: Player,
	pub pos: Option<Position>,
}

/// Leaderboard + Global player positions
///
/// This is sent every 5 seconds by the
/// server and is used by the client to
/// update the leaderboard and minimap.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreBoard {
	pub data: Vec<ScoreBoardData>,
	pub rankings: Vec<ScoreBoardRanking>,
}