51 lines
1.0 KiB
Rust
51 lines
1.0 KiB
Rust
use std::fmt::{Display, Formatter};
|
|
|
|
use rand::Rng;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::config::BotConfig;
|
|
use crate::game::player_data::PlayerData;
|
|
|
|
pub mod game_state;
|
|
pub mod global_data;
|
|
pub mod player_data;
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq, Copy)]
|
|
pub enum Phase {
|
|
Day,
|
|
Night,
|
|
}
|
|
|
|
impl Default for Phase {
|
|
fn default() -> Self {
|
|
Self::Night
|
|
}
|
|
}
|
|
|
|
impl Display for Phase {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
let phase_name = match self {
|
|
Self::Day => "Day",
|
|
Self::Night => "Night",
|
|
};
|
|
|
|
write!(f, "{}", phase_name)
|
|
}
|
|
}
|
|
|
|
pub fn generate_codename(config: &BotConfig) -> String {
|
|
let mut rng = rand::thread_rng();
|
|
|
|
let occupation = &config.occupation[rng.gen_range(0..config.occupation.len())];
|
|
let adj = &config.adjective[rng.gen_range(0..config.adjective.len())];
|
|
|
|
format!("{} {}", adj, occupation)
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum MessageSource {
|
|
Player(Box<PlayerData>),
|
|
Host,
|
|
Automated,
|
|
}
|