Sort out some logging problems
This commit is contained in:
@ -111,7 +111,7 @@ fn route_msg(client: &mut Client, str_msg: &String) -> Result<(), ClientError> {
|
||||
info!(target: LOG_TARGET, "Watch game at {}", msg.url);
|
||||
},
|
||||
Inbound::UnrecognizedMessage => {
|
||||
|
||||
error!(target: LOG_TARGET, "Received unrecognized message {:?}", str_msg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ pub const PLAYER_REGISTERED: &'static str =
|
||||
pub const INVALID_PLAYER_NAME: &'static str =
|
||||
"se.cygni.snake.api.exception.InvalidPlayerName";
|
||||
pub const HEART_BEAT_RESPONSE: &'static str =
|
||||
"se.cygni.snake.api.request.HeartBeatResponse";
|
||||
"se.cygni.snake.api.response.HeartBeatResponse";
|
||||
pub const GAME_LINK_EVENT: &'static str =
|
||||
"se.cygni.snake.api.event.GameLinkEvent";
|
||||
|
||||
|
||||
12
src/snake.rs
12
src/snake.rs
@ -17,14 +17,14 @@ impl Snake {
|
||||
}
|
||||
|
||||
pub fn get_next_move(&self, msg: &MapUpdate) -> Direction {
|
||||
info!(target: LOG_TARGET, "Game map updated, tick: {}", msg.gameTick);
|
||||
debug!(target: LOG_TARGET, "Game map updated, tick: {}", msg.gameTick);
|
||||
|
||||
let ref map = msg.map;
|
||||
let player_id = &msg.receivingPlayerId;
|
||||
let snake = map.get_snake_by_id(player_id).unwrap();
|
||||
|
||||
info!(target: LOG_TARGET, "Food can be found at {:?}", translate_positions(&map.foodPositions, map.width));
|
||||
info!(target: LOG_TARGET, "My snake positions are {:?}", translate_positions(&snake.positions, map.width));
|
||||
debug!(target: LOG_TARGET, "Food can be found at {:?}", translate_positions(&map.foodPositions, map.width));
|
||||
debug!(target: LOG_TARGET, "My snake positions are {:?}", translate_positions(&snake.positions, map.width));
|
||||
|
||||
let direction = if map.can_snake_move_in_direction(snake, Direction::Down) {
|
||||
Direction::Down
|
||||
@ -44,15 +44,15 @@ impl Snake {
|
||||
}
|
||||
|
||||
pub fn on_game_ended(&self, msg: &GameEnded) {
|
||||
info!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId);
|
||||
debug!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId);
|
||||
}
|
||||
|
||||
pub fn on_tournament_ended(&self, msg: &TournamentEnded) {
|
||||
info!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId);
|
||||
debug!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId);
|
||||
}
|
||||
|
||||
pub fn on_snake_dead(&self, msg: &SnakeDead) {
|
||||
info!(target: LOG_TARGET, "The snake died, reason was: {:?}", msg.deathReason);
|
||||
debug!(target: LOG_TARGET, "The snake died, reason was: {:?}", msg.deathReason);
|
||||
}
|
||||
|
||||
pub fn on_game_starting(&self, _: &GameStarting) {
|
||||
|
||||
@ -142,8 +142,6 @@ pub struct TournamentEnded {
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Map {
|
||||
#[serde(rename="type")]
|
||||
pub type_: String,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub worldTick: u32,
|
||||
|
||||
Reference in New Issue
Block a user