add a !reaction dice roll for a very simple oracle-style vibe check
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
@@ -80,3 +80,56 @@ class MarkovTestCase(TestCase):
|
||||
mock_event,
|
||||
'test: unmodded attempt beats a difficulty 3 task. 14(d20=9)'
|
||||
)
|
||||
|
||||
def test_reaction_roll_strings(self):
|
||||
"""Simulate incoming reaction requests."""
|
||||
mock_event = mock.MagicMock()
|
||||
mock_event.source = 'test!test@test'
|
||||
mock_event.target = '#test'
|
||||
mock_event.recursing = False
|
||||
|
||||
# good and very good are bold green
|
||||
mock_event.arguments = ['!reaction']
|
||||
match = re.search(dice.ircplugin.REACTION_COMMAND_REGEX, mock_event.arguments[0])
|
||||
with mock.patch('random.SystemRandom.randint', return_value=18):
|
||||
self.plugin.handle_reaction_roll(self.mock_connection, mock_event, match)
|
||||
self.mock_bot.reply.assert_called_with(
|
||||
mock_event,
|
||||
'test: the current disposition is: 9positive 14(18)'
|
||||
)
|
||||
mock_event.arguments = ['!reaction']
|
||||
match = re.search(dice.ircplugin.REACTION_COMMAND_REGEX, mock_event.arguments[0])
|
||||
with mock.patch('random.SystemRandom.randint', return_value=20):
|
||||
self.plugin.handle_reaction_roll(self.mock_connection, mock_event, match)
|
||||
self.mock_bot.reply.assert_called_with(
|
||||
mock_event,
|
||||
'test: the current disposition is: 9VERY positive 14(20)'
|
||||
)
|
||||
|
||||
# decent is green
|
||||
mock_event.arguments = ['!reaction']
|
||||
match = re.search(dice.ircplugin.REACTION_COMMAND_REGEX, mock_event.arguments[0])
|
||||
with mock.patch('random.SystemRandom.randint', return_value=10):
|
||||
self.plugin.handle_reaction_roll(self.mock_connection, mock_event, match)
|
||||
self.mock_bot.reply.assert_called_with(
|
||||
mock_event,
|
||||
'test: the current disposition is: 9positive, with complications 14(10)'
|
||||
)
|
||||
|
||||
# bad and very bad are bold red
|
||||
mock_event.arguments = ['!reaction']
|
||||
match = re.search(dice.ircplugin.REACTION_COMMAND_REGEX, mock_event.arguments[0])
|
||||
with mock.patch('random.SystemRandom.randint', return_value=4):
|
||||
self.plugin.handle_reaction_roll(self.mock_connection, mock_event, match)
|
||||
self.mock_bot.reply.assert_called_with(
|
||||
mock_event,
|
||||
'test: the current disposition is: 4negative 14(4)'
|
||||
)
|
||||
mock_event.arguments = ['!reaction']
|
||||
match = re.search(dice.ircplugin.REACTION_COMMAND_REGEX, mock_event.arguments[0])
|
||||
with mock.patch('random.SystemRandom.randint', return_value=1):
|
||||
self.plugin.handle_reaction_roll(self.mock_connection, mock_event, match)
|
||||
self.mock_bot.reply.assert_called_with(
|
||||
mock_event,
|
||||
'test: the current disposition is: 4VERY negative 14(1)'
|
||||
)
|
||||
|
||||
@@ -85,3 +85,22 @@ class DiceLibTestCase(TestCase):
|
||||
with mock.patch('random.SystemRandom.randint', return_value=10):
|
||||
result = dice.lib.cypher_roll(mods='2')
|
||||
self.assertEqual(result, (10, 1, None, None))
|
||||
|
||||
def test_reaction_roll(self):
|
||||
"""Roll possible reactions."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=1):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (1, 'VERY negative', '--'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=2):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (2, 'negative', '-'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=6):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (6, 'negative', '-'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=7):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (7, 'positive, with complications', '~'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=14):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (14, 'positive, with complications', '~'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=15):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (15, 'positive', '+'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=19):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (19, 'positive', '+'))
|
||||
with mock.patch('random.SystemRandom.randint', return_value=20):
|
||||
self.assertEqual(dice.lib.reaction_roll(), (20, 'VERY positive', '++'))
|
||||
|
||||
Reference in New Issue
Block a user