def test_stringify_no_notes(self):
     result = stringify(roll(3, 5, always_success_fake_randomize))
     self.assertEqual("- **Successes**: 8\n- **Failures**: 0", result)
     result = stringify(roll(17, 4, always_success_fake_randomize))
     self.assertEqual("- **Successes**: 21\n- **Failures**: 0", result)
     result = stringify(roll(1, 0, always_critical_fake_randomize))
     self.assertEqual("- **Successes**: 1\n- **Failures**: 0", result)
 def test_roll_result_successes_and_criticals(self):
     result = roll(4, 1, always_critical_fake_randomize)
     self.assertEqual(9, result.successes)
     self.assertEqual(0, result.failures)
     self.assertEqual([10] * 5, result.rolls)
     self.assertTrue(result.is_messy_critical)
     self.assertFalse(result.is_critical)
     self.assertFalse(result.is_bestial_failure)
     result = roll(8, 2, always_critical_fake_randomize)
     self.assertEqual(20, result.successes)
     self.assertEqual(0, result.failures)
     self.assertEqual([10] * 10, result.rolls)
     self.assertTrue(result.is_messy_critical)
     self.assertFalse(result.is_critical)
     self.assertFalse(result.is_bestial_failure)
 def test_roll_bestial_failure(self):
     result = roll(1, 1, always_one_fake_randomize)
     self.assertEqual(0, result.successes)
     self.assertEqual(2, result.failures)
     self.assertEqual([1, 1], result.rolls)
     self.assertFalse(result.is_critical)
     self.assertFalse(result.is_messy_critical)
     self.assertTrue(result.is_bestial_failure)
 def test_roll_result_failures_and_successes(self):
     result = roll(5, 4, AscendingFakeRandomize().randomize)
     self.assertEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], result.rolls)
     self.assertEqual(4, result.successes)
     self.assertEqual(5, result.failures)
     self.assertFalse(result.is_messy_critical)
     self.assertFalse(result.is_critical)
     self.assertFalse(result.is_bestial_failure)
async def on_message(message):
    if message.author == client.user:
        return
    if message.content.startswith(invoking_command_prefix()):
        log_command_entry(message)
        normal_dices, hunger_dices, comment = tokenize(
            without_command_prefix(message.content))
        roll_result = roll(normal_dices, hunger_dices)
        await message.channel.send(
            build_reply(comment, message.author.mention, roll_result))
def roll_command_handler(update_obj: telegram.Update, _: telegram.ext.CallbackContext):
    log_command_entry(update_obj)
    normal_dices, hunger_dices, comment = tokenize(without_command_prefix(update_obj.message.text, prefix='/'))
    roll_result = roll(normal_dices, hunger_dices)
    update_obj.message.reply_markdown_v2(build_reply(comment,
                                                     user_mention=None,
                                                     roll_result=roll_result,
                                                     list_prefix='\\-',
                                                     bold_delimiter='*',
                                                     italic_delimiter='_'),
                                         quote=True)
 def test_roll_result_is_critical(self):
     result = roll(2, 0, always_critical_fake_randomize)
     self.assertEqual([10, 10], result.rolls)
     self.assertTrue(result.is_critical)
     self.assertFalse(result.is_messy_critical)
     self.assertFalse(result.is_bestial_failure)
     result = roll(1, 1, always_critical_fake_randomize)
     self.assertEqual([10, 10], result.rolls)
     self.assertFalse(result.is_critical)
     self.assertTrue(result.is_messy_critical)
     self.assertFalse(result.is_bestial_failure)
     result = roll(1, 0, always_critical_fake_randomize)
     self.assertEqual([10], result.rolls)
     self.assertFalse(result.is_critical)
     self.assertFalse(result.is_messy_critical)
     self.assertFalse(result.is_bestial_failure)
     result = roll(0, 1, always_critical_fake_randomize)
     self.assertEqual([10], result.rolls)
     self.assertEqual(1, result.successes)
     self.assertFalse(result.is_critical)
     self.assertFalse(result.is_messy_critical)
     self.assertFalse(result.is_bestial_failure)
Ejemplo n.º 8
0
 def test_stringify_notes_critical_hit(self):
     result = stringify(roll(2, 0, always_critical_fake_randomize))
     self.assertEqual(
         "- **Successes**: 4\n- **Failures**: 0\n- **Special**: *critical hit*",
         result)
Ejemplo n.º 9
0
 def test_stringify_critical_hit_and_bestial_failure(self):
     result = stringify(roll(20, 1, AscendingFakeRandomize().randomize))
     self.assertEqual(
         "- **Successes**: 12\n- **Failures**: 11\n"
         "- **Special**: *critical hit*, *bestial failure*", result)
Ejemplo n.º 10
0
 def test_stringify_notes_messy_critical_and_bestial_failure(self):
     result = stringify(roll(20, 20, AscendingFakeRandomize().randomize))
     self.assertEqual(
         "- **Successes**: 24\n- **Failures**: 20\n"
         "- **Special**: *messy critical*, *bestial failure*", result)
Ejemplo n.º 11
0
 def test_stringify_notes_messy_critical(self):
     result = stringify(roll(0, 20, always_critical_fake_randomize))
     self.assertEqual(
         "- **Successes**: 40\n- **Failures**: 0\n- **Special**: *messy critical*",
         result)
Ejemplo n.º 12
0
 def test_stringify_notes_bestial_failure(self):
     result = stringify(roll(0, 10, AscendingFakeRandomize().randomize))
     self.assertEqual(
         "- **Successes**: 5\n- **Failures**: 5\n- **Special**: *bestial failure*",
         result)
 def test_simple_stringify(self):
     self.assertEqual('- **Successes**: 3\n- **Failures**: 0', stringify(roll(2, 1, always_success_fake_randomize)))
     self.assertEqual('- !Successes!: 1\n- !Failures!: 0', stringify(roll(1, 0, always_success_fake_randomize), '!'))
 def test_messy_and_bestial_failure(self):
     result = roll(10, 10, AscendingFakeRandomize().randomize)
     self.assertEqual('- **Successes**: 12\n- **Failures**: 10\n- **Special**: *messy critical*, *bestial failure*',
                      stringify(result))
     self.assertEqual('- *Successes*: 12\n- *Failures*: 10\n- *Special*: !messy critical!, !bestial failure!',
                      stringify(result, bold_delimiter='*', italic_delimiter='!'))
 def test_criticals(self):
     result = roll(2, 0, always_critical_fake_randomize)
     self.assertEqual('- **Successes**: 4\n- **Failures**: 0\n- **Special**: *critical hit*', stringify(result))
     self.assertEqual('- **Successes**: 4\n- **Failures**: 0\n- **Special**: !!critical hit!!',
                      stringify(result, italic_delimiter='!!'))
 def test_stringify_list_prefix(self):
     self.assertEqual('!! **Successes**: 3\n!! **Failures**: 0',
                      stringify(roll(2, 1, always_success_fake_randomize), list_prefix='!!'))