// Disadvantage: same as advantage except the lowest alternate roll is
// kept.
same as advantage except the lowest alternate roll is
kept.
same as advantage except the lowest alternate roll is kept .
fn disadvantage(results: &mut Results, amt: i64) {
        let mut rolls: Vec<Roll> = Vec::new();
        let amt = if amt < 0 {
            1
        } else {
            amt
        };
        for r in results.rolls.iter() {
            if r.keep {
                let mut tmp: Vec<Roll> = Vec::new();
                let mut lo = 0;
                tmp.push(r.clone());
                for idx in 1..=amt as usize {
                    let mut reroll = Roll::new(r.range, r.modifier);
                    if reroll.roll < tmp[lo].roll  {
                        tmp[lo].keep = false;
                        lo = idx;
                    } else {
                        reroll.keep = false;
                    }
                    tmp.push(reroll);
                }
                for r2 in tmp {
                    rolls.push(r2);
                }
            } else {
                rolls.push(r.clone());
            }
        }
        results.rolls = rolls;
    }
fn disadvantage ( results : & mut Results , amt : i64 ) { let mut rolls : Vec < Roll > = Vec :: new ( ) ; let amt = if amt < 0 { 1 } else { amt } ; for r in results . rolls . iter ( ) { if r . keep { let mut tmp : Vec < Roll > = Vec :: new ( ) ; let mut lo = 0 ; tmp . push ( r . clone ( ) ) ; for idx in 1 ..= amt as usize { let mut reroll = Roll :: new ( r . range , r . modifier ) ; if reroll . roll < tmp [ lo ] . roll { tmp [ lo ] . keep = false ; lo = idx ; } else { reroll . keep = false ; } tmp . push ( reroll ) ; } for r2 in tmp { rolls . push ( r2 ) ; } } else { rolls . push ( r . clone ( ) ) ; } } results . rolls = rolls ; }
Disadvantage: same as advantage except the lowest alternate roll is
kept.
Disadvantage : same as advantage except the lowest alternate roll is kept .
results
&mut Results
amt
i64