Exemplo n.º 1
0
    def test_save_and_load(self):
        self.prepare_test()

        game = Game()
        save('a', game)
        game.new_rang(2)
        save('b', game)
        game.hot_seat = True
        save('c', game)
        game.turn.another_turn()
        save('d', game)

        new_game = Game()
        load(new_game, 3)
        assert new_game.hot_seat
        assert new_game.rang == 2
        assert new_game.turn.color == Color.Blue

        load(new_game, 2)
        assert new_game.turn.color == Color.Red

        load(new_game, 1)
        assert not new_game.hot_seat

        load(new_game, 0)
        assert new_game.rang == 11
Exemplo n.º 2
0
 def test_to_lose_update(self):
     game = Game()
     game.new_rang(2)
     game.hex_dictionary = {
         (0, 0): Color.White,
         (-1, 2): Color.Blue,
         (1, 2): Color.White,
         (0, 4): Color.Red
     }
     game.update_game(389, 243)
     assert game.win
     assert not game.newRecord
Exemplo n.º 3
0
    def test_right_hex_dictionary(self):
        self.prepare_test()

        game = Game()
        game.new_rang(2)
        diction = {(0, 0): Color.White, (-1, 2): Color.Red,
                   (1, 2): Color.Red, (0, 4): Color.Blue}
        game.hex_dictionary = diction.copy()

        save('a', game)

        new_game = Game()
        load(new_game, 0)
        assert new_game.hex_dictionary == diction
Exemplo n.º 4
0
 def test_to_win_update(self):
     game = Game()
     game.new_rang(2)
     game.hex_dictionary = {
         (0, 0): Color.White,
         (-1, 2): Color.Red,
         (1, 2): Color.Blue,
         (0, 4): Color.White
     }
     game.update_game(399, 249)
     assert (game.hex_dictionary == {
         (0, 0): Color.Red,
         (-1, 2): Color.Red,
         (1, 2): Color.Blue,
         (0, 4): Color.White
     })
     assert game.win
     assert game.newRecord
Exemplo n.º 5
0
 def test_undo_history(self):
     game = Game()
     game.hot_seat = True
     game.new_rang(2)
     game.update_game(389, 243)
     game.update_game(331, 344)
     assert (game.undo_history == [((0, 0), Color.Red),
                                   ((-1, 2), Color.Blue)])
     game.undo()
     assert (game.undo_history == [((0, 0), Color.Red)])
     assert (game.redo_history == [((-1, 2), Color.Blue)])
     game.undo()
     assert (game.undo_history == [])
     assert (game.redo_history == [((-1, 2), Color.Blue),
                                   ((0, 0), Color.Red)])
     game.undo()
     assert (game.undo_history == [])
     assert (game.redo_history == [((-1, 2), Color.Blue),
                                   ((0, 0), Color.Red)])
     game.update_game(356, 324)
     assert (game.redo_history == [])
Exemplo n.º 6
0
 def test_new_rang(self, n=5):
     game = Game()
     game.new_rang(n)
     assert (game.rang == n)
     assert (game.hex_dictionary == make_hex_dict(n))