forked from cadey/pneuma
format the code i modified
This commit is contained in:
parent
45e5505c9c
commit
2af22fc7d2
11
src/main.rs
11
src/main.rs
|
@ -72,7 +72,10 @@ fn find_path(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/move", format = "json", data = "<msg>")]
|
#[post("/move", format = "json", data = "<msg>")]
|
||||||
fn make_move(cache_state: State<Cache>, msg: Json<battlesnake::SnakeRequest>) -> Json<battlesnake::MoveResponse> {
|
fn make_move(
|
||||||
|
cache_state: State<Cache>,
|
||||||
|
msg: Json<battlesnake::SnakeRequest>,
|
||||||
|
) -> Json<battlesnake::MoveResponse> {
|
||||||
let head = msg.you.body[0];
|
let head = msg.you.body[0];
|
||||||
|
|
||||||
let mut cache = cache_state.lock().expect("wanted cache to be unlockable");
|
let mut cache = cache_state.lock().expect("wanted cache to be unlockable");
|
||||||
|
@ -88,12 +91,14 @@ fn make_move(cache_state: State<Cache>, msg: Json<battlesnake::SnakeRequest>) ->
|
||||||
Json(battlesnake::MoveResponse {
|
Json(battlesnake::MoveResponse {
|
||||||
move_field: "up".to_string(),
|
move_field: "up".to_string(),
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
Some(next) => Json(battlesnake::MoveResponse {
|
Some(next) => Json(battlesnake::MoveResponse {
|
||||||
move_field: battlesnake::Line {
|
move_field: battlesnake::Line {
|
||||||
start: &head,
|
start: &head,
|
||||||
end: &next,
|
end: &next,
|
||||||
}.direction().to_string(),
|
}
|
||||||
|
.direction()
|
||||||
|
.to_string(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue