cypher: slightly better display of output with no difficulty or mods

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
2025-02-08 23:30:59 -06:00
parent cc9b110531
commit fa4815153a
2 changed files with 18 additions and 4 deletions

View File

@@ -26,12 +26,13 @@ class MarkovTestCase(TestCase):
def test_cypher_roll_strings(self):
"""Simulate incoming Cypher System requests."""
mock_event = mock.MagicMock()
mock_event.arguments = ['!cypher T3']
mock_event.source = 'test!test@test'
mock_event.target = '#test'
mock_event.recursing = False
match = re.search(dice.ircplugin.CYPHER_COMMAND_REGEX, '!cypher T3')
# general task roll
mock_event.arguments = ['!cypher T3']
match = re.search(dice.ircplugin.CYPHER_COMMAND_REGEX, mock_event.arguments[0])
with mock.patch('random.SystemRandom.randint', return_value=17):
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
self.mock_bot.reply.assert_called_with(
@@ -39,10 +40,23 @@ class MarkovTestCase(TestCase):
'test: your check 9succeeded, with +1 damage! 14(d20=17 vs. diff. 3)'
)
match = re.search(dice.ircplugin.CYPHER_COMMAND_REGEX, '!cypher +1')
# unknown target roll
mock_event.arguments = ['!cypher +1']
match = re.search(dice.ircplugin.CYPHER_COMMAND_REGEX, mock_event.arguments[0])
with mock.patch('random.SystemRandom.randint', return_value=17):
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
self.mock_bot.reply.assert_called_with(
mock_event,
'test: your check beats a difficulty 4 task, with +1 damage! 14(d20=17 with +1 levels)'
)
# no mod or known difficulty
mock_event.arguments = ['!cypher unmodded attempt']
match = re.search(dice.ircplugin.CYPHER_COMMAND_REGEX, mock_event.arguments[0])
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
with mock.patch('random.SystemRandom.randint', return_value=9):
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
self.mock_bot.reply.assert_called_with(
mock_event,
'test: unmodded attempt beats a difficulty 3 task. 14(d20=9)'
)