use crate::model::{prelude::*, user::AchievementRatingCounts};
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct Leaderboard {
pub entries: Vec<LeaderboardUser>,
}
impl AsRef<Leaderboard> for Leaderboard {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct LeaderboardUser {
#[serde(rename = "_id")]
pub id: UserId,
pub username: String,
pub role: Role,
#[serde(rename = "ts")]
pub created_at: Option<Timestamp>,
pub xp: f64,
pub country: Option<String>,
#[serde(rename = "supporter")]
#[serde(default)] pub is_supporter: bool,
pub league: PartialLeagueData,
#[serde(rename = "gamesplayed")]
pub online_games_played: i32,
#[serde(rename = "gameswon")]
pub online_games_won: i32,
#[serde(rename = "gametime")]
pub game_time: f64,
#[serde(rename = "ar")]
pub achievement_rating: i32,
#[serde(rename = "ar_counts")]
pub achievement_rating_counts: AchievementRatingCounts,
#[serde(rename = "p")]
pub prisecter: Prisecter,
}
impl LeaderboardUser {
impl_get_user!(id);
impl_for_xp!();
impl_for_username!();
impl_for_role!();
impl_for_account_created_at!();
impl_for_country!();
}
impl AsRef<LeaderboardUser> for LeaderboardUser {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct PartialLeagueData {
#[serde(rename = "gamesplayed")]
pub games_played: u32,
#[serde(rename = "gameswon")]
pub games_won: u32,
pub tr: f64,
pub gxe: f64,
pub rank: Rank,
#[serde(rename = "bestrank")]
pub best_rank: Option<Rank>,
pub glicko: f64,
pub rd: Option<f64>,
pub apm: Option<f64>,
pub pps: Option<f64>,
pub vs: Option<f64>,
#[serde(rename = "decaying")]
pub is_decaying: bool,
}
impl AsRef<PartialLeagueData> for PartialLeagueData {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct HistoricalLeaderboard {
pub entries: Vec<PastUserWithPrisecter>,
}
impl AsRef<HistoricalLeaderboard> for HistoricalLeaderboard {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct PastUserWithPrisecter {
#[serde(rename = "_id")]
pub id: UserId,
pub season: String,
pub username: String,
pub country: Option<String>,
pub placement: i32,
#[serde(rename = "ranked")]
pub is_ranked: bool,
#[serde(rename = "gamesplayed")]
pub games_played: u32,
#[serde(rename = "gameswon")]
pub games_won: u32,
pub glicko: f64,
pub rd: f64,
pub tr: f64,
pub gxe: f64,
pub rank: Rank,
#[serde(rename = "bestrank")]
pub best_rank: Option<Rank>,
pub apm: f64,
pub pps: f64,
pub vs: f64,
#[serde(rename = "p")]
pub prisecter: Prisecter,
}
impl PastUserWithPrisecter {
impl_get_user!(id);
impl_for_country!();
}
impl AsRef<PastUserWithPrisecter> for PastUserWithPrisecter {
fn as_ref(&self) -> &Self {
self
}
}