werewolves/werewolves-proto/src/message/night.rs

131 lines
3.5 KiB
Rust
Raw Normal View History

use serde::{Deserialize, Serialize};
use werewolves_macros::ChecksAs;
use crate::{
player::CharacterId,
role::{Alignment, PreviousGuardianAction, Role, RoleTitle},
};
use super::Target;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ActionPrompt {
WolvesIntro {
wolves: Box<[(Target, RoleTitle)]>,
},
RoleChange {
new_role: RoleTitle,
},
Seer {
living_players: Box<[Target]>,
},
Protector {
targets: Box<[Target]>,
},
Arcanist {
living_players: Box<[Target]>,
},
Gravedigger {
dead_players: Box<[Target]>,
},
Hunter {
current_target: Option<Target>,
living_players: Box<[Target]>,
},
Militia {
living_players: Box<[Target]>,
},
MapleWolf {
kill_or_die: bool,
living_players: Box<[Target]>,
},
Guardian {
previous: Option<PreviousGuardianAction>,
living_players: Box<[Target]>,
},
WolfPackKill {
living_villagers: Box<[Target]>,
},
Shapeshifter,
AlphaWolf {
living_villagers: Box<[Target]>,
},
DireWolf {
living_players: Box<[Target]>,
},
}
impl PartialOrd for ActionPrompt {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
fn ordering_num(prompt: &ActionPrompt) -> u8 {
match prompt {
ActionPrompt::WolvesIntro { wolves: _ } => 0,
ActionPrompt::Guardian {
living_players: _,
previous: _,
}
| ActionPrompt::Protector { targets: _ } => 1,
ActionPrompt::WolfPackKill {
living_villagers: _,
} => 2,
ActionPrompt::Shapeshifter => 3,
ActionPrompt::AlphaWolf {
living_villagers: _,
} => 4,
ActionPrompt::DireWolf { living_players: _ } => 5,
ActionPrompt::Seer { living_players: _ }
| ActionPrompt::Arcanist { living_players: _ }
| ActionPrompt::Gravedigger { dead_players: _ }
| ActionPrompt::Hunter {
current_target: _,
living_players: _,
}
| ActionPrompt::Militia { living_players: _ }
| ActionPrompt::MapleWolf {
kill_or_die: _,
living_players: _,
}
| ActionPrompt::RoleChange { new_role: _ } => 0xFF,
}
}
ordering_num(self).partial_cmp(&ordering_num(other))
}
}
#[derive(Debug, Clone, Serialize, PartialEq, Deserialize, ChecksAs)]
pub enum ActionResponse {
Seer(CharacterId),
Arcanist(CharacterId, CharacterId),
Gravedigger(CharacterId),
Hunter(CharacterId),
Militia(Option<CharacterId>),
MapleWolf(Option<CharacterId>),
Guardian(CharacterId),
WolfPackKillVote(CharacterId),
#[checks]
Shapeshifter(bool),
AlphaWolf(Option<CharacterId>),
Direwolf(CharacterId),
Protector(CharacterId),
#[checks]
RoleChangeAck,
WolvesIntroAck,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ActionResult {
RoleBlocked,
Seer(Alignment),
Arcanist { same: bool },
GraveDigger(Option<RoleTitle>),
GoBackToSleep,
WolvesIntroDone,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RoleChange {
Elder(Role),
Apprentice(Role),
Shapeshift(Role),
}