cypher: distinguish between a task roll and an attack roll

attack = A, otherwise the same options as with a generic task (= T)

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
2025-02-08 23:51:00 -06:00
parent 3b7c871a94
commit 6d8ba18380
4 changed files with 35 additions and 12 deletions

View File

@@ -30,14 +30,24 @@ class MarkovTestCase(TestCase):
mock_event.target = '#test'
mock_event.recursing = False
# general task roll
# general task roll (no damage output on a 17)
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(
mock_event,
'test: your check 9succeeded, with +1 damage! 14(d20=17 vs. diff. 3)'
'test: your check 9succeeded! 14(d20=17 vs. diff. 3)'
)
# general attack roll (incl. damage output on a 17)
mock_event.arguments = ['!cypher A3']
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 attack 9succeeded, with +1 damage! 14(d20=17 vs. diff. 3)'
)
# general task roll, case insensitive
@@ -47,7 +57,7 @@ class MarkovTestCase(TestCase):
self.plugin.handle_cypher_roll(self.mock_connection, mock_event, match)
self.mock_bot.reply.assert_called_with(
mock_event,
'test: your check 9succeeded, with +1 damage! 14(d20=17 vs. diff. 3)'
'test: your check 9succeeded! 14(d20=17 vs. diff. 3)'
)
# unknown target roll
@@ -57,7 +67,7 @@ class MarkovTestCase(TestCase):
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)'
'test: your check beats a difficulty 4 task. 14(d20=17 with +1 levels)'
)
# no mod or known difficulty

View File

@@ -26,15 +26,25 @@ class DiceLibTestCase(TestCase):
result = dice.lib.cypher_roll(difficulty=1)
self.assertEqual(result, (1, None, False, 'a GM intrusion'))
# rolled a 17 on an attack
with mock.patch('random.SystemRandom.randint', return_value=17):
result = dice.lib.cypher_roll(difficulty=1, is_attack=True)
self.assertEqual(result, (17, 5, True, '+1 damage'))
# rolled a 18 on an attack
with mock.patch('random.SystemRandom.randint', return_value=18):
result = dice.lib.cypher_roll(difficulty=1, is_attack=True)
self.assertEqual(result, (18, 6, True, '+2 damage'))
# rolled a 17
with mock.patch('random.SystemRandom.randint', return_value=17):
result = dice.lib.cypher_roll(difficulty=1)
self.assertEqual(result, (17, 5, True, '+1 damage'))
self.assertEqual(result, (17, 5, True, None))
# rolled a 18
with mock.patch('random.SystemRandom.randint', return_value=18):
result = dice.lib.cypher_roll(difficulty=1)
self.assertEqual(result, (18, 6, True, '+2 damage'))
self.assertEqual(result, (18, 6, True, None))
# rolled a 19
with mock.patch('random.SystemRandom.randint', return_value=19):