本文整理汇总了Python中term2048.game.Game.loop方法的典型用法代码示例。如果您正苦于以下问题:Python Game.loop方法的具体用法?Python Game.loop怎么用?Python Game.loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类term2048.game.Game
的用法示例。
在下文中一共展示了Game.loop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_win_loop
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import loop [as 别名]
def test_simple_win_loop(self):
kp._setNextKey(kp.UP)
g = Game(goal=4, size=2, clear_screen=False)
g.board.cells = [
[2, 0],
[2, 0]
]
g.loop()
示例2: test_loop_pause
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import loop [as 别名]
def test_loop_pause(self):
store = NamedTemporaryFile(delete=False)
store.close()
kp._setNextKey(kp.SPACE)
g = Game(scores_file=None, store_file=store.name)
self.assertEqual(g.loop(), 0)
self.assertFileIsNotEmpty(store.name)
remove(store.name)
示例3: test_loop_pause_error
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import loop [as 别名]
def test_loop_pause_error(self):
store = NamedTemporaryFile(delete=False)
store.close()
os.chmod(store.name, 0) # no rights at all
kp._setNextKey(kp.SPACE)
g = Game(scores_file=None, store_file=store.name)
self.assertIs(None, g.loop())
os.chmod(store.name, 0o200) # give me writing rights back
remove(store.name)
示例4: test_simple_win_loop_clear
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import loop [as 别名]
def test_simple_win_loop_clear(self):
kp._setNextKey(kp.UP)
g = Game(goal=4, size=2)
g.board.cells = [
[2, 0],
[2, 0]
]
self.assertEqual(g.loop(), 4)
if os.name == 'nt':
self.assertEqual(self.sys_cmd, ('cls',))
else:
self.assertEqual(self.sys_cmd, ('clear',))
示例5: start_game
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import loop [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()
示例6: test_loop_interrupt
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import loop [as 别名]
def test_loop_interrupt(self):
kp._setCtrlC(True)
g = Game(goal=4, size=2)
self.assertEqual(g.loop(), None)