2025-11-05 20:24:51 +00:00
|
|
|
// Copyright (C) 2025 Emilis Bliūdžius
|
|
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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
|
|
|
}
|