Пример #1
0
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:
            print("CRITICAL HIT!")
            print("Damage roll:     {}".format(damage))
        elif attack_result + attack_bonus >= target_ac:
            print("HIT!")
            print("Damage roll:     {}".format(damage))
        else:
            print("MISS!")

        if i < repeats - 1:
            print("----------------------------")
Пример #2
0
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:
            print("CRITICAL HIT!")
            print("Damage roll:     {}".format(damage))
        elif attack_result + attack_bonus >= target_ac:
            print("HIT!")
            print("Damage roll:     {}".format(damage))
        else:
            print("MISS!")

        if i < repeats - 1:
            print("----------------------------")
Пример #3
0
                        sorted(du.roll_batch(dice[0], sumup=False),
                               reverse=True)[:int(args.best)]) + bonus)
            elif args.worst is not None:
                if len(dice) > 1:
                    raise DiceArgumentException(
                        "You can use only one type of die.")
                elif dice[0][1] < int(args.worst):
                    raise DiceArgumentException(
                        "You can't pick out more dice than you roll.")

                rolls[i].append(
                    sum(
                        sorted(du.roll_batch(dice[0], sumup=False))
                        [:int(args.worst)]) + bonus)
            elif args.critical is True:
                rolls[i].append(du.roll_all(dice) + du.roll_all(dice) + bonus)
            else:
                rolls[i].append(du.roll_all(dice) + bonus)

    if args.transpose:
        rolls = map(list, zip(*rolls))

    if args.verbose:
        dice_strings = []
        for dice, bonus in parsed_dice:
            output_string = ""
            if len(dice) > 0:
                output_string = output_string + \
                    str(dice[0][1]) + 'd' + str(dice[0][2])
                if len(dice) > 1:
                    for die in dice[1:]:
Пример #4
0
                    raise DiceArgumentException("You can use only one type of die.")
                elif dice[0][1] < int(args.best):
                    raise DiceArgumentException("You can't pick out more dice than you roll.")

                rolls[i].append(
                    sum(sorted(du.roll_batch(dice[0], sumup=False), reverse=True)[: int(args.best)]) + bonus
                )
            elif args.worst is not None:
                if len(dice) > 1:
                    raise DiceArgumentException("You can use only one type of die.")
                elif dice[0][1] < int(args.worst):
                    raise DiceArgumentException("You can't pick out more dice than you roll.")

                rolls[i].append(sum(sorted(du.roll_batch(dice[0], sumup=False))[: int(args.worst)]) + bonus)
            elif args.critical is True:
                rolls[i].append(du.roll_all(dice) + du.roll_all(dice) + bonus)
            else:
                rolls[i].append(du.roll_all(dice) + bonus)

    if args.transpose:
        rolls = map(list, zip(*rolls))

    if args.verbose:
        dice_strings = []
        for dice, bonus in parsed_dice:
            output_string = ""
            if len(dice) > 0:
                output_string = output_string + str(dice[0][1]) + "d" + str(dice[0][2])
                if len(dice) > 1:
                    for die in dice[1:]:
                        output_string = output_string + die[0] + str(die[1]) + "d" + str(die[2])