parser.add_argument('-a', help='roll width advantage', action='store_true') parser.add_argument('-d', help='roll width disadvantage', action='store_true') args = parser.parse_args() repeats = 1 if args.c is not None: if args.c >= 1: repeats = args.c try: for i in range(repeats): target_ac = int(args.target_ac) attack_dice, attack_bonus = du.parse_roll_line(args.attack_roll) attack_result = du.roll_batch(attack_dice[0]) if args.a: attack_result = max(attack_result, du.roll_batch(attack_dice[0])) elif args.d: attack_result = max(attack_result, du.roll_batch(attack_dice[0])) attack_roll = attack_result + attack_bonus print("Attack roll: {} vs AC {}".format(attack_roll, target_ac)) damage_dice, damage_bonus = du.parse_roll_line(args.damage_roll) damage = du.roll_all(damage_dice) + damage_bonus if attack_result == 20: damage += du.roll_all(damage_dice) if attack_result == 20:
'--worst', help= 'only sum specified number of worst rolls (can only include one die type in a roll)', type=int) args = parser.parse_args() repeats = 1 if args.count is not None: if args.count >= 1: repeats = args.count try: parsed_dice = [] for die_code in args.die_code: die, bonus = du.parse_roll_line(die_code) parsed_dice.append((die, bonus)) rolls = [] for i in range(repeats): rolls.append([]) for dice, bonus in parsed_dice: if len(dice) == 0: rolls[i].append(bonus) elif args.advantage: if dice[0][1] > 1 or dice[0][2] != 20: raise DiceArgumentException( "Can only do a 1d20+x type of roll with advantage.") rolls[i].append( max(du.roll_batch(dice[0]), du.roll_batch(dice[0])) +
) group.add_argument( "-w", "--worst", help="only sum specified number of worst rolls (can only include one die type in a roll)", type=int ) args = parser.parse_args() repeats = 1 if args.count is not None: if args.count >= 1: repeats = args.count try: parsed_dice = [] for die_code in args.die_code: die, bonus = du.parse_roll_line(die_code) parsed_dice.append((die, bonus)) rolls = [] for i in range(repeats): rolls.append([]) for dice, bonus in parsed_dice: if len(dice) == 0: rolls[i].append(bonus) elif args.advantage: if dice[0][1] > 1 or dice[0][2] != 20: raise DiceArgumentException("Can only do a 1d20+x type of roll with advantage.") rolls[i].append(max(du.roll_batch(dice[0]), du.roll_batch(dice[0])) + bonus) elif args.disadvantage: if dice[0][1] > 1 or dice[0][2] != 20: