-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBishop.cpp
69 lines (60 loc) · 2.84 KB
/
Bishop.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
#include "Bishop.h"
Bishop::Bishop(bool color) {
if (color) {
pieceType.setTexture(TextureManager::GetTexture("white_bishop"));
}
else {
pieceType.setTexture(TextureManager::GetTexture("black_bishop"));
}
ChessPiece::color = color;
dragging = false;
moveCount = 0;
canEnPassant = false;
canCastle = false;
canCastleLeft = false;
canCastleRight = false;
inCheck = false;
attackingKing = false;
protectingKing = false;
alreadyModified = false;
name = "Bish";
}
void Bishop::CalculateLegalMoves(vector<vector<ChessPiece*>>& gridPieces, int activeRowIndex, int activeColIndex, int activePieceOriginalPositionX, int activePieceOriginalPositionY, vector<Log>& logs, vector<ChessPiece*>& whitePieces, vector<ChessPiece*>& blackPieces) {
//Moves used for playing the game
legalMoves.clear();
legalMovesIncludingFriendlyFire.clear();
lineOfSight = true; //Send a LoS check all the way in one direction, false if hits friendly or wall
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, -pivot, activeColIndex, pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Up-Right
}
lineOfSight = true; //Reset the LoS check for the other diagonals
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, -pivot, activeColIndex, -pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Up-Left
}
lineOfSight = true; //So on
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, pivot, activeColIndex, pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Down-Right
}
lineOfSight = true; //And so forth
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, pivot, activeColIndex, -pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Down-Left
}
//Moves used for monitoring state
totalMoves.clear();
lineOfSight = true; //Send an LoS check all the way in one direction, false if hits wall
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, -pivot, activeColIndex, pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Up-Right
}
lineOfSight = true; //Reset the LoS check for the other diagonals
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, -pivot, activeColIndex, -pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Up-Left
}
lineOfSight = true; //So on
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, pivot, activeColIndex, pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Down-Right
}
lineOfSight = true; //And so forth
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, pivot, activeColIndex, -pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Down-Left
}
}