本文整理汇总了Python中term2048.game.Game.restore方法的典型用法代码示例。如果您正苦于以下问题:Python Game.restore方法的具体用法?Python Game.restore怎么用?Python Game.restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类term2048.game.Game
的用法示例。
在下文中一共展示了Game.restore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_store_restore_empty_game
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import restore [as 别名]
def test_store_restore_empty_game(self):
store = NamedTemporaryFile(delete=False)
store.close()
g1 = Game(scores_file=None, store_file=store.name)
self.assertTrue(g1.store())
g2 = Game(scores_file=None, store_file=store.name)
g2.board.setCell(0, 0, 16)
self.assertTrue(g2.restore())
self.assertIn(g2.board.getCell(0, 0), [0, 2, 4])
remove(store.name)
示例2: start_game
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import restore [as 别名]
def start_game(debug=False):
"""
Start a new game. If ``debug`` is set to ``True``, the game object is
returned and the game loop isn't fired.
"""
args = parse_cli_args()
if args['version']:
print_version_and_exit()
if args['rules']:
print_rules_and_exit()
game = Game(**args)
if args['resume']:
game.restore()
if debug:
return game
return game.loop()
示例3: test_restore_fail_return_false
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import restore [as 别名]
def test_restore_fail_return_false(self):
store_name = '/i/dont/%s/exist/%s' % (uuid4(), uuid4())
g = Game(scores_file=None, store_file=store_name)
self.assertFalse(g.restore())