Added new roles
parent
b91223d6ed
commit
fa7d78c272
|
@ -43,10 +43,14 @@ pub enum Role {
|
|||
Jester,
|
||||
Mason,
|
||||
Shepard,
|
||||
Dreamer,
|
||||
ApprenticeSeer,
|
||||
// Wolf Roles
|
||||
MasterWolf,
|
||||
WolfShaman,
|
||||
Wolf,
|
||||
WolfAgent,
|
||||
WolfDreamer,
|
||||
// Custom Role
|
||||
Custom(String, RoleColor),
|
||||
}
|
||||
|
@ -72,6 +76,10 @@ impl Display for Role {
|
|||
Role::WolfShaman => "Wolf Shaman",
|
||||
Role::Wolf => "Wolf",
|
||||
Role::Custom(role_name, _) => role_name,
|
||||
Role::Dreamer => "Dreamer",
|
||||
Role::ApprenticeSeer => "Apprentice Seer",
|
||||
Role::WolfAgent => "Wolf Agent",
|
||||
Role::WolfDreamer => "Wolf Dreamer",
|
||||
};
|
||||
|
||||
write!(f, "{}", s)
|
||||
|
@ -92,14 +100,18 @@ impl Role {
|
|||
Role::Psychic => RoleColor::Blue,
|
||||
Role::Miller => RoleColor::Red,
|
||||
Role::Herring => RoleColor::Blue,
|
||||
Role::Spy => RoleColor::Blue,
|
||||
Role::Spy => RoleColor::Green,
|
||||
Role::Jester => RoleColor::Purple,
|
||||
Role::Mason => RoleColor::Green,
|
||||
Role::Shepard => RoleColor::Green,
|
||||
Role::MasterWolf => RoleColor::Green,
|
||||
Role::WolfShaman => RoleColor::Red,
|
||||
Role::Wolf => RoleColor::Red,
|
||||
Role::Dreamer => RoleColor::Red,
|
||||
Role::Custom(_, color) => color.clone(),
|
||||
Role::ApprenticeSeer => RoleColor::Blue,
|
||||
Role::WolfAgent => RoleColor::Red,
|
||||
Role::WolfDreamer =>RoleColor::Red,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +119,7 @@ impl Role {
|
|||
pub fn player_color(&self) -> RoleColor {
|
||||
match self {
|
||||
Role::Miller => RoleColor::Green,
|
||||
Role::Herring => RoleColor::Green,
|
||||
_ => self.seer_color(),
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +128,7 @@ impl Role {
|
|||
pub fn player_role_name(&self) -> String {
|
||||
match self {
|
||||
Role::Miller => Role::Villager.to_string(),
|
||||
Role::Herring => Role::Villager.to_string(),
|
||||
_ => self.to_string(),
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +136,8 @@ impl Role {
|
|||
pub fn register_role_listener(&self, listeners: &mut Listeners) {
|
||||
#[allow(clippy::single_match)]
|
||||
match self {
|
||||
Role::Spy => listeners.add_listener(Box::new(SpyListener {})),
|
||||
Role::Spy => listeners.add_listener(Box::new(SpyListener {role: Role::Spy})),
|
||||
Role::WolfAgent => listeners.add_listener(Box::new(SpyListener {role: Role::WolfAgent})),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ use serenity::model::prelude::UserId;
|
|||
use serenity::utils::MessageBuilder;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SpyListener {}
|
||||
pub struct SpyListener {
|
||||
pub role: Role
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Listener for SpyListener {
|
||||
|
@ -43,7 +45,7 @@ impl Listener for SpyListener {
|
|||
.game_state()?
|
||||
.player_data
|
||||
.iter()
|
||||
.find(|p| p.alive && p.role == Role::Spy);
|
||||
.find(|p| p.alive && p.role == self.role);
|
||||
|
||||
if let Some(spy_player) = spy_player {
|
||||
if spy_player.discord_id == dest_player.discord_id
|
||||
|
|
Loading…
Reference in New Issue