-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChessMove.cpp
More file actions
103 lines (100 loc) · 2.09 KB
/
ChessMove.cpp
File metadata and controls
103 lines (100 loc) · 2.09 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "ChessMove.hpp"
ChessMove::ChessMove(int from_row, int from_col, int to_row, int to_col, int color, int piece, int take_row, int take_col, bool promotion) : Move()
{
this->from_row = from_row;
this->from_col = from_col;
this->to_col = to_col;
this->to_row = to_row;
this->color = color;
this->piece = piece;
this->take_row = take_row;
this->take_col = take_col;
this->promotion = promotion;
}
int ChessMove::getFromRow()
{
return this->from_row;
}
int ChessMove::getFromCol()
{
return this->from_col;
}
int ChessMove::getToRow()
{
return this->to_row;
}
int ChessMove::getToCol()
{
return this->to_col;
}
int ChessMove::getPiece()
{
return this->piece;
}
int ChessMove::getColor()
{
return this->color;
}
int ChessMove::getTakeRow()
{
return this->take_row;
}
int ChessMove::getTakeCol()
{
return this->take_col;
}
bool ChessMove::getPromotion()
{
return this->promotion;
}
void ChessMove::setFromRow(int from_row)
{
this->from_row = from_row;
}
void ChessMove::setFromCol(int from_col)
{
this->from_col = from_col;
}
void ChessMove::setToRow(int to_row)
{
this->to_row = to_row;
}
void ChessMove::setToCol(int to_col)
{
this->to_col = to_col;
}
void ChessMove::setPiece(int piece)
{
this->piece = piece;
}
void ChessMove::setColor(int color)
{
this->color = color;
}
void ChessMove::setTakeRow(int take_row)
{
this->take_row = take_row;
}
void ChessMove::setTakeCol(int take_col)
{
this->take_col = take_col;
}
void ChessMove::setPromotion(bool promotion)
{
this->promotion = promotion;
}
bool ChessMove::eq(std::shared_ptr<Move> other_m)
{
std::shared_ptr<ChessMove> other = std::static_pointer_cast<ChessMove>(other_m);
return (
this->from_row == other->getFromRow() &&
this->from_col == other->getFromCol() &&
this->to_row == other->getToRow() &&
this->to_col == other->getToCol() &&
this->color == other->getColor() &&
this->piece == other->getPiece() &&
this->take_row == other->getTakeRow() &&
this->take_col == other->getTakeCol() &&
this->promotion == other->getPromotion()
);
}