本文整理汇总了Python中Game.Game.score方法的典型用法代码示例。如果您正苦于以下问题:Python Game.score方法的具体用法?Python Game.score怎么用?Python Game.score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.score方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameTest
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [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: TestGame
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
class TestGame(unittest.TestCase):
game = None
def setUp(self):
self.game = Game()
def tearDown(self):
self.game = None
def testOneThrow(self):
self.game.add(1)
self.assertEqual(1, self.game.score())
def testTwoThrowsNoMark(self):
self.game.add(1)
self.game.add(1)
self.assertEqual(2, self.game.score())
def testFourFramesNoMark(self):
self.game.add(1)
self.game.add(1)
self.game.add(1)
self.game.add(1)
self.assertEqual(4, self.game.score())
示例3: assertScoreForRolls
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [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 )
示例4: score_full_game
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
def score_full_game(self, balls):
game = Game()
for ball in balls:
game.add_ball(ball)
return game.score()
示例5: check_full_game
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
def check_full_game(self, expectedScore, balls):
game = Game()
for ball in balls:
game.add_ball(ball)
self.assertEquals(expectedScore, game.score())
示例6: test_strike
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
def test_strike(self):
game = Game()
game.add_ball(10)
self.assertEquals(game.score(), 10)
self.assertEquals(game.current_frame(), 2)
示例7: test_add_second_ball
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
def test_add_second_ball(self):
game = Game()
game.add_ball(1)
game.add_ball(2)
self.assertEquals(game.score(), 3)
self.assertEquals(game.current_frame(), 2)
示例8: test_add_ball
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
def test_add_ball(self):
game = Game()
game.add_ball(1)
self.assertEquals(game.current_frame(), 1)
self.assertEquals(game.score(), 1)
示例9: test_game_init
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
def test_game_init(self):
game = Game()
self.assertEquals(game.current_frame(), 1)
self.assertEquals(game.score(), 0)