2021-10-23 19:13:28 +00:00
|
|
|
use crate::models::locations::LocationType;
|
2021-10-24 19:21:30 +00:00
|
|
|
use crate::models::parameters::CommandRequest;
|
|
|
|
use crate::models::player::UserID;
|
2021-12-05 23:51:13 +00:00
|
|
|
use crate::models::{Position, Portal};
|
2021-10-03 20:03:32 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct AddLocationParams {
|
2021-10-31 17:00:07 +00:00
|
|
|
pub token: String,
|
|
|
|
pub user_id: UserID,
|
2021-10-03 20:03:32 +00:00
|
|
|
pub name: String,
|
|
|
|
pub position: Position,
|
|
|
|
pub loc_type: LocationType,
|
2021-12-05 23:51:13 +00:00
|
|
|
pub portal: Option<Portal>,
|
2021-10-03 20:03:32 +00:00
|
|
|
}
|
2021-10-24 19:20:15 +00:00
|
|
|
|
2021-12-01 04:13:56 +00:00
|
|
|
impl AddLocationParams {
|
|
|
|
pub fn new(
|
|
|
|
name: String,
|
|
|
|
position: Position,
|
|
|
|
loc_type: LocationType,
|
2021-12-05 23:51:13 +00:00
|
|
|
portal: Option<Portal>,
|
2021-12-01 04:13:56 +00:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
token: Default::default(),
|
|
|
|
user_id: Default::default(),
|
|
|
|
name,
|
|
|
|
position,
|
|
|
|
loc_type,
|
2021-12-05 23:51:13 +00:00
|
|
|
portal,
|
2021-12-01 04:13:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-24 19:20:15 +00:00
|
|
|
impl CommandRequest for AddLocationParams {
|
2021-10-31 17:00:07 +00:00
|
|
|
fn token(&self) -> String {
|
|
|
|
self.token.clone()
|
2021-10-24 19:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn user_id(&self) -> Option<UserID> {
|
|
|
|
Some(self.user_id.clone())
|
|
|
|
}
|
2021-12-01 04:13:56 +00:00
|
|
|
|
|
|
|
fn set_user_id(&mut self, user_id: UserID) {
|
|
|
|
self.user_id = user_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_token(&mut self, token: String) {
|
|
|
|
self.token = token;
|
|
|
|
}
|
2021-10-24 19:20:15 +00:00
|
|
|
}
|