Applied cargo fmt

This commit is contained in:
Christoffer Lantz 2019-07-26 16:38:31 +02:00
parent 71347b5d11
commit 14bee47e58

View File

@ -3,19 +3,20 @@
//! and provide a handler function.
use crate::Server;
use chrono::{NaiveTime, Timelike};
use common::{
comp,
msg::ServerMsg,
npc::{get_npc_name, NpcKind},
state::TimeOfDay,
};
use chrono::{NaiveTime, Timelike};
use rand::Rng;
use specs::{Builder, Entity as EcsEntity, Join};
use vek::*;
use lazy_static::lazy_static;
use scan_fmt::scan_fmt;
/// Struct representing a command that a user can run from server chat.
pub struct ChatCommand {
/// The keyword used to invoke the command, omitting the leading '/'.
@ -210,8 +211,7 @@ fn handle_kill(server: &mut Server, entity: EcsEntity, _args: String, _action: &
fn handle_time(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) {
let time = scan_fmt!(&args, action.arg_fmt, String);
let new_time = match time.as_ref().map(|s| s.as_str())
{
let new_time = match time.as_ref().map(|s| s.as_str()) {
Some("night") => NaiveTime::from_hms(0, 0, 0),
Some("dawn") => NaiveTime::from_hms(5, 0, 0),
Some("day") => NaiveTime::from_hms(12, 0, 0),
@ -221,12 +221,13 @@ fn handle_time(server: &mut Server, entity: EcsEntity, args: String, action: &Ch
Err(_) => match NaiveTime::parse_from_str(n, "%H:%M") {
Ok(time) => time,
Err(_) => {
server
.clients
.notify(entity, ServerMsg::private(format!("'{}' is not a valid time.", n)));
server.clients.notify(
entity,
ServerMsg::private(format!("'{}' is not a valid time.", n)),
);
return;
}
}
},
},
None => {
server.clients.notify(
@ -237,11 +238,15 @@ fn handle_time(server: &mut Server, entity: EcsEntity, args: String, action: &Ch
}
};
server.state.ecs_mut().write_resource::<TimeOfDay>().0 = new_time.num_seconds_from_midnight() as f64;
server.state.ecs_mut().write_resource::<TimeOfDay>().0 =
new_time.num_seconds_from_midnight() as f64;
server.clients.notify(
entity,
ServerMsg::private(format!("Time changed to: {}", new_time.format("%H:%M").to_string()))
ServerMsg::private(format!(
"Time changed to: {}",
new_time.format("%H:%M").to_string()
)),
);
}
@ -579,6 +584,7 @@ fn handle_light(server: &mut Server, entity: EcsEntity, args: String, action: &C
.notify(entity, ServerMsg::chat(format!("You have no position!")));
}
}
fn handle_lantern(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) {
if server
.state
@ -615,6 +621,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, _args: String, _action
);
}
}
fn handle_tell(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) {
let opt_alias = scan_fmt!(&args, action.arg_fmt, String);
match opt_alias {