本文整理汇总了Python中dice.Dice.roll_list方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.roll_list方法的具体用法?Python Dice.roll_list怎么用?Python Dice.roll_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dice.Dice
的用法示例。
在下文中一共展示了Dice.roll_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDiceClass
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import roll_list [as 别名]
class TestDiceClass(unittest.TestCase):
def setUp(self):
self.dice = Dice()
self.roll_list = self.dice.roll_list("100d100")
def tearDown(self):
pass
def testLen_roll_list(self):
self.assertEqual(100, len(self.roll_list))
def testNone_roll_list(self):
self.assertEqual(None, self.dice.roll_list("aaaa"))
def testNumber_roll_list(self):
for member in self.roll_list:
assert(1 <= member and member <= 100)
def testSimple_roll(self):
result = self.dice.roll("1d100")
assert(1 <= result and result <= 100)
def testSimple2_roll(self):
self.assertEqual(150, self.dice.roll("2d100", [100,50]))
def testNone_roll(self):
self.assertEqual(None, self.dice.roll("aaaa"))
def testPlus_roll(self):
result = self.dice.roll("1d100+1")
assert(2 <= result and result <= 101)
def testPlus2_roll(self):
self.assertEqual(151, self.dice.roll("2d100+1", [100,50]))
def testMinus_roll(self):
result = self.dice.roll("1d100-1")
assert(0 <= result and result <= 99)
def testMinus2_roll(self):
self.assertEqual(149, self.dice.roll("2d100-1", [100,50]))
def testMulti_roll(self):
result = self.dice.roll("1d100*2")
assert(2 <= result and result <= 200)
assert(result % 2 == 0)
result = self.dice.roll("1d100x2")
assert(2 <= result and result <= 200)
assert(result % 2 == 0)
def testMulti2_roll(self):
self.assertEqual(300, self.dice.roll("2d100*2", [100,50]))
self.assertEqual(300, self.dice.roll("2d100x2", [100,50]))
def testDiv_roll(self):
result = self.dice.roll("1d100/2")
assert(1 <= result and result <= 50)
def testDiv2_roll(self):
self.assertEqual(75, self.dice.roll("2d100/2", [100,50]))
def testDiv3_roll(self):
self.assertEqual(1, self.dice.roll("1d4/2", [1]))
def testBest_roll(self):
self.assertEqual(100, self.dice.roll("3d100b1", [25, 100,50]))
self.assertEqual(150, self.dice.roll("3d100b2", [25, 100,50]))