예제 #1
0
 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
0
 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)
예제 #3
0
파일: ui.py 프로젝트: smile921/kh_blog
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()
예제 #4
0
파일: ui.py 프로젝트: bfontaine/term2048
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()
예제 #5
0
 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())
예제 #6
0
 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())