Skip to content

Commit

Permalink
🎨 Add: enable switch prove role_assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
sheagrief committed Oct 31, 2024
1 parent ad73e45 commit 131845e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions examples/werewolf_cli/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,18 @@ impl Game {
}
}

pub fn role_assignment(&mut self) {
pub fn role_assignment(&mut self, is_prove: bool) {
let role = role::calc_role(self.state.players.len(), &self.rules);

for (player, role) in self.state.players.iter_mut().zip(role) {
player.role = Some(role);
}

// prove and verify
if let Err(e) = self.prove_and_verify() {
eprintln!("Failed to prove and verify: {}", e);
if is_prove {
// prove and verify
if let Err(e) = self.prove_and_verify() {
eprintln!("Failed to prove and verify: {}", e);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/werewolf_cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let mut game = Game::new(register_players(), game_rule);

game.role_assignment();
game.role_assignment(false);

println!("{:?}", game.state.players);

Expand Down

0 comments on commit 131845e

Please sign in to comment.