-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpiece.cpp
More file actions
56 lines (41 loc) · 1.06 KB
/
piece.cpp
File metadata and controls
56 lines (41 loc) · 1.06 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
#include "piece.h"
#include <string>
Piece::Piece() {
}
void Piece::init(int _posX, int _posY) {
posX = _posX;
posY = _posY;
}
Piece::~Piece() {
}
bool Piece::canMoveTo(int targetX, int targetY) {
for (unsigned int i = 0 ; i < availableMovements.size() ; i++) {
if (availableMovements[i][0] == targetX && availableMovements[i][1] == targetY) {
return true;
}
}
return false;
}
void Piece::moveTo(int targetX, int targetY) {
posX = targetX;
posY = targetY;
}
const std::vector<int> Piece::getPosition() {
std::vector<int> position;
position.resize(2);
position[0] = posX;
position[1] = posY;
return position;
}
void Piece::computeAvailableMovements(std::vector<Piece*> own, std::vector<Piece*> opp) {
}
std::string Piece::toString() const {
std::string s = "Pièce en " ;
s = std::to_string(posX) + " et " + std::to_string(posY) ;
return s;
}
void Piece::clearAvailableMovements() {
availableMovements.clear();
}
void Piece::deleteAvailableMovements(std::vector<int>) {
}