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:
parent
cc9b110531
commit
fa4815153a
@ -76,7 +76,7 @@ class Dice(Plugin):
|
|||||||
# show the adjusted difficulty
|
# show the adjusted difficulty
|
||||||
detail_str = f"14(d20={result} vs. diff. {difficulty}{mods})"
|
detail_str = f"14(d20={result} vs. diff. {difficulty}{mods})"
|
||||||
else:
|
else:
|
||||||
detail_str = f"14(d20={result} with {mods} levels)"
|
detail_str = f"14(d20={result}{f' with {mods} levels' if mods else ''})"
|
||||||
|
|
||||||
if comment:
|
if comment:
|
||||||
return self.bot.reply(event, f"{nick}: {comment} {result_str} {detail_str}")
|
return self.bot.reply(event, f"{nick}: {comment} {result_str} {detail_str}")
|
||||||
|
@ -26,12 +26,13 @@ class MarkovTestCase(TestCase):
|
|||||||
def test_cypher_roll_strings(self):
|
def test_cypher_roll_strings(self):
|
||||||
"""Simulate incoming Cypher System requests."""
|
"""Simulate incoming Cypher System requests."""
|
||||||
mock_event = mock.MagicMock()
|
mock_event = mock.MagicMock()
|
||||||
mock_event.arguments = ['!cypher T3']
|
|
||||||
mock_event.source = 'test!test@test'
|
mock_event.source = 'test!test@test'
|
||||||
mock_event.target = '#test'
|
mock_event.target = '#test'
|
||||||
mock_event.recursing = False
|
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):
|
with mock.patch('random.SystemRandom.randint', return_value=17):
|
||||||
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
|
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
|
||||||
self.mock_bot.reply.assert_called_with(
|
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)'
|
'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):
|
with mock.patch('random.SystemRandom.randint', return_value=17):
|
||||||
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
|
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
|
||||||
self.mock_bot.reply.assert_called_with(
|
self.mock_bot.reply.assert_called_with(
|
||||||
mock_event,
|
mock_event,
|
||||||
'test: your check beats a difficulty 4 task, with +1 damage! 14(d20=17 with +1 levels)'
|
'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)'
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user