def test_iterate_all_moves_with_both_players(self): p3 = Piece((0, 1), Owner.OPPONENT, Rank('4')) b = Board().place_piece(p2).place_piece(p3) expected_for_player = [((0, 0), m) for m in b.iterate_moves_for_piece(p2)] expected_for_opponent = [((0, 1), m) for m in b.iterate_moves_for_piece(p3)] self.assertEqual(list(b.iterate_all_moves(Owner.PLAYER)), expected_for_player) self.assertEqual(list(b.iterate_all_moves(Owner.OPPONENT)), expected_for_opponent)
def test_iterate_all_moves_with_multiple_pieces(self): b = Board().place_piece(p2).place_piece(p1) expected = ([((0, 0), m) for m in b.iterate_moves_for_piece(p2)] + [((0, 1), m) for m in b.iterate_moves_for_piece(p1)]) self.assertEqual(list(b.iterate_all_moves(Owner.PLAYER)), expected)
def test_iterate_all_moves_with_one_piece(self): b = Board().place_piece(p2) expected = [((0, 0), m) for m in b.iterate_moves_for_piece(p2)] self.assertEqual(list(b.iterate_all_moves(Owner.PLAYER)), expected)
def test_iterate_all_moves_with_landmine_and_flag(self): b = Board().place_piece(landmine).place_piece(flag) self.assertEqual(list(b.iterate_all_moves(Owner.PLAYER)), [])