few updates

This commit is contained in:
2025-03-17 11:54:45 +01:00
parent 2eaa843016
commit 73653723ea
4 changed files with 44 additions and 9 deletions
+24 -3
View File
@@ -1,6 +1,9 @@
use mongodb::bson::doc;
use crate::response::{Response, Result};
use crate::{
database::Player,
response::{Response, Result},
};
use super::Session;
@@ -12,11 +15,29 @@ pub fn player(session: &Session, uuid: String) -> Result {
"uuid": uuid.clone(),
})
.run()?
.deserialize_current()
.unwrap();
.deserialize_current()?;
Ok(Response::Player {
cloak: player.cloak,
uuid,
cloaks: player.cloaks,
})
}
pub fn create(session: &Session) -> Result {
let uuid = session.local_player.id.clone();
let player = Player {
cloak: "".to_string(),
cloaks: Vec::new(),
uuid: uuid.clone(),
};
session.database.players.insert_one(player.clone()).run()?;
Ok(Response::Player {
cloak: player.cloak,
uuid,
cloaks: player.cloaks,
})
}