fn ai_confused(
    monster_id: usize,
    _tcod: &Tcod,
    game: &mut Game,
    objects: &mut [Object],
    previous_ai: Box<Ai>,
    num_turns: i32,
) -> Ai {
    if num_turns >= 0 {
        // still confused ...
        // move in a random direction, and decrease the number of turns confused
        object_move_by(
            monster_id,
            rand::thread_rng().gen_range(-1, 2),
            rand::thread_rng().gen_range(-1, 2),
            &game.map,
            objects,
        );
        Ai::Confused {
            previous_ai: previous_ai,
            num_turns: num_turns - 1,
        }
    } else {
        // restore the previous AI (this one will be deleted)
        game.messages.add(
            format!("The {} is no longer confused!", objects[monster_id].name),
            RED,
        );
        *previous_ai
    }
}
// confused ai type (wanders randomly for a few seconds)
confused ai type (wanders randomly for a few seconds)
confused ai type ( wanders randomly for a few seconds )
fn ai_confused(
    monster_id: usize,
    _tcod: &Tcod,
    game: &mut Game,
    objects: &mut [Object],
    previous_ai: Box<Ai>,
    num_turns: i32,
) -> Ai {
    if num_turns >= 0 {
        // still confused ...
        // move in a random direction, and decrease the number of turns confused
        object_move_by(
            monster_id,
            rand::thread_rng().gen_range(-1, 2),
            rand::thread_rng().gen_range(-1, 2),
            &game.map,
            objects,
        );
        Ai::Confused {
            previous_ai: previous_ai,
            num_turns: num_turns - 1,
        }
    } else {
        // restore the previous AI (this one will be deleted)
        game.messages.add(
            format!("The {} is no longer confused!", objects[monster_id].name),
            RED,
        );
        *previous_ai
    }
}
fn ai_confused ( monster_id : usize , _tcod : & Tcod , game : & mut Game , objects : & mut [ Object ] , previous_ai : Box < Ai > , num_turns : i32 , ) -> Ai { if num_turns >= 0 { // still confused ... // move in a random direction, and decrease the number of turns confused object_move_by ( monster_id , rand :: thread_rng ( ) . gen_range ( - 1 , 2 ) , rand :: thread_rng ( ) . gen_range ( - 1 , 2 ) , & game . map , objects , ) ; Ai :: Confused { previous_ai : previous_ai , num_turns : num_turns - 1 , } } else { // restore the previous AI (this one will be deleted) game . messages . add ( format ! ( " " objects [ monster_id ] name ) , RED , ) ; * previous_ai } }
confused ai type (wanders randomly for a few seconds)
confused ai type ( wanders randomly for a few seconds )
monster_id
usize
_tcod
&Tcod
game
&mut Game
objects
&mut [Object]
previous_ai
Box<Ai>
num_turns
i32