Can notify a player that the server is waiting for opponent play configuration
This commit is contained in:
		@@ -58,6 +58,8 @@ impl Player for BotPlayer {
 | 
			
		||||
        unreachable!()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn waiting_for_opponent_boats_layout(&self) {}
 | 
			
		||||
 | 
			
		||||
    fn notify_other_player_ready(&self) {}
 | 
			
		||||
 | 
			
		||||
    fn notify_game_starting(&self) {}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,8 @@ pub trait Player {
 | 
			
		||||
 | 
			
		||||
    fn rejected_boats_layout(&self, errors: Vec<&'static str>);
 | 
			
		||||
 | 
			
		||||
    fn waiting_for_opponent_boats_layout(&self);
 | 
			
		||||
 | 
			
		||||
    fn notify_other_player_ready(&self);
 | 
			
		||||
 | 
			
		||||
    fn notify_game_starting(&self);
 | 
			
		||||
@@ -294,6 +296,8 @@ impl Handler<SetBoatsLayout> for Game {
 | 
			
		||||
        if self.map_0.is_some() && self.map_1.is_some() {
 | 
			
		||||
            self.players.iter().for_each(|p| p.notify_game_starting());
 | 
			
		||||
            self.start_fire_exchanges();
 | 
			
		||||
        } else {
 | 
			
		||||
            self.players[player_index].waiting_for_opponent_boats_layout();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,11 @@ impl Player for HumanPlayer {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn waiting_for_opponent_boats_layout(&self) {
 | 
			
		||||
        self.player
 | 
			
		||||
            .do_send(ServerMessage::WaitingForOtherPlayerConfiguration);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn notify_other_player_ready(&self) {
 | 
			
		||||
        self.player.do_send(ServerMessage::OpponentReady);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user