2025-10-06 20:45:15 +01:00
|
|
|
use core::fmt::Display;
|
2025-06-23 09:48:28 +01:00
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
use crate::{
|
2025-10-06 20:45:15 +01:00
|
|
|
character::CharacterId,
|
|
|
|
|
role::{Role, RoleTitle},
|
2025-06-23 09:48:28 +01:00
|
|
|
};
|
|
|
|
|
|
2025-10-05 10:52:37 +01:00
|
|
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
2025-06-23 09:48:28 +01:00
|
|
|
pub struct PlayerId(uuid::Uuid);
|
|
|
|
|
|
|
|
|
|
impl PlayerId {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self(uuid::Uuid::new_v4())
|
|
|
|
|
}
|
|
|
|
|
pub const fn from_u128(v: u128) -> Self {
|
|
|
|
|
Self(uuid::Uuid::from_u128(v))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Display for PlayerId {
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
self.0.fmt(f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
|
pub struct Player {
|
|
|
|
|
id: PlayerId,
|
|
|
|
|
name: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Player {
|
|
|
|
|
pub fn new(name: String) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
id: PlayerId::new(),
|
|
|
|
|
name,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
|
|
|
pub enum Protection {
|
|
|
|
|
Guardian { source: CharacterId, guarding: bool },
|
|
|
|
|
Protector { source: CharacterId },
|
2025-10-06 20:45:15 +01:00
|
|
|
Vindicator { source: CharacterId },
|
2025-06-23 09:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
|
|
|
|
pub enum KillOutcome {
|
|
|
|
|
Killed,
|
|
|
|
|
Failed,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-07 21:18:31 +01:00
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
2025-10-04 17:50:29 +01:00
|
|
|
pub struct RoleChange {
|
2025-10-06 20:45:15 +01:00
|
|
|
pub role: Role,
|
|
|
|
|
pub new_role: RoleTitle,
|
|
|
|
|
pub changed_on_night: u8,
|
2025-06-23 09:48:28 +01:00
|
|
|
}
|