-
Notifications
You must be signed in to change notification settings - Fork 0
/
chessGame.h
84 lines (63 loc) · 1.86 KB
/
chessGame.h
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
/*
This header file contains th ChessGame class.
contains the whole game.
*/
#ifndef _CHESSGAME_H
#define _CHESSGAME_H
#include <SFML/Graphics.hpp>
#include <array>
#include <vector>
#include <iostream>
#include "board.h"
#include "piece.h"
#include <chrono>
class ChessGame : public sf::Drawable
{
private:
Board board;
std::array<Piece, 16> whitePieces;
std::array<Piece, 16> blackPieces;
Piece *selectedPiece;
std::vector<sf::RectangleShape> possibleMovesSquares;
std::string lastMove;
sf::RectangleShape infoRestart;
sf::Font font;
sf::Text textRestart;
sf::Text textTurn;
sf::Text textSituation;
sf::Text textLastMove;
// Tracking time
std::chrono::steady_clock::time_point begin;
std::chrono::steady_clock::time_point end;
void startTime();
void endTime();
std::chrono::seconds getElapsedTime();
// save details of recent games
void saveDetail();
bool selected;
bool playerTurn; // true = White turn, false = Black Turn
bool playerTurnCheck;//shows true for White's turn
bool mate;
int turn;//1 then 2 then 3 ....
void createMovesSquares();
void calcPossibleMoves();
void calcKingMoves(Piece *tmpPiece);
void calcQueenMoves(Piece *tmpPiece);
void calcRookMoves(Piece *tmpPiece);
void calcBishopMoves(Piece *tmpPiece);
void calcKnightMoves(Piece *tmpPiece);
void calcPawnMoves(Piece *tmpPiece);
void calcCastling(Piece *tmpPiece);
void eraseMoves(Piece *tmpPiece);
void checkMate();
void updateInfo();
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const;
public:
ChessGame(sf::Color bordCol1, sf::Color bordCol2);
bool getSelected() { return selected; }
bool getMate() { return mate; }
bool selectPiece(int pos);
void moveSelected(int pos);
void restart();
};
#endif