Reorganize routes
This commit is contained in:
parent
4fb952a59f
commit
c0b6067d34
@ -1,7 +1,7 @@
|
||||
use crate::data::GameRules;
|
||||
use actix::Addr;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::data::GameRules;
|
||||
use crate::game::{Game, Player};
|
||||
use crate::human_player_ws::{ClientMessage, HumanPlayerWS, ServerMessage};
|
||||
|
||||
@ -22,8 +22,9 @@ impl Player for HumanPlayer {
|
||||
}
|
||||
|
||||
fn query_boats_layout(&self, rules: &GameRules) {
|
||||
self.player
|
||||
.do_send(ServerMessage::QueryBoatsLayout(rules.clone()));
|
||||
self.player.do_send(ServerMessage::QueryBoatsLayout {
|
||||
rules: rules.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ pub enum ClientMessage {
|
||||
#[serde(tag = "type")]
|
||||
pub enum ServerMessage {
|
||||
WaitingForOtherPlayer,
|
||||
QueryBoatsLayout(GameRules),
|
||||
QueryBoatsLayout { rules: GameRules },
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
12
src/main.rs
12
src/main.rs
@ -31,7 +31,7 @@ async fn not_found() -> impl Responder {
|
||||
}
|
||||
|
||||
/// Get bot configuration
|
||||
async fn bot_configuration() -> impl Responder {
|
||||
async fn game_configuration() -> impl Responder {
|
||||
HttpResponse::Ok().json(PlayConfiguration::default())
|
||||
}
|
||||
|
||||
@ -54,11 +54,6 @@ async fn start_bot_play(
|
||||
resp
|
||||
}
|
||||
|
||||
/// Random play configuration
|
||||
async fn random_play_config() -> impl Responder {
|
||||
HttpResponse::Ok().json(GameRules::random_players_rules())
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||
@ -76,9 +71,8 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
App::new()
|
||||
.wrap(cors)
|
||||
.route("/bot/config", web::get().to(bot_configuration))
|
||||
.route("/bot/play", web::get().to(start_bot_play))
|
||||
.route("/random/config", web::get().to(random_play_config))
|
||||
.route("/config", web::get().to(game_configuration))
|
||||
.route("/play/bot", web::get().to(start_bot_play))
|
||||
.route("/", web::get().to(index))
|
||||
.route("{tail:.*}", web::get().to(not_found))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user