traitor prompt appears for non-wakers
also the traitor, elder reveal, role change prompts can no longer get drunk (lol)
This commit is contained in:
parent
1c3980d700
commit
99a2fa31c4
|
|
@ -14,11 +14,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use rand::{SeedableRng, rngs::SmallRng, seq::SliceRandom};
|
||||
// #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
// pub enum BagItem<T, V> {
|
||||
// Left(T),
|
||||
// Right(V),
|
||||
// }
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Bag<T>(Vec<T>);
|
||||
|
|
|
|||
|
|
@ -248,9 +248,9 @@ impl Character {
|
|||
)
|
||||
}
|
||||
|
||||
fn mason_prompts(&self, village: &Village) -> Result<Box<[ActionPrompt]>> {
|
||||
fn mason_prompts(&self, village: &Village) -> Result<Vec<ActionPrompt>> {
|
||||
if !self.role.wakes(village) {
|
||||
return Ok(Box::new([]));
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let (recruits, recruits_available) = match &self.role {
|
||||
Role::MasonLeader {
|
||||
|
|
@ -313,22 +313,25 @@ impl Character {
|
|||
}
|
||||
|
||||
pub fn night_action_prompts(&self, village: &Village) -> Result<Box<[ActionPrompt]>> {
|
||||
let mut prompts = Vec::new();
|
||||
if self.mason_leader().is_ok() {
|
||||
return self.mason_prompts(village);
|
||||
}
|
||||
if !self.alive() || !self.role.wakes(village) {
|
||||
return Ok(Box::new([]));
|
||||
// add them here so masons wake up even with a dead leader
|
||||
prompts.append(&mut self.mason_prompts(village)?);
|
||||
}
|
||||
let night = match village.time() {
|
||||
GameTime::Day { number: _ } => return Err(GameError::NotNight),
|
||||
GameTime::Night { number } => number,
|
||||
};
|
||||
let mut prompts = Vec::new();
|
||||
if night == 0 && self.auras.list().contains(&Aura::Traitor) {
|
||||
log::info!("adding traitor prompt for {}", self.identity());
|
||||
prompts.push(ActionPrompt::TraitorIntro {
|
||||
character_id: self.identity(),
|
||||
});
|
||||
}
|
||||
if !self.alive() || !self.role.wakes(village) {
|
||||
return Ok(prompts.into_boxed_slice());
|
||||
}
|
||||
|
||||
match &self.role {
|
||||
Role::Empath { cursed: true }
|
||||
| Role::Diseased
|
||||
|
|
|
|||
|
|
@ -1064,6 +1064,9 @@ impl Night {
|
|||
Visits::new(
|
||||
self.used_actions
|
||||
.iter()
|
||||
.filter(|(_, result, _)| {
|
||||
!matches!(result, ActionResult::Drunk | ActionResult::RoleBlocked)
|
||||
})
|
||||
.filter_map(|(prompt, _, _)| match prompt {
|
||||
ActionPrompt::Arcanist {
|
||||
character_id,
|
||||
|
|
|
|||
|
|
@ -547,10 +547,26 @@ impl Night {
|
|||
resp: ActionResponse,
|
||||
) -> Result<ResponseOutcome> {
|
||||
let outcome = self.process(resp)?;
|
||||
if matches!(
|
||||
self.current_prompt(),
|
||||
Some((ActionPrompt::TraitorIntro { .. }, _))
|
||||
| Some((ActionPrompt::RoleChange { .. }, _))
|
||||
| Some((ActionPrompt::ElderReveal { .. }, _))
|
||||
) {
|
||||
return Ok(outcome);
|
||||
}
|
||||
let mut act = match outcome {
|
||||
ResponseOutcome::PromptUpdate(prompt) => {
|
||||
return Ok(ResponseOutcome::PromptUpdate(prompt));
|
||||
}
|
||||
ResponseOutcome::ActionComplete(ActionComplete {
|
||||
result: ActionResult::Drunk,
|
||||
..
|
||||
})
|
||||
| ResponseOutcome::ActionComplete(ActionComplete {
|
||||
result: ActionResult::RoleBlocked,
|
||||
..
|
||||
}) => return Ok(outcome),
|
||||
ResponseOutcome::ActionComplete(act) => act,
|
||||
};
|
||||
let Some(char) = self.current_character() else {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
use core::{num::NonZeroU8, ops::Not};
|
||||
|
||||
use crate::{
|
||||
aura::{Aura, AuraTitle},
|
||||
aura::Aura,
|
||||
diedto::DiedTo,
|
||||
error::GameError,
|
||||
game::{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use yew::prelude::*;
|
||||
|
||||
use crate::components::{Icon, IconSource};
|
||||
|
||||
#[function_component]
|
||||
pub fn TraitorIntroPage() -> Html {
|
||||
html! {
|
||||
|
|
@ -8,8 +10,11 @@ pub fn TraitorIntroPage() -> Html {
|
|||
<div class="information traitor faint">
|
||||
<h2>{"YOU ARE A TRAITOR"}</h2>
|
||||
<h3>{"YOU RETAIN YOUR ROLE AND WIN IF EVIL WINS"}</h3>
|
||||
<div class="info-icon-grow">
|
||||
<Icon source={IconSource::Traitor}/>
|
||||
</div>
|
||||
<h4>{"HOWEVER"}</h4>
|
||||
<h2 class="yellow inline-icons">
|
||||
<h2 class="yellow">
|
||||
{"YOU CONTRIBUTE TO VILLAGE PARITY"}
|
||||
</h2>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue