From 83d078095405cbdc362fcb0db47cdaab98ed7f03 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Tue, 18 Oct 2022 09:17:15 +0200 Subject: [PATCH] Add a route to get default rules --- rust/sea_battle_backend/src/server.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/sea_battle_backend/src/server.rs b/rust/sea_battle_backend/src/server.rs index a0e7e25..a255d8d 100644 --- a/rust/sea_battle_backend/src/server.rs +++ b/rust/sea_battle_backend/src/server.rs @@ -28,6 +28,11 @@ async fn game_configuration() -> impl Responder { HttpResponse::Ok().json(PlayConfiguration::default()) } +/// Get default game rules +async fn default_rules() -> impl Responder { + HttpResponse::Ok().json(GameRules::random_players_rules()) +} + #[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug)] pub struct BotPlayQuery { #[serde(flatten)] @@ -155,6 +160,7 @@ pub async fn start_server(args: Args) -> std::io::Result<()> { .wrap(cors) .route("/version", web::get().to(version_information)) .route("/config", web::get().to(game_configuration)) + .route("/default_rules", web::get().to(default_rules)) .route("/play/bot", web::get().to(start_bot_play)) .route("/play/create_invite", web::get().to(start_create_invite)) .route("/play/accept_invite", web::get().to(start_accept_invite))