Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dice_ast = _upcast_scaled_dice(self, autoctx, dice_ast)
# -mi # (#527)
if mi_arg:
dice_ast = d20.utils.tree_map(_mi_mapper(mi_arg), dice_ast)
# -d #
if d_arg:
d_ast = d20.parse(d_arg)
dice_ast.roll = d20.ast.BinOp(dice_ast.roll, '+', d_ast.roll)
# crit
in_crit = autoctx.in_crit or crit_arg
roll_for = "Damage" if not in_crit else "Damage (CRIT!)"
if in_crit:
dice_ast = d20.utils.tree_map(_crit_mapper, dice_ast)
if critdice and not autoctx.is_spell:
# add X critdice to the leftmost node if it's dice
left = d20.utils.leftmost(dice_ast)
if isinstance(left, d20.ast.Dice):
left.num += int(critdice)
# -c #
if c_arg and in_crit:
c_ast = d20.parse(c_arg)
dice_ast.roll = d20.ast.BinOp(dice_ast.roll, '+', c_ast.roll)
# max
if max_arg:
dice_ast = d20.utils.tree_map(_max_mapper, dice_ast)
# evaluate damage
# add on combatant damage effects (#224)
if autoctx.combatant:
effect_d = '+'.join(autoctx.combatant.active_effects('d'))
if effect_d:
if d:
d = f"{d}+{effect_d}"
else:
d = effect_d
dice_ast = copy.copy(d20.parse(self.dice))
dice_ast = _upcast_scaled_dice(self, autoctx, dice_ast)
if not self.hidden:
# -mi # (#527)
if mi:
dice_ast = d20.utils.tree_map(_mi_mapper(mi), dice_ast)
if d:
d_ast = d20.parse(d)
dice_ast.roll = d20.ast.BinOp(dice_ast.roll, '+', d_ast.roll)
if maxdmg:
dice_ast = d20.utils.tree_map(_max_mapper, dice_ast)
rolled = roll(dice_ast)
if not self.hidden:
autoctx.meta_queue(f"**{self.name.title()}**: {rolled.result}")
d20.utils.simplify_expr(rolled.expr)
autoctx.metavars[self.name] = RerollableStringifier().stringify(rolled.expr.roll)
d = effect_d
dice_ast = copy.copy(d20.parse(self.dice))
dice_ast = _upcast_scaled_dice(self, autoctx, dice_ast)
if not self.hidden:
# -mi # (#527)
if mi:
dice_ast = d20.utils.tree_map(_mi_mapper(mi), dice_ast)
if d:
d_ast = d20.parse(d)
dice_ast.roll = d20.ast.BinOp(dice_ast.roll, '+', d_ast.roll)
if maxdmg:
dice_ast = d20.utils.tree_map(_max_mapper, dice_ast)
rolled = roll(dice_ast)
if not self.hidden:
autoctx.meta_queue(f"**{self.name.title()}**: {rolled.result}")
d20.utils.simplify_expr(rolled.expr)
autoctx.metavars[self.name] = RerollableStringifier().stringify(rolled.expr.roll)