def handler(exp): real = dice.roll(exp) mx = dice.roll_max(exp) mn = dice.roll_min(exp) try: yield from zip( cast(Iterable[int], real), cast(Iterable[int], mn), cast(Iterable[int], mx), ) except TypeError: yield (real, mn, mx)
def __init__(self, name='Sword', damage='1d6', magicBonus=0, char=dndChar()): self.name = name self.damage = damage + '+0' self.magicBonus = magicBonus self.char = char self.minDamage = dice.roll_min(self.damage) self.maxDamage = dice.roll_max(self.damage) self.averageDamage = np.zeros(self.maxCA) self.plot = None
def handler(exp): real = as_iterable(dice.roll(exp)) mn = as_iterable(dice.roll_min(exp)) mx = as_iterable(dice.roll_max(exp)) yield from zip(real, mn, mx)
def test_extreme_roll(self): assert roll_min('3d6') == [1] * 3 assert roll_max('3d6') == [6] * 3
def test_extreme_reroll(self): r = roll_min("2d6r") assert r == [1, 1] r = roll_max("2d6r6") assert r == [6, 6]
def test_roll(): for single, raw in itertools.product((True, False), (True, False)): assert roll('6d6', single=single, raw=raw) assert roll_min('6d6', single=single, raw=raw) assert roll_max('6d6', single=single, raw=raw)
def test_roll(): for single, raw in product((True, False), (True, False)): assert roll("6d6", single=single, raw=raw) assert roll_min("6d6", single=single, raw=raw) assert roll_max("6d6", single=single, raw=raw)
def test_extreme_reroll(self): r = roll_min('2d6r') assert r == [1, 1] r = roll_max('2d6r6') assert r == [6, 6]
def test_extreme_roll(self): assert roll_min("3d6") == [1] * 3 assert roll_max("3d6") == [6] * 3