-
Notifications
You must be signed in to change notification settings - Fork 0
/
piece.cpp
80 lines (54 loc) · 1.04 KB
/
piece.cpp
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
/*
* piece.h
* Pieces to move on the gameboard.
*
* @author Yoan DUMAS
* @versionn 1.0
* @date 18/12/2013
*/
#include "piece.h"
#include <iostream>
// Initition of the counter
int Piece::counter_s = 1;
Piece::Piece() :
ID_(counter_s++),
color_(WHITE)
{
pos_.i = -1;
pos_.j = -1;
}
Piece::~Piece() {
pos_.i = -1;
pos_.j = -1;
}
Piece::Piece(const position_t & inPosition, const color_t & inColor) :
pos_(inPosition),
ID_(counter_s++),
color_(inColor)
{}
Piece::Piece(const Piece & inPiece) :
pos_(inPiece.getPosition()),
ID_(counter_s++),
color_(inPiece.getColor())
{}
color_t Piece::getColor() const {
return color_;
}
int Piece::getID() const {
return ID_;
}
bool Piece::isWhite() const {
return color_==WHITE;
}
bool Piece::isBlack() const {
return color_==BLACK;
}
position_t Piece::getPosition() const {
return pos_;
}
void Piece::setColor(const color_t & inColor) {
color_ = inColor;
}
void Piece::setPosition(const position_t & inPos) {
pos_ = inPos;
}