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.

clre_server.rs 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. use libfj::cardlife;
  2. #[test]
  3. fn clre_server_init() -> Result<(), ()> {
  4. assert!(cardlife::CLreServer::new("http://localhost:5030").is_ok());
  5. Ok(())
  6. }
  7. #[tokio::test]
  8. async fn clre_server_game() -> Result<(), ()> {
  9. let server = cardlife::CLreServer::new("http://localhost:5030").unwrap();
  10. let result = server.game_info().await;
  11. assert!(result.is_ok());
  12. let game_info = result.unwrap();
  13. assert_eq!(game_info.admin_password, "");
  14. assert_eq!(game_info.game_host_type, 1);
  15. println!("GameInfo.to_string() -> `{}`", game_info.to_string());
  16. Ok(())
  17. }
  18. #[tokio::test]
  19. async fn clre_server_status() -> Result<(), ()> {
  20. let server = cardlife::CLreServer::new("http://localhost:5030").unwrap();
  21. let result = server.status_info().await;
  22. assert!(result.is_ok());
  23. let status_info = result.unwrap();
  24. assert_eq!(status_info.status, "Online");
  25. assert_eq!(status_info.max_players, 10);
  26. assert_eq!(status_info.player_count, status_info.online_players.len());
  27. if status_info.online_players.len() != 0 {
  28. for player in &status_info.online_players {
  29. assert_ne!(player.name, "");
  30. assert_ne!(player.id, "");
  31. assert!(!player.is_dev);
  32. println!("PlayerStatusInfo.to_string() -> `{}`", player.to_string());
  33. }
  34. }
  35. Ok(())
  36. }