def test_is_fail(self): tree = EvalTree('2d20l1') tree.evaluate() self.assertTrue(tree.is_fail()) self.assertFalse(tree.is_critical()) tree = EvalTree('1d20 + 1d20') tree.evaluate() self.assertTrue(tree.is_fail()) self.assertTrue(tree.is_critical())
def populate(self, tree: EvalTree): """Display the result of a roll represented by the tree.""" try: tree.evaluate() text = tree.verbose_result() color = 'black' if tree.is_critical(): color = 'green' elif tree.is_fail(): color = 'red' self.setText(text) self.setFont(self.defaultFont) self.setStyleSheet('color: {}'.format(color)) except EvaluationError as e: self.show_error(e)