OChess v0.0.2
Programmer's Manual
Game.hpp
1#pragma once
2
3#include "ChessArbiter.hpp"
4#include "HalfMove.hpp"
5#include "ochess.hpp"
6#include <unordered_map>
7
12class Game {
15 HalfMove *moves;
16 std::string board;
17 std::string initial_fen;
18 std::string result;
19 std::unordered_map<std::string, std::string> tags;
21 chessarbiter::ChessArbiter arbiter;
22
23public:
24 Game(const Game* g);
25 Game();
26 Game(std::string fen);
27 Game(HalfMove *m, std::string initial_fen);
28 ~Game();
29 std::string GetBoard();
30 std::string GetTag(std::string tagname);
31 void SetTag(std::string tagname, std::string value);
32 void DeleteTag(std::string tagname);
33 HalfMove *GetCurrentMove();
34 HalfMove *GetNextMove();
35 HalfMove *GetMoves();
36 std::string GetFen();
37 std::string GetResult();
38 void GetOpening(std::string &name,std::string &eco);
40 bool Play(std::string move,char promotion='q');
41 bool IsBlackToPlay();
42 bool IsCheckmate(bool forBlack);
44 bool IsPromotionMove(std::string absolute_move);
45 void Previous();
46 void Next();
48 void DeleteMove(HalfMove *m);
49 void PromoteMove(HalfMove *m);
50 void SetMoveAsMainline(HalfMove *m);
51 void SetCurrent(HalfMove *m);
52 std::vector<std::string> ListTags();
53 void SetResult(std::string result);
59 void BuildAndVerify();
60};
Hold an entire chess game. Used in many places in the projects.
Definition: Game.hpp:12
bool IsPromotionMove(std::string absolute_move)
Check if a given absolute move consists in a pawn promotion.
Definition: Game.cpp:105
HalfMove * current
64 char string that contains all the pieces on the board (used in BoardCanvas)
Definition: Game.hpp:14
void BuildAndVerify()
Build current game Verify and play all the moves in the game while building the fen for each move.
Definition: Game.cpp:215
void DeleteMove(HalfMove *m)
Delete a move (its mainline and variations recursively)
Definition: Game.cpp:61
chessarbiter::ChessArbiter arbiter
Used by various methods of the class.
Definition: Game.hpp:21
bool Play(std::string move, char promotion='q')
Play the given absolute move.
Definition: Game.cpp:111
This class extends CGEHalfMove (to be displayed in the game editor)
Definition: HalfMove.hpp:13