58 lines
1.1 KiB
Rust
58 lines
1.1 KiB
Rust
use std::fmt::{Display, Formatter};
|
|
|
|
use rand::thread_rng;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::config::BotConfig;
|
|
use crate::game::player_data::PlayerData;
|
|
use rand::prelude::SliceRandom;
|
|
|
|
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 occupation = &config
|
|
.game_config
|
|
.occupation
|
|
.choose(&mut thread_rng())
|
|
.unwrap();
|
|
let adj = &config
|
|
.game_config
|
|
.adjective
|
|
.choose(&mut thread_rng())
|
|
.unwrap();
|
|
|
|
format!("{} {}", adj, occupation)
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum MessageSource {
|
|
Player(Box<PlayerData>),
|
|
Host,
|
|
Automated,
|
|
}
|