Skip to content

Commit

Permalink
Godfather in jail fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Apr 28, 2024
1 parent a1443c4 commit ac9bb86
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
16 changes: 7 additions & 9 deletions server/src/game/player/player_helper_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ use super::PlayerReference;

impl PlayerReference{
pub fn roleblock(&self, game: &mut Game, send_messages: bool) {
if !self.role(game).roleblock_immune() {
let roleblock_immune = self.role(game).roleblock_immune();

if !roleblock_immune {
self.set_night_roleblocked(game, true);
self.set_night_visits(game, vec![]);

if send_messages {
self.push_night_message(game,
ChatMessageVariant::RoleBlocked { immune: false }
);
}
} else if send_messages {
}

if send_messages {
self.push_night_message(game,
ChatMessageVariant::RoleBlocked { immune: true }
ChatMessageVariant::RoleBlocked { immune: roleblock_immune }
);
}
}
Expand Down
8 changes: 6 additions & 2 deletions server/src/game/role/jailor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ impl RoleStateImpl for Jailor {


fn do_night_action(mut self, game: &mut Game, actor_ref: PlayerReference, priority: Priority) {


match priority {
Priority::Roleblock => {
if let Some(jailed) = self.jailed_target_ref{
jailed.roleblock(game, false);
for player in PlayerReference::all_players(game){
if player.night_jailed(game){
player.roleblock(game, false);
}
}
},
Priority::Kill => {
Expand Down
44 changes: 44 additions & 0 deletions server/tests/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,50 @@ fn vigilante_cant_select_night_one() {
assert!(!vigilante_suicide.set_night_target(townie_b));
}

#[test]
fn godfather_backup_kills_esc() {
kit::scenario!(game in Night 1 where
godfather: Godfather,
hypnotist: Hypnotist,
det: Detective,
esc: Escort
);

assert!(godfather.day_target(hypnotist));

assert!(hypnotist.set_night_target(det));
assert!(esc.set_night_target(godfather));

game.next_phase();
assert!(!det.alive());
assert!(godfather.alive());
assert!(hypnotist.alive());
assert!(esc.alive());
}

#[test]
fn godfather_backup_kills_jail() {
kit::scenario!(game in Dusk 1 where
godfather: Godfather,
hypnotist: Hypnotist,
det: Detective,
jail: Jailor
);

assert!(jail.day_target(godfather));
assert!(godfather.day_target(hypnotist));

game.next_phase();
assert!(hypnotist.set_night_target(det));

game.next_phase();

assert!(!det.alive());
assert!(godfather.alive());
assert!(hypnotist.alive());
assert!(jail.alive());
}

#[test]
fn godfathers_backup_tag_works() {
kit::scenario!(game in Night 2 where
Expand Down

0 comments on commit ac9bb86

Please sign in to comment.