Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -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)
def consolidated(self):
"""
Gets the most simplified version of the roll string. Consolidates totals and damage types together.
Note that this modifies the result expression in place!
>>> result = vroll("3d6[fire]+1d4[cold]")
>>> str(result)
'3d6 (3, 3, 2) [fire] + 1d4 (2) [cold] = `10`'
>>> result.consolidated()
'8 [fire] + 2 [cold]'
:rtype: str
"""
d20.utils.simplify_expr(self._roll.expr, ambig_inherit='left')
return RerollableStringifier().stringify(self._roll.expr.roll)
autoctx.meta_queue(f"**Damage Type**: {transforms[None]}")
elif transforms:
for frm in transforms:
autoctx.meta_queue(f"**Damage Change**: {frm} > {transforms[frm]}")
# evaluate resistances
do_resistances(dmgroll.expr, resistances, always, transforms)
# generate output
result = d20.MarkdownStringifier().stringify(dmgroll.expr)
# output
if not hide:
autoctx.queue(f"**{roll_for}**: {result}")
else:
d20.utils.simplify_expr(dmgroll.expr)
autoctx.queue(f"**{roll_for}**: {d20.MarkdownStringifier().stringify(dmgroll.expr)}")
autoctx.add_pm(str(autoctx.ctx.author.id), f"**{roll_for}**: {result}")
autoctx.target.damage(autoctx, dmgroll.total, allow_overheal=self.overheal)
# return metadata for scripting
return {'damage': f"**{roll_for}**: {result}", 'total': dmgroll.total, 'roll': dmgroll}