dice: more fork syncing, this time changing some output
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
+6
-6
@@ -61,9 +61,9 @@ def cypher_result(difficulty: Optional[int] = None, mod: int = 0, is_attack: boo
|
||||
"""Turn the results of a Cypher System roll into a display string."""
|
||||
# tweak the comment to show task/attack in cases of empty string
|
||||
if comment:
|
||||
display_comment = comment
|
||||
display_comment = f"{comment} {stat} roll"
|
||||
else:
|
||||
display_comment = "attack" if is_attack else "task"
|
||||
display_comment = f"{stat} roll"
|
||||
|
||||
# roll it
|
||||
result, beats, success, effect, neg_effect, result_lvl, diff_level = cypher_roll(
|
||||
@@ -106,9 +106,9 @@ def cypher_result(difficulty: Optional[int] = None, mod: int = 0, is_attack: boo
|
||||
modded_diff = str(difficulty)
|
||||
|
||||
if ircify:
|
||||
detail_str = f"14(res. {result_lvl} (d20={result}) vs. {stat} difficulty {diff_level} ({modded_diff}))"
|
||||
detail_str = f"14(result {result_lvl} (d20={result}) vs. difficulty {diff_level} ({modded_diff}))"
|
||||
else:
|
||||
detail_str = f"(res. {result_lvl} (d20={result}) vs. {stat} difficulty {diff_level} ({modded_diff}))"
|
||||
detail_str = f"(result {result_lvl} (d20={result}) vs. difficulty {diff_level} ({modded_diff}))"
|
||||
else:
|
||||
# we don't know the difficulty, so don't know success or not
|
||||
if beats is not None:
|
||||
@@ -132,9 +132,9 @@ def cypher_result(difficulty: Optional[int] = None, mod: int = 0, is_attack: boo
|
||||
modded_diff = ""
|
||||
|
||||
if ircify:
|
||||
detail_str = f"14(res. {result_lvl}{modded_diff} (d20={result}) vs. {stat})"
|
||||
detail_str = f"14(result {result_lvl}{modded_diff} (d20={result}))"
|
||||
else:
|
||||
detail_str = f"(res. {result_lvl}{modded_diff} (d20={result}) vs. {stat})"
|
||||
detail_str = f"(result {result_lvl}{modded_diff} (d20={result}))"
|
||||
|
||||
return (result, beats, success, effect, neg_effect, result_lvl, diff_level,
|
||||
f"{display_comment} {result_str} {detail_str}")
|
||||
|
||||
@@ -133,5 +133,5 @@ class CypherRollStringTestCase(TestCase):
|
||||
"""Test the basics of string output."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=10):
|
||||
_, _, _, _, _, _, _, result = dice.lib.cypher_result(difficulty=3, mod=0, stat="Might",
|
||||
comment="")
|
||||
self.assertEqual(result, "task succeeded! (res. 3 (d20=10) vs. Might difficulty 3 (3))")
|
||||
comment="Test")
|
||||
self.assertEqual(result, "Test Might roll succeeded! (result 3 (d20=10) vs. difficulty 3 (3))")
|
||||
|
||||
@@ -52,35 +52,35 @@ class DiceRollerTestCase(TestCase):
|
||||
"""Roll a normal Cypher System roll."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=5):
|
||||
result = self.roller.do_roll('difficulty 5 might task to muscle good')
|
||||
self.assertEqual(result, 'task to muscle good failed. (res. 1 (d20=5) vs. might difficulty 5 (5))')
|
||||
self.assertEqual(result, 'task to muscle good might roll failed. (result 1 (d20=5) vs. difficulty 5 (5))')
|
||||
|
||||
def test_cypher_roll_normal_with_mods(self):
|
||||
"""Roll a Cypher System roll with mods."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=4):
|
||||
result = self.roller.do_roll('difficulty 2-2 might attack to hit good')
|
||||
self.assertEqual(result, 'attack to hit good succeeded! (res. 1 (d20=4) vs. might difficulty 0 (2-2))')
|
||||
self.assertEqual(result, 'attack to hit good might roll succeeded! (result 1 (d20=4) vs. difficulty 0 (2-2))')
|
||||
|
||||
def test_cypher_roll_normal_with_positive_mods(self):
|
||||
"""Roll a Cypher System roll with mods."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=20):
|
||||
result = self.roller.do_roll('difficulty 2+2 might attack to hit good')
|
||||
self.assertEqual(result, 'attack to hit good succeeded, with a MAJOR EFFECT! '
|
||||
'(res. 6 (d20=20) vs. might difficulty 4 (2+2))')
|
||||
self.assertEqual(result, 'attack to hit good might roll succeeded, with a MAJOR EFFECT! '
|
||||
'(result 6 (d20=20) vs. difficulty 4 (2+2))')
|
||||
|
||||
def test_cypher_roll_no_difficulty(self):
|
||||
"""Roll a Cypher System roll without difficulty, just mods."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=5):
|
||||
result = self.roller.do_roll('-1 might task to muscle good')
|
||||
self.assertEqual(result, 'task to muscle good beats a difficulty 2 task. (res. 1+1 (d20=5) vs. might)')
|
||||
self.assertEqual(result, 'task to muscle good might roll beats a difficulty 2 task. (result 1+1 (d20=5))')
|
||||
|
||||
def test_cypher_roll_no_difficulty_no_comment(self):
|
||||
"""Roll a Cypher System roll without difficulty, just mods."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=5):
|
||||
result = self.roller.do_roll('-1 might attack')
|
||||
self.assertEqual(result, 'attack beats a difficulty 2 task. (res. 1+1 (d20=5) vs. might)')
|
||||
self.assertEqual(result, 'attack might roll beats a difficulty 2 task. (result 1+1 (d20=5))')
|
||||
|
||||
def test_cypher_roll_no_difficulty_intrusion(self):
|
||||
"""Roll a Cypher System roll without difficulty, just mods."""
|
||||
with mock.patch('random.SystemRandom.randint', return_value=1):
|
||||
result = self.roller.do_roll('-1 might attack')
|
||||
self.assertEqual(result, 'attack beats nothing, with a GM intrusion! (res. 0+1 (d20=1) vs. might)')
|
||||
self.assertEqual(result, 'attack might roll beats nothing, with a GM intrusion! (result 0+1 (d20=1))')
|
||||
|
||||
Reference in New Issue
Block a user