use actix::Addr; use uuid::Uuid; use crate::data::{BoatsLayout, GameRules}; use crate::game::{Game, Player, SetBoatsLayout}; #[derive(Clone)] pub struct RandomBot { game: Addr, uuid: Uuid, } impl RandomBot { pub fn new(game: Addr) -> Self { Self { game, uuid: Uuid::new_v4(), } } } impl Player for RandomBot { fn get_name(&self) -> &str { "Random Bot" } fn get_uid(&self) -> Uuid { self.uuid } fn query_boats_layout(&self, rules: &GameRules) { match BoatsLayout::gen_random_for_rules(rules) { Ok(layout) => self.game.do_send(SetBoatsLayout(self.uuid, layout)), Err(e) => log::error!( "Failed to use game rules to construct boats layout: {:?}", e ), } } fn notify_other_player_ready(&self) {} fn notify_game_starting(&self) {} }