// 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 . use core::fmt::Display; use serde::{Deserialize, Serialize}; use crate::{ character::CharacterId, role::{Role, RoleTitle}, }; #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)] 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 }, Vindicator { source: CharacterId }, } #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum KillOutcome { Killed, Failed, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct RoleChange { pub role: Role, pub new_role: RoleTitle, pub changed_on_night: u8, }