77 lines
1.9 KiB
Rust
77 lines
1.9 KiB
Rust
// 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/>.
|
|
pub mod host;
|
|
mod ident;
|
|
pub mod night;
|
|
|
|
use core::num::NonZeroU8;
|
|
|
|
pub use ident::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{
|
|
character::CharacterId,
|
|
game::{GameOver, story::GameStory},
|
|
role::RoleTitle,
|
|
};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
pub enum ClientMessage {
|
|
Hello,
|
|
Goodbye,
|
|
GetState,
|
|
RoleAck,
|
|
UpdateSelf(UpdateSelf),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
pub enum UpdateSelf {
|
|
Name(String),
|
|
Number(NonZeroU8),
|
|
Pronouns(Option<String>),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct DayCharacter {
|
|
pub character_id: CharacterId,
|
|
pub name: String,
|
|
pub alive: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum ServerMessage {
|
|
Disconnect,
|
|
LobbyInfo {
|
|
joined: bool,
|
|
players: Box<[PublicIdentity]>,
|
|
},
|
|
GameInProgress,
|
|
GameStart {
|
|
role: RoleTitle,
|
|
},
|
|
InvalidMessageForGameState,
|
|
NoSuchTarget,
|
|
GameOver(GameOver),
|
|
Story(GameStory),
|
|
Update(PlayerUpdate),
|
|
Sleep,
|
|
Reset,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum PlayerUpdate {
|
|
Number(NonZeroU8),
|
|
}
|