-
Notifications
You must be signed in to change notification settings - Fork 0
/
cell.cc
59 lines (51 loc) · 1.11 KB
/
cell.cc
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
#include <iostream>
#include <vector>
#include "cell.h"
class Piece;
Cell::Cell(){}
void Cell::setCoord(int xCoord, int yCoord) {
x = xCoord;
y = yCoord;
}
void Cell::clean() {
myPiece = nullptr;
occupied = 0;
threatenByWhite = 0;
threatenByBlack = 0;
}
int Cell::getX() const { return x; }
int Cell::getY() const { return y; }
int Cell::getOccupiedState() const { return occupied; }
int Cell::whiteThreatenState() const {return threatenByWhite;}
int Cell::blackThreatenState() const {return threatenByBlack;}
int Cell::threatenState(bool colour) const {
if (colour) {
return threatenByWhite;
} else {
return threatenByBlack;
}
}
Piece* Cell::returnPiece() const { return myPiece; }
void Cell::alertOn(bool colour) {
if (colour) {
++threatenByWhite;
} else {
++threatenByBlack;
}
}
void Cell::alertOff(bool colour) {
if (colour) {
--threatenByWhite;
} else {
--threatenByBlack;
}
}
void Cell::comeNotify(Piece *p, bool colour) {
myPiece = p;
if (colour) occupied = 1;
else occupied = 2;
}
void Cell::leaveNotify(int x, int y) {
myPiece = nullptr;
occupied = 0;
}