-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueen.cpp
109 lines (92 loc) · 4.72 KB
/
Queen.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "Queen.h"
Queen::Queen(bool color) {
if (color) {
pieceType.setTexture(TextureManager::GetTexture("white_queen"));
}
else {
pieceType.setTexture(TextureManager::GetTexture("black_queen"));
}
ChessPiece::color = color;
dragging = false;
moveCount = 0;
canEnPassant = false;
canCastle = false;
canCastleLeft = false;
canCastleRight = false;
inCheck = false;
attackingKing = false;
protectingKing = false;
alreadyModified = false;
name = "Quee";
}
void Queen::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, 0, activePieceOriginalPositionX, activePieceOriginalPositionY); //Up
}
lineOfSight = true; //Reset the LoS check for the other straights
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, pivot, activeColIndex, 0, activePieceOriginalPositionX, activePieceOriginalPositionY); //Down
}
lineOfSight = true; //So on
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, 0, activeColIndex, -pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Left
}
lineOfSight = true; //And so forth
for (int pivot = 1; lineOfSight; pivot++) {
AddMove(gridPieces, activeRowIndex, 0, activeColIndex, pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Right
}
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, 0, activePieceOriginalPositionX, activePieceOriginalPositionY); //Up
}
lineOfSight = true; //Reset the LoS check for the other straights
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, pivot, activeColIndex, 0, activePieceOriginalPositionX, activePieceOriginalPositionY); //Down
}
lineOfSight = true; //So on
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, 0, activeColIndex, -pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Left
}
lineOfSight = true; //And so forth
for (int pivot = 1; lineOfSight; pivot++) {
AddTotalMove(gridPieces, activeRowIndex, 0, activeColIndex, pivot, activePieceOriginalPositionX, activePieceOriginalPositionY); //Right
}
lineOfSight = true; //Send a LoS check all the way in one direction, false if hits friendly or 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
}
}