当前位置: 首页>>代码示例>>Python>>正文


Python Game.store方法代码示例

本文整理汇总了Python中term2048.game.Game.store方法的典型用法代码示例。如果您正苦于以下问题:Python Game.store方法的具体用法?Python Game.store怎么用?Python Game.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在term2048.game.Game的用法示例。


在下文中一共展示了Game.store方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_store_non_empty_file

# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
 def test_store_non_empty_file(self):
     store = NamedTemporaryFile(delete=False)
     store.close()
     g = Game(scores_file=None, store_file=store.name)
     self.assertTrue(g.store())
     self.assertFileIsNotEmpty(store.name)
     remove(store.name)
开发者ID:Anykey228,项目名称:term2048_ai,代码行数:9,代码来源:test_game.py

示例2: test_store_fail_return_false

# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
 def test_store_fail_return_false(self):
     store = NamedTemporaryFile(delete=False)
     store.close()
     os.chmod(store.name, 0)  # no rights at all
     g = Game(scores_file=None, store_file=store.name)
     self.assertFalse(g.store())
     os.chmod(store.name, 0o200)  # give me writing rights back
     remove(store.name)
开发者ID:Anykey228,项目名称:term2048_ai,代码行数:10,代码来源:test_game.py

示例3: test_start_game_no_resume

# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
    def test_start_game_no_resume(self):
        g1 = Game(scores_file=None)
        g1.board.setCell(0, 0, 16)
        self.assertTrue(g1.store())

        sys.argv = ['term2048']
        g2 = ui.start_game(debug=True)
        self.assertIn(g2.board.getCell(0, 0), [0, 2, 4])
开发者ID:jasonkliu,项目名称:term2048,代码行数:10,代码来源:test_ui.py

示例4: test_store_restore_empty_game

# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [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)
开发者ID:Anykey228,项目名称:term2048_ai,代码行数:12,代码来源:test_game.py

示例5: test_start_game_resume

# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
    def test_start_game_resume(self):
        cellvalue = 2
        g1 = Game(scores_file=None)
        g1.board.setCell(0, 0, cellvalue)
        g1.score = 42
        self.assertTrue(g1.store())

        sys.argv = ['term2048', '--resume']
        g2 = ui.start_game(debug=True)
        self.assertEqual(cellvalue, g2.board.getCell(0, 0))
        self.assertEqual(g1.score, g2.score)
开发者ID:jasonkliu,项目名称:term2048,代码行数:13,代码来源:test_ui.py


注:本文中的term2048.game.Game.store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。