本文整理汇总了Python中Game.Game.roll方法的典型用法代码示例。如果您正苦于以下问题:Python Game.roll方法的具体用法?Python Game.roll怎么用?Python Game.roll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.roll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameTest
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
class GameTest(unittest2.TestCase):
def setUp(self):
self.game = Game()
def testGutterGame(self):
self.rollForMe(0)
self.assertEqual(self.game.score(), 0)
def testAllOnes(self):
self.rollForMe(1)
self.assertEqual(self.game.score(), 20)
def testPerfectGame(self):
self.rollForMe(10, 12)
self.assertEqual(self.game.score(), 300)
def testSpare(self):
self.rollForMe(5, 2)
self.rollForMe(2, 1)
self.rollForMe(0, 17)
self.assertEqual(self.game.score(), 14)
def rollForMe(self, pins, times=20):
for element in range(times):
self.game.roll(pins)
示例2: test_calculates_for_strike
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
def test_calculates_for_strike(self):
game = Game()
game.roll(10)
game.roll(5)
game.roll(4)
self.assertEqual(28, game.score)
示例3: test_calculates_for_spare
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
def test_calculates_for_spare(self):
game = Game()
game.roll(5)
game.roll(5)
game.roll(3)
self.assertEqual(16, game.score)
示例4: test_calculates_score_no_spare_no_strike
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
def test_calculates_score_no_spare_no_strike(self):
game = Game()
noOfStruckPins = 5
game.roll(noOfStruckPins)
self.assertEqual(game.score, noOfStruckPins)
示例5: assertScoreForRolls
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
def assertScoreForRolls(self, rolls, expectedScore, msg = None):
theGame = Game()
for roll in rolls:
theGame.roll(roll)
theActualScore = theGame.score()
if theActualScore != expectedScore:
print 'expected score: %d, but got score: %d' % ( expectedScore, theActualScore )
示例6: test_strike_on_last_frame
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
def test_strike_on_last_frame(self):
game = Game()
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(10)
game.roll(1)
game.roll(1)
self.assertEqual(12, game.score)
示例7: test_spare_on_last_frame
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
def test_spare_on_last_frame(self):
game = Game()
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(0)
game.roll(5)
game.roll(5)
game.roll(1)
self.assertEqual(11, game.score)