parent
cc10e5001f
commit
faadf904e0
@ -0,0 +1,24 @@
|
|||||||
|
use mio::Token;
|
||||||
|
|
||||||
|
use crate::command::CommandSetPlayer;
|
||||||
|
use crate::database::Db;
|
||||||
|
use crate::queue::SendQueue;
|
||||||
|
use crate::{try_option_send_error, try_send_error};
|
||||||
|
|
||||||
|
impl CommandSetPlayer {
|
||||||
|
/// Set the player's password
|
||||||
|
pub fn dispatch_password(&self, args: String, token: Token, db: &mut Db) -> SendQueue {
|
||||||
|
let mut player = try_option_send_error!(token, db.get_connected_player(token));
|
||||||
|
|
||||||
|
if args.is_empty() {
|
||||||
|
return SendQueue(vec![(token, "Password can't be empty".into(), true, None)].into());
|
||||||
|
}
|
||||||
|
|
||||||
|
player.password = args;
|
||||||
|
|
||||||
|
let _ = try_send_error!(token, db.save_player(&player));
|
||||||
|
let _ = try_send_error!(token, db.save_connected_player(token, &player));
|
||||||
|
|
||||||
|
SendQueue::ok(token)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue