An unofficial collection of APIs used in FreeJam games and mods
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.2KB

  1. use serde::{Deserialize, Serialize};
  2. #[derive(Deserialize, Serialize, Clone)]
  3. pub(crate) struct AuthenticationPayload {
  4. #[serde(rename = "EmailAddress")]
  5. pub email_address: String,
  6. #[serde(rename = "Password")]
  7. pub password: String,
  8. }
  9. /// Authentication information
  10. #[derive(Deserialize, Serialize, Clone)]
  11. pub struct AuthenticationInfo {
  12. /// User's public ID
  13. #[serde(rename = "PublicId")]
  14. pub public_id: String,
  15. /// User's email address
  16. #[serde(rename = "EmailAddress")]
  17. pub email_address: String,
  18. /// Account display name
  19. #[serde(rename = "DisplayName")]
  20. pub display_name: String,
  21. /// Account purchases (???)
  22. #[serde(rename = "Purchases")]
  23. purchases: Vec<String>, // ???
  24. /// Account flags (dev, admin, etc.???)
  25. #[serde(rename = "Flags")]
  26. flags: Vec<String>, // ???
  27. /// Is confirmed account?
  28. #[serde(rename = "Confirmed")]
  29. pub confirmed: bool,
  30. /// Temporary account token
  31. #[serde(rename = "Token")]
  32. pub token: String,
  33. /// Steam ID
  34. ///
  35. /// Since Steam users cannot be authenticated using this lib, this will always be blank or None
  36. #[serde(rename = "SteamId")]
  37. steam_id: Option<String>, // ???
  38. /// User ID
  39. #[serde(rename = "ID")]
  40. pub id: usize,
  41. }
  42. impl std::string::ToString for AuthenticationInfo {
  43. fn to_string(&self) -> String {
  44. format!("{} ({})", &self.display_name, &self.public_id)
  45. }
  46. }
  47. #[derive(Deserialize, Serialize, Clone)]
  48. pub(crate) struct LobbyPayload {
  49. #[serde(rename = "PublicId")]
  50. pub public_id: String,
  51. }
  52. /// Lobby information for available Cardlife servers
  53. #[derive(Deserialize, Serialize, Clone)]
  54. pub struct LobbyInfo {
  55. #[serde(rename = "Games")]
  56. /// Available servers' information
  57. pub games: Vec<LiveGameInfo>,
  58. }
  59. /// Server information for a single Cardlife server
  60. #[derive(Deserialize, Serialize, Clone)]
  61. pub struct LiveGameInfo {
  62. /// Server game ID
  63. #[serde(rename = "Id")]
  64. pub id: usize,
  65. /// World name
  66. #[serde(rename = "WorldName")]
  67. pub world_name: String,
  68. /// Max players
  69. #[serde(rename = "MaxPlayers")]
  70. pub max_players: usize,
  71. /// Current player count
  72. #[serde(rename = "CurrentPlayers")]
  73. pub current_players: usize,
  74. /// Server version
  75. #[serde(rename = "GameVersion")]
  76. pub game_version: String,
  77. /// Ping latency
  78. #[serde(rename = "Ping")]
  79. pub ping: usize,
  80. /// Account has already joined this server?
  81. #[serde(rename = "HasPlayed")]
  82. pub has_played: bool,
  83. /// Server is password protected?
  84. #[serde(rename = "HasPassword")]
  85. pub has_password: bool,
  86. /// PvP is enabled on this server?
  87. #[serde(rename = "IsPvp")]
  88. pub is_pvp: bool,
  89. /// EasyAntiCheat is enabled on this server?
  90. #[serde(rename = "IsAntiCheatEnabled")]
  91. pub is_anticheat_enabled: bool,
  92. /// Official server?
  93. #[serde(rename = "IsOfficial")]
  94. pub is_official: bool,
  95. /// Mods installed on this server
  96. #[serde(rename = "ModInfo")]
  97. pub mod_info: String,
  98. /// Server region
  99. #[serde(rename = "Region")]
  100. pub region: String,
  101. }
  102. impl std::string::ToString for LiveGameInfo {
  103. fn to_string(&self) -> String {
  104. format!("{} ({}):{}/{}", self.world_name, self.id, self.current_players, self.max_players)
  105. }
  106. }