-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chess.h
71 lines (52 loc) · 1.81 KB
/
Chess.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
#ifndef CHESS_H
#define CHESS_H
#include <iostream>
#include "Piece.h"
#include "Board.h"
class Chess
{
// Reads the board in from a stream
friend std::istream& operator >> ( std::istream& is , Chess& chess );
public:
// This default constructor initializes a board with the standard piece positions, and sets the state to white's turn
Chess( void );
// Returns a constant reference to the board
/////////////////////////////////////
// DO NOT MODIFY THIS FUNCTION!!!! //
/////////////////////////////////////
const Board& board( void ) const { return _board; }
// Returns true if it's white's turn
/////////////////////////////////////
// DO NOT MODIFY THIS FUNCTION!!!! //
/////////////////////////////////////
bool turn_white( void ) const { return _turn_white; }
// Sets _turn_white for a new board
void set_turn_white( char white_black ) {
if(white_black == 'b') {
_turn_white = false;
}
else {
_turn_white = true;
}
// If none of the above, there's an error.
// So we just assume it starts white.
}
// Attempts to make a move. If successfull, the move is made and the turn is switched white <-> black
bool make_move( std::pair< char , char > start , std::pair< char , char > end );
// Returns true if the designated player is in check from the given board
bool in_p_check( bool white, const Board& b ) const;
// Returns true if the designated player is in check
bool in_check( bool white ) const;
// Returns true if the designated player is in mate
bool in_mate( bool white ) const;
// Returns true if the designated player is in mate
bool in_stalemate( bool white ) const;
private:
// The board
Board _board;
// Is it white's turn?
bool _turn_white;
};
// Writes the board out to a stream
std::ostream& operator << ( std::ostream& os , const Chess& chess );
#endif // CHESS_H