39 lines
764 B
Rust
39 lines
764 B
Rust
use serde::{Deserialize, Serialize};
|
|
use crate::GeoffreyDatabaseModel;
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub enum UserID {
|
|
DiscordUUID(u64),
|
|
MinecraftUUID(String),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct Player {
|
|
pub id: Option<u64>,
|
|
pub name: String,
|
|
pub user_ids: Vec<UserID>
|
|
}
|
|
|
|
impl Player {
|
|
pub fn new(name: &str, user_id: UserID) -> Self {
|
|
Self {
|
|
id: None,
|
|
name: name.to_string(),
|
|
user_ids: vec![user_id]
|
|
}
|
|
}
|
|
}
|
|
|
|
impl GeoffreyDatabaseModel for Player {
|
|
fn id(&self) -> Option<u64> {
|
|
self.id
|
|
}
|
|
|
|
fn set_id(&mut self, id: u64) {
|
|
self.id = Some(id);
|
|
}
|
|
|
|
fn tree() -> String {
|
|
"player".to_string()
|
|
}
|
|
} |