1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::judger::log::Log;

use super::{responder, DeathReason, LifeStatus, Responder, RoleGroup};
use super::RespBoxesMut;

#[derive(Default)]
pub struct Hunter {}


impl RoleGroup for Hunter {
    fn death(
        &self, 
        mut players: RespBoxesMut,
        dying: &mut Box<dyn Responder>,
        log: &mut Log
    ) {
        dying.send_msg("你死了,请发表遗言。");
        dying.set_status(LifeStatus::Dead);
        let words = format!("{}的遗言: {}", dying.name(), dying.rec_text());
        players.iter_mut().for_each(|x| x.send_msg(&words));
        log.write(&words);
        players = players.into_iter()
            .filter(|x| x.status() == LifeStatus::Alive)
            .collect();
        let mut voter = vec![dying];
        let shoot = responder::vote(
            &mut voter, 
            responder::make_votelist(&players), 
            "选择开枪对象".to_string(),
            log
        );
        voter[0].send_end();
        players.iter_mut()
            .find(|x| x.get_id() == shoot).unwrap()
            .set_status(LifeStatus::NewDeath(DeathReason::Gun));
        
    }
}