-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
60 lines (41 loc) · 1.48 KB
/
Game.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
#ifndef GAME_H
#define GAME_H
#include <iostream>
#include "Piece.h"
#include "Board.h"
#include "Exceptions.h"
namespace Chess
{
class Game {
public:
// This default constructor initializes a board with the standard
// piece positions, and sets the state to white's turn
Game();
Game(const Game& game);
// Returns a constant reference to the board
const Board& get_board() const { return board; }
// Returns true if it is white's turn
bool turn_white() const { return is_white_turn; }
// Attemps to make a move. If successful, the move is made and
// the turn is switched white <-> black. Otherwise, an exception is thrown
void make_move(std::pair<char, char> start, std::pair<char, char> end);
// 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;
//Returns true if the designated player can make the move legally without being in check
bool has_available(bool white) const;
// Reads the board in from a stream
friend std::istream& operator>> (std::istream& is, Game& game);
private:
// The board
Board board;
// Is it white's turn?
bool is_white_turn;
};
// Writes the board out to a stream
std::ostream& operator<< (std::ostream& os, const Game& game);
}
#endif // GAME_H