246 lines
8.1 KiB
Rust
246 lines
8.1 KiB
Rust
// Copyright (C) 2025 Emilis Bliūdžius
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
use core::num::NonZeroU8;
|
|
#[allow(unused)]
|
|
use pretty_assertions::{assert_eq, assert_ne, assert_str_eq};
|
|
|
|
use crate::{
|
|
diedto::DiedTo,
|
|
game::{Game, GameSettings, SetupRole},
|
|
game_test::{ActionPromptTitleExt, ActionResultExt, GameExt, SettingsExt, gen_players},
|
|
message::night::{ActionPrompt, ActionPromptTitle},
|
|
};
|
|
|
|
#[test]
|
|
fn recruits_decrement() {
|
|
let players = gen_players(1..10);
|
|
let mason_leader_player_id = players[0].player_id;
|
|
let wolf_player_id = players[1].player_id;
|
|
let sacrificial_wolf_player_id = players[2].player_id;
|
|
let mut settings = GameSettings::empty();
|
|
settings.add_and_assign(
|
|
SetupRole::MasonLeader {
|
|
recruits_available: NonZeroU8::new(1).unwrap(),
|
|
},
|
|
mason_leader_player_id,
|
|
);
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf_player_id);
|
|
settings.add_and_assign(SetupRole::Werewolf, sacrificial_wolf_player_id);
|
|
settings.fill_remaining_slots_with_villagers(9);
|
|
let mut game = Game::new(&players, settings).unwrap();
|
|
game.r#continue().r#continue();
|
|
assert_eq!(game.next().title(), ActionPromptTitle::WolvesIntro);
|
|
game.r#continue().sleep();
|
|
game.next_expect_day();
|
|
|
|
assert_eq!(game.execute().title(), ActionPromptTitle::WolfPackKill);
|
|
game.mark(
|
|
game.living_villager_excl(mason_leader_player_id)
|
|
.character_id(),
|
|
);
|
|
game.r#continue().sleep();
|
|
|
|
let recruited = game.living_villager_excl(mason_leader_player_id);
|
|
assert_eq!(game.next().title(), ActionPromptTitle::MasonLeaderRecruit);
|
|
game.mark(recruited.character_id());
|
|
game.r#continue().r#continue();
|
|
assert_eq!(
|
|
game.next(),
|
|
ActionPrompt::MasonsWake {
|
|
leader: game
|
|
.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
masons: Box::new([
|
|
game.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
game.character_by_player_id(recruited.player_id())
|
|
.identity(),
|
|
])
|
|
}
|
|
);
|
|
game.r#continue().sleep();
|
|
game.next_expect_day();
|
|
|
|
assert_eq!(game.execute().title(), ActionPromptTitle::WolfPackKill);
|
|
game.mark(
|
|
game.living_villager_excl(recruited.player_id())
|
|
.character_id(),
|
|
);
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().masons_wake();
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
}
|
|
|
|
#[test]
|
|
fn dies_recruiting_wolf() {
|
|
let players = gen_players(1..10);
|
|
let mason_leader_player_id = players[0].player_id;
|
|
let wolf_player_id = players[1].player_id;
|
|
let mut settings = GameSettings::empty();
|
|
settings.add_and_assign(
|
|
SetupRole::MasonLeader {
|
|
recruits_available: NonZeroU8::new(1).unwrap(),
|
|
},
|
|
mason_leader_player_id,
|
|
);
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf_player_id);
|
|
settings.fill_remaining_slots_with_villagers(9);
|
|
let mut game = Game::new(&players, settings).unwrap();
|
|
game.r#continue().r#continue();
|
|
assert_eq!(game.next().title(), ActionPromptTitle::WolvesIntro);
|
|
game.r#continue().sleep();
|
|
game.next_expect_day();
|
|
|
|
assert_eq!(game.execute().title(), ActionPromptTitle::WolfPackKill);
|
|
game.mark(game.living_villager().character_id());
|
|
game.r#continue().sleep();
|
|
|
|
assert_eq!(game.next().title(), ActionPromptTitle::MasonLeaderRecruit);
|
|
game.mark(game.character_by_player_id(wolf_player_id).character_id());
|
|
game.r#continue().sleep();
|
|
|
|
assert_eq!(
|
|
game.next(),
|
|
ActionPrompt::MasonsWake {
|
|
leader: game
|
|
.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
masons: Box::new([game
|
|
.character_by_player_id(mason_leader_player_id)
|
|
.identity()])
|
|
}
|
|
);
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
|
|
assert_eq!(
|
|
game.character_by_player_id(mason_leader_player_id)
|
|
.died_to()
|
|
.cloned(),
|
|
Some(DiedTo::MasonLeaderRecruitFail {
|
|
tried_recruiting: game.character_by_player_id(wolf_player_id).character_id(),
|
|
night: 1,
|
|
})
|
|
);
|
|
}
|
|
|
|
// todo: masons wake even if leader dead
|
|
#[test]
|
|
fn masons_wake_even_if_leader_died() {
|
|
let players = gen_players(1..10);
|
|
let mason_leader_player_id = players[0].player_id;
|
|
let wolf_player_id = players[1].player_id;
|
|
let black_knight_player_id = players[2].player_id;
|
|
let mut settings = GameSettings::empty();
|
|
settings.add_and_assign(
|
|
SetupRole::MasonLeader {
|
|
recruits_available: NonZeroU8::new(3).unwrap(),
|
|
},
|
|
mason_leader_player_id,
|
|
);
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf_player_id);
|
|
settings.add_and_assign(SetupRole::BlackKnight, black_knight_player_id);
|
|
settings.fill_remaining_slots_with_villagers(9);
|
|
let mut game = Game::new(&players, settings).unwrap();
|
|
let blk_knight_cid = game
|
|
.character_by_player_id(black_knight_player_id)
|
|
.character_id();
|
|
game.r#continue().r#continue();
|
|
assert_eq!(game.next().title(), ActionPromptTitle::WolvesIntro);
|
|
game.r#continue().sleep();
|
|
game.next_expect_day();
|
|
|
|
assert_eq!(game.execute().title(), ActionPromptTitle::WolfPackKill);
|
|
game.mark(blk_knight_cid);
|
|
game.r#continue().sleep();
|
|
|
|
assert_eq!(game.next().title(), ActionPromptTitle::MasonLeaderRecruit);
|
|
game.mark(blk_knight_cid);
|
|
game.r#continue().r#continue();
|
|
|
|
assert_eq!(
|
|
game.next(),
|
|
ActionPrompt::MasonsWake {
|
|
leader: game
|
|
.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
masons: Box::new([
|
|
game.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
game.character_by_player_id(black_knight_player_id)
|
|
.identity()
|
|
])
|
|
}
|
|
);
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
|
|
game.execute().title().wolf_pack_kill();
|
|
game.mark(blk_knight_cid);
|
|
game.r#continue().sleep();
|
|
|
|
let second_recruit = game.living_villager();
|
|
assert_eq!(game.next().title(), ActionPromptTitle::MasonLeaderRecruit);
|
|
game.mark(second_recruit.character_id());
|
|
game.r#continue().r#continue();
|
|
|
|
assert_eq!(
|
|
game.next(),
|
|
ActionPrompt::MasonsWake {
|
|
leader: game
|
|
.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
masons: Box::new([
|
|
game.character_by_player_id(black_knight_player_id)
|
|
.identity(),
|
|
game.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
second_recruit.identity()
|
|
])
|
|
}
|
|
);
|
|
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
game.mark_for_execution(
|
|
game.character_by_player_id(mason_leader_player_id)
|
|
.character_id(),
|
|
);
|
|
|
|
game.execute().title().wolf_pack_kill();
|
|
game.mark(blk_knight_cid);
|
|
game.r#continue().sleep();
|
|
|
|
assert_eq!(
|
|
game.next(),
|
|
ActionPrompt::MasonsWake {
|
|
leader: game
|
|
.character_by_player_id(mason_leader_player_id)
|
|
.identity(),
|
|
masons: Box::new([
|
|
game.character_by_player_id(black_knight_player_id)
|
|
.identity(),
|
|
second_recruit.identity()
|
|
])
|
|
}
|
|
);
|
|
}
|