-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueen.cpp
More file actions
54 lines (38 loc) · 1.47 KB
/
Queen.cpp
File metadata and controls
54 lines (38 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "Queen.h"
#include <vector>
#include <iostream>
#include "Chessboard.h"
#include "Bishop.h"
#include "Rook.h"
using namespace std;
Queen::Queen(bool white) : Chessman('q', white), Bishop(white), Rook(white)
{
}
void Queen::calculate_possible_moves(const int row, const int col, const Chessboard& cb) const
{
Bishop::calculate_possible_moves(row, col, cb);
Rook::calculate_possible_moves(row, col, cb);
}
std::vector<Position> Queen::get_moves() const
{
int reserve_size = 0;
vector<Position> joined_vector;
if (Bishop::valid_moves != nullptr)
reserve_size += Bishop::valid_moves->size();
if (Bishop::capture_moves != nullptr)
reserve_size += Bishop::capture_moves->size();
if (Rook::valid_moves != nullptr)
reserve_size += Bishop::valid_moves->size();
if (Rook::capture_moves != nullptr)
reserve_size += Bishop::capture_moves->size();
joined_vector.reserve(reserve_size);
if (Bishop::valid_moves != nullptr)
joined_vector.insert(joined_vector.end(), Bishop::valid_moves->begin(), Bishop::valid_moves->end());
if (Bishop::capture_moves != nullptr)
joined_vector.insert(joined_vector.end(), Bishop::capture_moves->begin(), Bishop::capture_moves->end());
if (Rook::valid_moves != nullptr)
joined_vector.insert(joined_vector.end(), Rook::valid_moves->begin(), Rook::valid_moves->end());
if (Rook::capture_moves != nullptr)
joined_vector.insert(joined_vector.end(), Rook::capture_moves->begin(), Rook::capture_moves->end());
return joined_vector;
}