-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamestate.cpp
38 lines (29 loc) · 934 Bytes
/
gamestate.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
#include "gamestate.h"
// Constructor implementation
GameState::GameState(): m_whitesTurn(true), m_inCheck(false), m_checkmate(false), m_stalemate(false), m_whiteKingPosition({7, 4}), m_blackKingPosition({0, 4}){
}
bool GameState::isPieceTurn(int x, int y) const{
//whites turn and piece is white
if(m_chessBoard[y][x]>20 && m_whitesTurn){
return true;
}
//blacks turn and piece is black
else if(m_chessBoard[y][x] > 0 && m_chessBoard[y][x] < 20 && !m_whitesTurn){
return true;
}
else{
return false;
}
}
void GameState::printBoard() const {
for (int y = 0; y < 8; ++y) {
for (int x = 0; x < 8; ++x) {
if(m_chessBoard[y][x]!=0)
std::cout << m_chessBoard[y][x] << ' ';
else
std::cout << "0 " << ' ';
}
std::cout << std::endl;
}
std::cout<<"-----------------------"<<std::endl;
}