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.

86 lines
2.3KB

  1. use serde::{Deserialize, Serialize};
  2. /// CLre game info
  3. #[derive(Deserialize, Serialize, Clone)]
  4. pub struct GameInfo {
  5. /// Max allowed player count
  6. #[serde(rename = "MaxPlayers")]
  7. pub max_players: usize,
  8. /// Server world ID
  9. #[serde(rename = "GameId")]
  10. pub game_id: usize,
  11. /// Server world GUID
  12. #[serde(rename = "GameGuid")]
  13. pub game_guid: String,
  14. /// World name
  15. #[serde(rename = "WorldName")]
  16. pub world_name: String,
  17. /// Game host type
  18. #[serde(rename = "GameHostType")]
  19. pub game_host_type: usize,
  20. /// Is PvP enabled?
  21. #[serde(rename = "PvP")]
  22. pub pvp: bool,
  23. /// Photon server region override
  24. #[serde(rename = "PhotonRegionOverride")]
  25. pub photon_region_override: String,
  26. /// Server password
  27. #[serde(rename = "ServerPassword")]
  28. pub server_password: String,
  29. /// Admin priviledge password
  30. #[serde(rename = "AdminPassword")]
  31. pub admin_password: String,
  32. }
  33. impl std::string::ToString for GameInfo {
  34. fn to_string(&self) -> String {
  35. format!("{} ({})", &self.world_name, &self.game_guid)
  36. }
  37. }
  38. /// CLre_server status information
  39. #[derive(Deserialize, Serialize, Clone)]
  40. pub struct StatusInfo {
  41. /// Maximum player count
  42. #[serde(rename = "PlayersMax")]
  43. pub max_players: usize,
  44. /// Current player count
  45. #[serde(rename = "PlayerCount")]
  46. pub player_count: usize,
  47. /// Server status (enum as string)
  48. #[serde(rename = "Status")]
  49. pub status: String,
  50. /// Information on all online players in this server
  51. #[serde(rename = "OnlinePlayers")]
  52. pub online_players: Vec<PlayerStatusInfo>
  53. }
  54. /// A single online player's information
  55. #[derive(Deserialize, Serialize, Clone)]
  56. pub struct PlayerStatusInfo {
  57. /// Player public ID
  58. #[serde(rename = "id")]
  59. pub id: String,
  60. /// Player name
  61. #[serde(rename = "name")]
  62. pub name: String,
  63. /// Is the player a developer?
  64. #[serde(rename = "isDev")]
  65. pub is_dev: bool,
  66. /// Player's location on x-axis
  67. #[serde(rename = "x")]
  68. pub x: f32,
  69. /// Player's location on y-axis
  70. #[serde(rename = "y")]
  71. pub y: f32,
  72. /// Player's location on z-axis
  73. #[serde(rename = "z")]
  74. pub z: f32,
  75. }
  76. impl std::string::ToString for PlayerStatusInfo {
  77. fn to_string(&self) -> String {
  78. format!("{} ({})", &self.name, &self.id)
  79. }
  80. }